Linux job experts do not need to read

Source: Internet
Author: User
If you are a linux job expert, you do not need to read the Linux general technology-Linux technology and application information. The following is a detailed description. 1. Add users u1 and u2 and set the password (as shown below)
[Root @ mxl/] # useradd u1
[Root @ mxl/] # useradd u2
[Root @ mxl/] # passwd u1
Changing password for user u1.
New UNIX password:
Bad password: it is too simplistic/systematic
Retype new UNIX password:
Passwd: all authentication tokens updated successfully.
[Root @ mxl/] # passwd u2
Changing password for user u2.
New UNIX password:
Bad password: it is too simplistic/systematic
Retype new UNIX password:
Passwd: all authentication tokens updated successfully.
2. view the/etc/passwd and/etc/shadow files, and confirm that the two users have created
[Root @ mxl/] # cat/etc/passwd
U1: x: 502: 502:/home/u1:/bin/bash
U2: x: 503: 503:/home/u2:/bin/bash
[Root @ mxl ~] # Cat/etc/shadow
U1: $1 $ CwCsbz/P $/nod9kfmg1y1_bjljqwku0: 14040: 0: 99999: 7 :::
U2: $1 $ 5A8z1F5L $ gDvZJfpmUpc78YsUMUH4y.: 14040: 0: 99999: 7 :::
3. Check whether the u1 and u2 directories exist in the/home directory.

[Root @ mxl ~] # Ll/home
Total 4876
-Rwxr -- r -- 1 root 4971243 Nov 16 2004 fssh54b56tbyba.exe
Drwx ------ 2 u1 u1 4096 Jun 10 12:52 u1
Drwx ------ 2 u2 4096 Jun 10 u2
4. Log On As A u1 user
[Root @ mxl ~] # Su u1
[U1 @ mxl root] $

5. After logging on as a u1 user, the current directory location is displayed.
[U1 @ mxl root] $ pwd
/Root
6. Create two directories under the u1 Directory: dir1 and dir2
[U1 @ mxl ~] $ Mkdir dir1
[U1 @ mxl ~] $ Mkdir dir2
[U1 @ mxl ~] $ Ll
Total 8
Drwxrwxr-x 2 u1 u1 4096 Jun 10 13:20 dir1
Drwxrwxr-x 2 u1 u1 4096 Jun 10 13:20 dir2
7. Go to the dir1 directory and use vi to create two files named test1 and test2.
[U1 @ mxl ~] $ Cd dir1
[U1 @ mxl dir1] $ vi test1

Welcome to test1
WR save
[U1 @ mxl dir1] $ vi test2

Welcome to test2
WR
8. Use multiple methods to View File Content
[U1 @ mxl dir1] $ ll
Total 8
-Rw-r -- 1 u1 u1 17 Jun 10 13:28 test1
-Rw-r -- 1 u1 u1 17 Jun 10 13:30 test2
[U1 @ mxl dir1] $ cat test1
Welcome to test1
[U1 @ mxl dir1] $ cat test2
Welcome to test2
[U1 @ mxl dir1] $ more test2
Welcome to test2
[U1 @ mxl dir1] $ more test1
Welcome to test1
9. Go to the dir2 directory and use the touch files test3 and test4.
[U1 @ mxl ~] $ Cd dir2
[U1 @ mxl dir2] $ touch test3
[U1 @ mxl dir2] $ touch test4
[U1 @ mxl dir2] $ ll
Total 0
-Rw-r -- 1 u1 u1 0 Jun 10 13:36 test3
-Rw-r -- 1 u1 u1 0 Jun 10 13:36 test4

[U1 @ mxl dir2] $ touch test3 test4
[U1 @ mxl dir2] $ ll
Total 0
-Rw-r -- 1 u1 u1 0 Jun 10 13:36 test3
-Rw-r -- 1 u1 u1 0 Jun 10 13:36 test4
10. Copy the test1 file under the dir1 directory to/tmp and check whether the test1 file exists.
[U1 @ mxl dir2] $ cp ../dir1/test1/tmp
[U1 @ mxl dir2] $ ll/tmp/test1
-Rw-r -- 1 u1 u1 17 Jun 10 :37/tmp/test1
11. Move test2 in the dir1 directory to the dir2 directory.
[U1 @ mxl dir2] $ mv ../dir1/test2 ./
12. view the files in the dir1 directory
[U1 @ mxl dir2] $ ll ../dir1
Total 4
-Rw-r -- 1 u1 u1 17 Jun 10 test1 Directory No More test1 files under dir1

