Create a user process manually
1) New user natasha,uid is 1000,gid to 555, note information is "master"
vim/etc/passwd
Natasha:x:1000:555:master:/home/natasha:/bin/bash
2) Modify Natasha user's home directory for/natasha
[Email protected] ~]# VIM/ETC/PASSWD
[Email protected] ~]# Vim/etc/shadow
[Email protected] ~]# Vim/etc/group
[Email protected] ~]# Vim/etc/gshadow
[Email protected] ~]# Mkdir/home/natasha
[Email protected] ~]# ls-a/home/natasha/
. ..
[Email protected] ~]# cp-r/etc/skel/. [!.] */natasha/
[Email protected] ~]# Touch/var/spool/mail/ntasha
[[email protected] ~]# ID Natasha
uid=1000 (Natasha) gid=555 (Natasha) group =555 (Natasha)
3) View the last line of the user information profile
[Email protected] ~]# tail-1/etc/passwd
Natasha:x:1001:555:master:/home/natasha:/bin/bash
4) Set the password "123" for the Natasha user
[Email protected] ~]# passwd Natasha
Change the password for the user Natasha.
New Password:
Invalid password: password is less than 8 characters
Re-enter the new password:
PASSWD: All the authentication tokens have been successfully updated.
5) View the last line of the user's password profile
[Email protected] ~]# tail-1/etc/shadow
Natasha:$6$j9u/rnhi$ykp4xbjyxqhzo1qdfbs62hrzn5wgxxfucgx80ijbifuncjsxeszq.q2m8x/feeeczk5eeq0ooo3ivkymyl2az0 : 17310:0:99999:7:::
6) Lock the Natasha user account
[Email protected] ~]# usermod-l Natasha
7) Unlock the Natasha user account
[Email protected] ~]# usermod-u Natasha
8) New group Police,gid to 999
[Email protected] ~]# groupadd-g 999 police
police:x:999:
9) View the last line of the group configuration file
[Email protected] ~]# tail-1/etc/group
police:x:999:
10) Add Natasha user to police group
[Email protected] ~]# Usermod natasha-g Police
[[email protected] ~]# ID Natasha
uid=1000 (Natasha) gid=555 (Natasha) group =555 (Natasha), 999 (police)
11) Modify the group name of the police group to Jingcha
[Email protected] ~]# groupmod-n Jingcha Police
[Email protected] ~]# tail-1/etc/group
Jingcha:x:999:natasha
12) Delete Natasha user, even home directory and mailbox deleted together
USERDEL-R Natasha
13) Delete Jingcha Group
[Email protected] ~]# Groupdel Jingcha
Id[[email protected] ~]# Tail/etc/group
SSHD:X:74:
AVAHI:X:70:
SLOCATE:X:21:
POSTDROP:X:90:
postfix:x:89:
stapusr:x:156:
stapsys:x:157:
stapdev:x:158:
TCPDUMP:X:72:
Love:x:1000:love
Two Create catalog test
1) Create a directory test in the user's home directory, enter test to create an empty file File1
[Email protected] ~]# mkdir test
[[Email protected] ~]# CD test
[email protected] test]# Touch file1
2) display file information in long format, note the permissions of the file and the user and group to which it belongs
[email protected] test]# LL
Total dosage 0
-rw-r--r--. 1 root root 0 May 04:07 file1
3) Set permissions for file File1 so that other users can write to this file.
[Email protected] test]# chmod o+w file1
4) View the setting results,
[email protected] test]# LL
Total dosage 0
-rw-r--rw-. 1 root root 0 May 04:07 file1
5) Remove the Read permission from the same group of users to the file File1 and view the setting results.
[Email protected] test]# chmod g=-file1
[email protected] test]# LL
Total dosage 0
-RW----rw-. 1 root root 0 May 04:07 file1
6) Use digital notation to set permissions for file files, all readable, writable, and executable, and the owning group user and other users have only read and execute permissions. Review the setup results when the settings are complete.
[Email protected] test]# chmod 733 file1
[email protected] test]# LL
Total dosage 0
-rwx-wx-wx. 1 root root 0 May 04:07 file1
7) Change the permissions of the file File1 in digital form so that the owner can only read the file. No other user has permission. View the settings results.
[Email protected] test]# chmod file1
[email protected] test]# LL
Total dosage 0
-R--------. 1 root root 0 May 04:07 file1
8) go back to the upper directory to see the test permissions
[Email protected] test]# CD.
[email protected] ~]# ll D test
LS: Unable to access D: no file or directory
Test
Total dosage 0
-R--------. 1 root root 0 May 04:07 file1
9) Add write permissions to this directory for other users
[Email protected] ~]# chmod o+w test/
[Email protected] ~]# ll-d test
Drwxr-xrwx. 2 root root 19 May 04:07 test
Three create a new user by manipulating the file Alex
1, [[email protected] ~]# vim/etc/passwd----->1,2----> Edit user Files 2, [[email protected] ~]# tail-1/etc/passwd Add new user, view operation Alex:1111:1111::/home/alex:/bin/bash
3, [[email protected] ~]# Vim/etc/shadow ----->3,4----> Edit user Password
4, [[email protected] ~]# tail-1/etc/shadow file, view operation
alex:!! : 17310:0:99999:7:::
5, [[email protected] ~]# vim/etc/group ------->5,6-----> Edit Group File
6, [[email protected] ~]# tail-1/etc/group View Operation
alex:x:1111:
7. [[email protected] ~]# vim/etc/gshadow ---->7,8---> Edit Group password file
8. [[email protected] ~]# tail-1/etc/gshadow View Operation
alex:!::
9,10,11------> Common Files, copy user templates to Alex users
9, [[email protected] ~]# Mkdir/home/alex
10, [[email protected] ~]# cp-r/etc/skel/. [!.] */home/alex
11, [[email protected] ~]# ls-a/home/alex
. .. . bash_logout. Bash_profile. BASHRC. Mozilla
12,13,14----> Because user Alex is a ' root ' user created, change user owner and genus,
Change to Alex.
12, [[email protected] ~]# ll-d/home/alex
Drwxr-xr-x. 3 Alex Alex 78 May 06:47/home/alex
13, [[email protected] ~]# chown-r Alex:alex/home/alex
14, [[email protected] ~]# Touch/var/spool/mail/alex
15,16,17-----> Create user mailboxes, because user Alex is ' root ' user created, change belongs to the main group Alex, mail
15, [[email protected] ~]# chown-r Alex:mail/var/spool/mail/alex
16, [[email protected] ~]# ll-d/var/spool/mail/alex
-rw-r--r--. 1 Alex Mail 0 May 06:56/var/spool/mail/alex
17, [[email protected] ~]# ID Alex
uid=1111 (Alex) gid=1111 (Alex) group =1111 (Alex)
Four Authentication permissions
1) Create a new directory/test/dir, the owner is Tom, the array for the Group1,/test directory has permission of 777
[Email protected] ~]# mkdir-p/test/dir
[Email protected] ~]# ll-d/test/dir
Drwxr-xr-x. 2 root root 6 May 22:26/test/dir
[Email protected] ~]# Useradd Tom
[Email protected] ~]# Groupadd group1
[Email protected] ~]# chown tom:group1/test/dir/
[Email protected] ~]# ll-d/test/dir
Drwxr-xr-x. 2 Tom Group1 6 May 22:26/test/dir
[Email protected] ~]# chmod 777/test
[Email protected] ~]# ll-d/test
Drwxrwxrwx. 3 root root 17 May 22:26/test
2) [[email protected] tmp]# mkdir test
[Email protected] ~]# cd/tmp
[Email protected] tmp]# mkdir test
3) [[email protected] tmp]# ll-d test
[Email protected] tmp]# ll-d test
4) Drwxr-xr-x. 2 root root 6 May 08:32 test
Drwxr-xr-x. 2 root root 6 May 22:40 test
2) New user jack, switch to the jack user, verify the jack user rwx permissions to the dir directory (open another terminal, and then modify the Dir directory's others permissions)
[Email protected] tmp]# Useradd Jack
[[email protected] tmp]# ID Jack
uid=1009 (Jack) gid=1011 (Jack) group =1011 (Jack)
[Email protected] tmp]# Su-jack
[Email protected] ~]$ ll/test/dir/
Total dosage 0
[Email protected] ~]# chmod o+w/test/dir/
[Email protected] ~]$ Touch/test/dir/a.txt
[Email protected] ~]$ ll-d/test/dir/a.txt
-rw-rw-r--. 1 Jack Jack 0 May 22:52/test/dir/a.txt
[Email protected] ~]$ cd/test/dir/
[Email protected] dir]$ CD-
/home/jack
[[email protected] ~]# echo "Date" >/test/dir/a.txt
[Email protected] ~]# chmod o-x/test/dir/
[Email protected] ~]# chmod o-r/test/dir/
3) Add Jack to the group1 group to verify the Jack User's rwx permissions to the dir directory (open another terminal, and then modify the group permissions of the Dir directory)
4) switch to Tom User, verify the RWX permission of Tom user to dir directory (open another terminal, modify the user permission of Dir directory in turn)
5) Create a new file in Dir directory Tom.txt, the owner is Tom, the group is the Group1,/test directory permissions of 777
6) New user rose, switch to Rose User, verify the Rose User's rwx permissions to Tom.txt (open another terminal, modify tom.txt others permissions to match the verification process)
7) Add rose to the group1 group and, under the Rose user, verify the rwx permissions of the rose user to Tom.txt (open another terminal and modify Tom.txt group1 permissions to match the verification process)
8) switch to Tom User, verify Tom User's rwx permission to Tom.txt (open another terminal, modify Tom.txt user permission to cooperate with the verification process)
4. Linux Build Group