• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Linux基础用户相关

linux 搞代码 3年前 (2022-03-03) 18次浏览 已收录 0个评论

getent

getent is a common way to look up in user details on Linux;
getent is a Linux command that helps the user to get the entries in a number of important text files called databases;

Supported databases:

1. passwd shadow
2. group gshadow
2. ahosts ahostsv4 ahostsv6
2. aliases ethers 
4. hosts initgroups
2. netgroup networks  protocols rpc services 

Usage:
getent [OPTION...] database [key ...]

用户相干文件

/etc/passwd

格局:
login_name:passwd(x):UID:GID:GECOS:home_directory:shell

/etc/shadow

格局:
login_name:passwd(sha512):
从1970.01.01起到明码最近一次被批改的工夫:
明码再过几天能够被变更(0-任意):
明码再过几天必须被变更:
明码过期前几天零碎揭示用户(默认7天):
明码过期几天后账号被锁定:
从1970.01.01算起,多少天后账号生效

/etc/group
/etc/gshadow

用户相干命令

useradd

useradd [OPTIONS] LOGIN
useradd -D -- 默认配置/etc/default/useradd

newusers — update and create new users in batch

newusers [options] format_files
pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shell

su和sudo的区别

suChange the effective user id and group id to that of USER. A mere – implies -l. If USER not given, assume root.

su [options] [-] [USER [arg]...]

sudoexecute a command as another user

sudo [options] [<command>]
sudo -i -- run login shell as the target user
sudo -s -- run shell as the target user;

Different:

  1. -The main difference between the two is that su requires the password of the target account, while sudo requires the password of the current user.
  2. -Additionally,it is advisable to stick to sudo when performing tasks that require root privileges. By doing so, the current user is only granted privileged for the specified command.

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Linux基础用户相关

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址