13. view the files in the dir2 directory
[U1 @ mxl dir2] $ ll
Total 4
-Rw-r -- 1 u1 u1 17 Jun 10 13:30 test2
-Rw-r -- 1 u1 u1 0 Jun 10 13:36 test3
-Rw-r -- 1 u1 u1 0 Jun 10 13:36 test4

14. Delete the dir1 directory and all files in the directory
[U1 @ mxl dir2] $ rm-rf ../dir1/test1
[U1 @ mxl dir2] $ ll ../dir1
Total 0

15. Delete the dir2 directory and all files in the directory
[U1 @ mxl ~] $ Rm-rf dir2
[U1 @ mxl ~] $ Ll
Total 4
Drwxrwxr-x 2 u1 u1 4096 Jun 10 13:49 dir1
16. Log On As root
[U1 @ mxl ~] $ Su root
Password:
[Root @ mxl u1] #
17. Use the ls-l command to display the/tmp/test1 File Permission (and explain its meaning)
[Root @ mxl/] # ll/tmp/test1
-Rw-r -- 1 u1 u1 17 Jun 10 13:37/tmp/test1
The owner has the read/write permission. The owner has the read/write permission. Other users only have the read permission.
18. Change the owner of the/tmp/test1 file to u2 with the read, write, and executable permissions. Change the owner group to u2 with the read-only permission. Other users do not have any permissions.
[Root @ mxl/] # chown u2.u2 ../tmp/test1
[Root @ mxl/] # ll ../tmp/test1
-Rw-r -- 1 u2 u2 17 Jun 10 13:37 ../tmp/test1
[Root @ mxl/] # chmod u + x, g-w, o-r ../tmp/test1 method 1
[Root @ mxl/] # ll ../tmp/test1
-Rwxr ----- 1 u2 u2 17 Jun 10 13:37 ../tmp/test1
[Root @ mxl/] # chmod u-x, g + w, o + r ../tmp/test1 cancel the set permission
[Root @ mxl/] # ll ../tmp/test1
-Rw-r -- 1 u2 u2 17 Jun 10 13:37 ../tmp/test1
[Root @ mxl/] # chmod 740 ../tmp/test1 permission setting method 2
[Root @ mxl/] # ll ../tmp/test1
-Rwxr ----- 1 u2 u2 17 Jun 10 13:37 ../tmp/test1
19. Log On As user u2 and check the/tmp/test1 file. Is the content visible?
[Root @ mxl/] # su u2
Password: 123456
[U2 @ mxl/] $ cat/tmp/test1
Welcome to test1
20. Log On As user u1 and check the/tmp/test1 file. Is the content visible?
[U2 @ mxl/] $ su u1
Password:
[U1 @ mxl/] $ cat/tmp/test1
Cat:/tmp/test1: Permission denied → the system prompts that you do not have the Permission. Haha, because the owner and group of this file are u2, you have the Permission to log in with this user, u1 has no permission. In this file, u1 is another user, while other users do not have any permissions, so they do not view the content of this file.
21. Add a new user u4 to the u2 group and Log On As user u3 to view the/tmp/test1 file. Is the content visible?
[Root @ mxl ~] # Useradd-g u2 u4
[Root @ mxl ~] # Cat/etc/passwd
U1: x: 502: 502:/home/u1:/bin/bash
U2: x: 503: 503:/home/u2:/bin/bash
U4: x: 505: 503:/home/u4:/bin/bash
[Root @ mxl etc] # su u4
[U4 @ mxl etc] $ cat/tmp/test1
Welcome to test1
22. Add an existing user u1 to the u2 group and log on again as the user u1. Check whether the content of the/tmp/test1 file is visible?

