5.用户及权限

*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: -l newusername
-u new userId
-d new home directory
-g main group
-G other groups
-L lock the account
-U unlock 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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值