groupadd mygroup
useradd -g mygroup myuser
[root@localhost home]# su - myuser
[myuser@localhost ~]$ touch hv ex
[myuser@localhost ~]$ ll
total 0
-rw-r--r--. 1 myuser mygroup 0 Apr 10 19:36 ex
-rw-r--r--. 1 myuser mygroup 0 Apr 10 19:36 hv
[myuser@localhost ~]$ chown :root hv
chown: changing group of 'hv': Operation not permitted
myuser没有权限,给权限
[myuser@localhost ~]$ su - root
Password:
[root@localhost ~]# vim /etc/sudoers
myuser ALL=(ALL) NOPASSWD:ALL
[root@localhost ~]# su - myuser
[myuser@localhost ~]$ sudo chown :root hv
[myuser@localhost ~]$ ll
total 0
-rw-r--r--. 1 myuser mygroup 0 Apr 10 19:36 ex
-rw-r--r--. 1 myuser root 0 Apr 10 19:36 hv
[root@localhost ~]# useradd -d /helen helen
[root@localhost ~]# groupadd -g 600 temp
[root@localhost ~]# id helen
uid=1003(helen) gid=1003(helen) groups=1003(helen)
[root@localhost ~]# gpasswd -a helen temp
Adding user helen to group temp
[root@localhost ~]# id helen
uid=1003(helen) gid=1003(helen) groups=1003(helen),600(temp)
[root@localhost ~]# groupadd -g 600 temp
[root@localhost ~]# useradd helen -d /helen -G temp
[root@localhost helen]# id helen
uid=1003(helen) gid=1003(helen) groups=1003(helen),600(temp)
[root@localhost ~]# useradd user -G group
[root@localhost ~]# id user
uid=1004(user) gid=1005(user) groups=1005(user),1004(group)
#也可以在创建用户的时候用-p指定密码,但是密码要是密文的
[root@localhost ~]# echo "a1b2b3" | passwd --stdin user
[root@localhost ~]# tail -3 /etc/shadow
myuser:!!:19457:0:99999:7:::
helen:!!:19457:0:99999:7:::
user:$y$j9T$yJJuyzQ05IguhHelVrDXN0$5WX6AhFbgVb7XMxmaEjMACAFni1HKKbAbgRUDbj3fj4:19457:0:99999:7:::
[root@localhost ~]# groupadd -g 2000 adminuser
[root@localhost ~]# tail -2 /etc/group
user:x:1005:
adminuser:x:2000:
[root@localhost ~]# useradd natasha -G adminuser
[root@localhost ~]# id natasha
uid=1005(natasha) gid=2001(natasha) groups=2001(natasha),2000(adminuser)
useradd sarah -s /sbin/nolgin
echo "glegunge" | passwd --stdin 用户名
[root@localhost ~]# useradd -u 3456 -c alina alex
[root@localhost ~]# tail -2 /etc/passwd
natasha:x:1005:2001::/home/natasha:/bin/bash
alex:x:3456:3456:alina:/home/alex:/bin/bash
[root@localhost ~]# passwd alex
Changing password for user alex.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# tail -2 /etc/shadow
natasha:!!:19457:0:99999:7:::
alex:$y$j9T$mzHLeqU6VUFRjrunrOW5/.$LxIMtUEUVtAg4Aa6YL8/HkOAyYuJO8pV7iYsxlKwHjD:19457:0:99999:7:::
[root@localhost ~]#
[root@localhost ~]# groupadd g1
[root@localhost ~]# touch redhat.txt
[root@localhost ~]# ll
drwxr-xr-x. 2 root root 6 Feb 9 18:21 Public
-rw-r--r--. 1 root root 0 Apr 10 20:43 redhat.txt
[root@localhost ~]# chown redhat:g1 redhat.txt
[root@localhost ~]# ll
total 16
drwxr-xr-x. 2 root root 6 Feb 9 18:21 Public
-rw-r--r--. 1 redhat g1 0 Apr 10 20:43 redhat.txt
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- huatuo8.com 版权所有 湘ICP备2023022238号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务