[Root @ mxl home] # chgrp u2 u1
[Root @ mxl home] # ll
Total 4880
-Rwxr -- r -- 1 root 4971243 Nov 16 2004 fssh54b56tbyba.exe
Drwx ------ 3 u1 u2 4096 Jun 10 u1
Drwx ------ 2 u2 4096 Jun 10 u2
Drwx ------ 2 u4 u2 4096 Jun 10 u4
[Root @ mxl home] # vi ../etc/passwd
U1: x: 502: 502:/home/u1:/bin/bash → change to u1: x: 502: 503:/home/u1:/bin/bash
U2: x: 503: 503:/home/u2:/bin/bash
U4: x: 505: 503:/home/u4:/bin/bash
[Root @ mxl home] # su u1
[U1 @ mxl home] $ cat ../tmp/test1
Welcome to test1
The best way is to use the gpasswd command.
23. delete user u1
[Root @ mxl/] # userdel-r u1
[Root @ mxl home] # ll check that u1 has been deleted
Total 4876
-Rwxr -- r -- 1 root 4971243 Nov 16 2004 fssh54b56tbyba.exe
Drwx ------ 2 u2 4096 Jun 10 u2 drwx ------ 2 u4 u2 4096 Jun 10 u4

24. manually delete user u4
[Root @ mxl home] # rm-rf u4
[Root @ mxl home] # ll
Total 4872
-Rwxr -- r -- 1 root 4971243 Nov 16 2004 fssh54b56tbyba.exe
Drwx ------ 2 u2 4096 Jun 10 u2
[Root @ mxl home] # vi ../etc/passwd
U2: x: 503: 503:/home/u2:/bin/bash
U4: x: 505: 503:/home/u4:/bin/bash Delete this line in the VI editor and save
The command for deleting a line is cc.
[Root @ mxl/] # vi/etc/shadow
U4 :!! : 14040: 0: 99999: 7: Same as above. Delete this line in the VI editor and save it.
The command for deleting a line is cc.
25. Add users u5 and u6 and set the password (User u5 is manually added)
[Root @ mxl/] # useradd u6
[Root @ mxl/] # passwd u6
Changing password for user u6.
New UNIX password:
Bad password: it is too simplistic/systematic
Retype new UNIX password:
Passwd: all authentication tokens updated successfully.
U5 manual Addition
[Root @ mxl/] # vi/etc/passwd
U5: x: 502: 502:/home/u5:/bin/bash
[Root @ mxl/] # vi/etc/shadow
U5 :!! : 14040: 0: 99999: 7: add this row
[Root @ mxl/] # vi/etc/group
U5: x: 502: new to this row
[Root @ mxl/] # mkdir/home/u5
[Root @ mxl/] # cp/etc/skel/. */home/u5
Cp: omitting directory '/etc/skel /.'
Cp: omitting directory '/etc/skel /..'
[Root @ mxl home] # ll
Total 4880
-Rwxr -- r -- 1 root 4971243 Nov 16 2004 fssh54b56tbyba.exe
Drwx ------ 2 u2 4096 Jun 10 u2
Drwx ------ 2 u5 u5 4096 Jun 10 16:56 u5
Drwx ------ 2 u6 u6 4096 Jun 10 15:20 u6
[Root @ mxl/] # passwd u5
Changing password for user u5.
New UNIX password:
Bad password: it is too simplistic/systematic
Retype new UNIX password:
Passwd: all authentication tokens updated successfully.
[Root @ mxl/] # su u5
[U5 @ mxl/] $ su u5
Password:
26. Log On As user u5 and use vi to create t1 in the/home/u5 directory
[U5 @ mxl ~] $ Vi t1

Welcome to t1. This is the input content.
27. Add User u6 as root to group u5
[Root @ mxl/] # gpasswd-help
Gpasswd: invalid option -- h
Usage: gpasswd [-r |-R] group
Gpasswd [-a user] group
Gpasswd [-d user] group
Gpasswd [-A user,...] [-M user,...] group
The above are some help information for commands for adding users to a group.

