首页 > 其他分享 >用户管理

用户管理

时间:2025-01-09 09:12:42浏览次数:1  
标签:sbin 管理 yu nologin 用户 miaojiang root localhost

[root@localhost ~]# ls -l /home/
total 0
drwx------. 2 liuxin    liuxin    62 Jan  8 22:16 liuxin
drwx------. 2 miaojiang miaojiang 62 Jan  8 22:31 miaojiang
[root@localhost ~]# grep -w miaojiang /etc/passwd
miaojiang:x:1001:1001::/home/miaojiang:/bin/bash
[root@localhost ~]# id miaojiang
uid=1001(miaojiang) gid=1001(miaojiang) groups=1001(miaojiang)
[root@localhost ~]# groupadd yanfa
[root@localhost ~]# tail /etc/gro
groff/  group   group-
[root@localhost ~]# tail /etc/group
polkitd:x:998:
ssh_keys:x:997:
tss:x:59:
abrt:x:173:
sshd:x:74:
postdrop:x:90:
postfix:x:89:
liuxin:x:1000:
miaojiang:x:1001:
yanfa:x:1002:
[root@localhost ~]# useradd -M -s /sbin/nologin yu
[root@localhost ~]# tail /etc/pa
pam.d/   passwd   passwd-
[root@localhost ~]# tail /etc/passwd
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/s                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     bin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
liuxin:x:1000:1000::/home/liuxin:/bin/bash
miaojiang:x:1001:1001::/home/miaojiang:/bin/bash
yu:x:1002:1003::/home/yu:/sbin/nologin
[root@localhost ~]# ls /home/
liuxin  miaojiang
[root@localhost ~]# usermod -u 1500 -s /bin/bash -c myself_user -G old -e "20251010" -f 10 -d /home/yu yu
usermod: group 'old' does not exist
[root@localhost ~]# groupadd old
[root@localhost ~]# usermod -u 1500 -s /bin/bash -c myself_user -G old -e "20251010" -f 10 -d /home/yu yu
[root@localhost ~]# id yu
uid=1500(yu) gid=1003(yu) groups=1003(yu),1004(old)
[root@localhost ~]# ls /home/
liuxin  miaojiang
[root@localhost ~]# id yu
uid=1500(yu) gid=1003(yu) groups=1003(yu),1004(old)
[root@localhost ~]# tail -f /etc/pa
pam.d/   passwd   passwd-
[root@localhost ~]# tail -f /etc/passwd
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
liuxin:x:1000:1000::/home/liuxin:/bin/bash
miaojiang:x:1001:1001::/home/miaojiang:/bin/bash
yu:x:1500:1003:myself_user:/home/yu:/bin/bash
^C
[root@localhost ~]# cat /etc/pa
pam.d/   passwd   passwd-
[root@localhost ~]# cat /home/
cat: /home/: Is a directory
[root@localhost ~]# ls /home/
liuxin  miaojiang
[root@localhost ~]# userdel -rf liuxin
[root@localhost ~]# ls /home/
miaojiang
[root@localhost ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
miaojiang:x:1001:1001::/home/miaojiang:/bin/bash
yu:x:1500:1003:myself_user:/home/yu:/bin/bash
[root@localhost ~]# chpasswd
yu:123
miaojiang:456
[root@localhost ~]# su yu
bash-4.2$ su miaojiang
Password:
[miaojiang@localhost root]$ su root
Password:
[root@localhost ~]#

 

标签:sbin,管理,yu,nologin,用户,miaojiang,root,localhost
From: https://www.cnblogs.com/wmqxlt/p/18660975

相关文章