Linux基础-用户相关

詹姆斯大胡子 -
Linux基础-用户相关
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的区别

su -- Change 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]...]

sudo -- execute 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:

-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.-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.
特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。

Tags 标签

linux

扩展阅读

加个好友,技术交流

1628738909466805.jpg