本文主要是介绍Permissions,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Permissions
Here we will look at the essential part of system security and introduce the following command:
id:diplay user id
chmod:change a file’s mode
umask:set the default file permissions
su: run a shell as another user
chown:change a file’s owner
chgrp:change a file’s group ownership
passwd:change a user’s password
User accounts are defined in the /etc/passwd file.This file defines the username,uid,gid,the account’s real name,home directory and login shell
Groups are defined in the /etc/group file.
Reading,Writing and Executing
ls -l fool.txt
the first character means the type of the file/directory:
- -:a regular file
- d:directory
- l:a system link
- c:a character special file.It refers to a device that handles data as a stream of bytes.Sucn as terminal and moderm.
- b:a block special file,It refer s to a device that handles data in blocks.Such as hard-driver and CD-ROM drive.
umask-set default permissions
the umask command controls the default permissions given to a file when it is create.
the value of the umask is Oct and for example ,the value is 222,means the file don’t have the write permission with user/group/others.Where a 1 appears in the binary value,the corresponding attribute is unset.
su - run a shell with substitute user ans group IDs
su is used to start a shell as another user,the command pattern likes thie:
su [-[l]] [user]
if the ‘-l’ option is included,the resulting shell session is a login shell for the specified changed to the user’s environment.
If we want to start a shell with superuser,we can use:
su -
If we want to return to the previous user:
exit
sudo - execute a command as another user
sudo is just like su,but has some important addtional capabilities.sudo has been configured to allow us to run a fictitious backup program called backup_script with a superuser permission and does’t need to enter the password.in Ubuntu you can use it to execute the command with root right.
chown - change file owner and group
is used to change the owner/group of a file or directory,and need superuser permission.
chown [owner] [:[group]] file ...
Change your password
passwd [user]
这篇关于Permissions的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!