5.用户及权限

来源:互联网 发布:mac win8u盘安装 编辑:程序博客网 时间:2024/06/10 07:29
*info about account
syntax: id


*change password
styntax: passwd


*files about account/group
/etc/passwd   account
/etc/shadow   password
/etc/group    group


*View current users
whoami  -show the current user
who     -show all users who are using this server
w       -show all users who are using this server and what they are doing


*how to create a new user
syntax: useradd newusername


*add password for account
syntax: passwd [option] username
option:
-d   home directory
-s   shell
-u   userId
-g   main group
-G   Other groups (seperate by ",")


*modify account
syntax: usermod  [option]  username
option: -lnewusername
-unew userId
-dnew home directory
-gmain group
-Gother groups
-Llock the account
-Uunlock the account


*delete account
syntax: userdel [option] username
option: -r   delete home directory
example: userdel test    (delete account test but not delete its home directory)
userdel -r test   (delete account test and delete its home directory)


*add group
syntax: groupadd groupname


*modify group
syntax: groupmod [option]
option:-n newname oldname (change group name)
-g newGid oldGid  (change groupId)


*delete group
syntax: groupdel groupname



*use command "chown" to change owner of file/directory
syntax: chown account file
    chown -R account directory


*use command "chgrp" to change group of file/directory
syntax: chgrp group file
chgrp -R group directory


*use command "chmod" to change permission of file/directory
syntax: chmod [option] file
chmod -R [option] directory
option:
u,g,o represent user,group,other
a represent ugo
+,- represent add,del
4,2,1 represent r,w,x
example:
chmod u+rw filename
chmod g-x fileanme
chmod go+r filename
chmod a-x filename
chmod 660 filename (change permission to rw-rw----)


*default permission of file/directory
default file permission: 777-umask
default directory permission: 666-umask
syntax: umask  (show umask)
     umask newnumber  (change umask)


*special right
suid (let exec file run as it owner's right)