[Root @ mxl/] # gpasswd-a u6 u5
Adding user u6 to group u5
28. Use ll to view the file/home/u5/t1 attributes (what is the group permission ?)
[Root @ mxl/] # ll/home/u5/t1
-Rw-r -- 1 u5 u5 23 Jun 10 17:09/home/u5/t1
The owner group has the permission to read and write files.

29. Use ll to view the/home/u5 directory permissions (whether the directory has permissions for the u5 Group)
[Root @ mxl/] # ll/home
Total 4876
-Rwxr -- r -- 1 root 4971243 Nov 16 2004 fssh54b56tbyba.exe
Drwx ------ 2 u5 u5 4096 Jun 10 17:09 u5
Drwx ------ 2 u6 u6 4096 Jun 10 15:20 u6
The Group does not have any permissions on the directory.

30. Log On As user u5 and check whether the content of the/home/u5/t1 file is visible?
[U5 @ mxl home] $ cd u5
[U5 @ mxl ~] $ Ll
Total 4
-Rw-r -- 1 u5 u5 23 Jun 10 17:09 t1
[U5 @ mxl ~] $ Cat t1
Welcome to t1
31. log on to/home/u5/t1 as the root user and add a hard link:/home/u6/t1
[Root @ mxl/] # ln/home/u5/t1/home/u6/t1
[Root @ mxl/] #
[Root @ mxl/] # ll/home/u6
Total 4
-Rw-r -- 2 u5 u5 23 Jun 10 17:09 t1


32. Run the ll command to check whether/home/u5/t1 and/home/u6/t1 file attributes (hard connections, owner, and group) are the same.
[Root @ mxl/] # ll/home/u5
Total 4
-Rw-r -- 2 u5 u5 23 Jun 10 17:09 t1
[Root @ mxl/] # ll/home/u6
Total 4
-Rw-r -- 2 u5 u5 23 Jun 10 17:09 t1
Both the owner and group are u5
33. Log On As user u6 and check whether the content of the/home/u6/t1 file is visible?
[U6 @ mxl ~] $ Cat t1
Welcome to t1
34. Go to the/media/cdrom directory (create if the directory does not exist) and check whether there are any files.
[Root @ mxl media] # cd cdrom
Bash: cd: cdrom: No such file or directory
[Root @ mxl media] # mkdir cdrom
[Root @ mxl media] # ll
Total 4
Drwxr-xr-x 2 root 4096 Jun 10 17:40 cdrom

35. Mount the optical drive/dev/cdrom to the/media/cdrom directory and check whether the/media/cdrom directory contains any files.
Mount: block device/dev/cdrom is write-protected, mounting read-only
[Root @ mxl/] # ll/media/cdrom
Total 240
Drwxr-xr-x 2 root 2048 Feb 9 2007 Cluster
Drwxr-xr-x 2 root 2048 Feb 9 2007 ClusterStorage
-Rw-r -- 7 root 8446 Jan 25 2007 EULA
-Rw-r -- 7 root 18416 Dec 1 2006 GPL
-Rw-r -- 7 root 8223 Feb 8 2007 README-en
-Rw-r -- 7 root 74003 Feb 8 2007 RELEASE-NOTES-en
-Rw-r -- 7 root 1175 Feb 9 2007 RPM-GPG-KEY-redhat-auxiliary
-Rw-r -- 7 root 1706 Feb 9 2007 RPM-GPG-KEY-redhat-beta
-Rw-r -- 7 root 1990 Feb 9 2007 RPM-GPG-KEY-redhat-former
-Rw-r -- 7 root 1164 Feb 9 2007 RPM-GPG-KEY-redhat-release
Drwxr-xr-x 2 root 118784 Feb 9 2007 Server
-R -- 1 root 2928 Feb 9 2007 TRANS. TBL
Drwxr-xr-x 2 root 2048 Feb 9 2007 VT
36. Uninstall the optical drive
[Root @ mxl/] # eject
[Root @ mxl/] # ll/media/cdrom
After the total 0 files are uninstalled, check that there are no files in the optical drive.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.