1, the Replication/etc/skel directory is/home/tuser1, requires/home/tuser1 and its internal files belong to the group and other users do not have any access rights.
1.touch/etc/skel/test.txt # Create a test file in the original directory
2.cp-r/etc/skel/home/tuser1
3.ll/home/tuser1 #验证文件
4.chmod-r 700/home/tuser1
Chmod-r Go-rwx/home/tuser1
5. ll-d/home/tuser1 #验证文件夹权限
6. Ll/home/tuser1 #验证文件权限
2. Edit the/etc/group file and add the group Hadoop.
Groupadd Hadoop
3. Manually edit the/etc/passwd file to add a new line, adding user Hadoop, whose basic group ID is the Hadoop group ID number; its home directory is/home/hadoop.
1.echo "Hadoop:x:509:601::/home/hadoop:/bin/bash" >>/etc/passwd
2.CAT/ETC/PASSWD #验证
4. Copy the/etc/skel directory as/home/hadoop, which requires that the genus Group and other users of the Hadoop directory be modified without any access rights.
1. Cp/etc/skel/home/hadoop
2. chmod 700/home/hadoop
3. ll-d/home/hadoop #验证
5, modify the/home/hadoop directory and all the internal files of the owner of Hadoop, belong to Hadoop group.
1. Chown-r hadoop.hadoop/home/hadoop/
2. ll-d/home/hadoop #验证
3. Ll/home/hadoop #验证
6. Display the lines in the/proc/meminfo file beginning with uppercase or lowercase s, in two ways;
1. grep "^[ss]"/proc/meminfo
2. Sed-n '/^[ss]/p '/proc/meminfo
3. awk '/^[ss]/'/proc/meminfo
7. Display the default shell of the/etc/passwd file as a non-/sbin/nologin user;
Grep-v '/sbin/nologin$ '/etc/passwd
8. Display the user whose default shell is/bin/bash in/etc/passwd file;
grep '/bin/bash$ '/etc/passwd
9. Find out one or two digits in the/etc/passwd file;
Egrep "\<[0-9]\>|\<[0-9]{2}\>"/etc/passwd
10. Display the line beginning with at least one blank character in/boot/grub/grub.conf;
grep "^[[:space:]]\+"/boot/grub/grub.conf
Egrep "^[[:space:]]+"/boot/grub/grub.conf
11, the display/etc/rc.d/rc.sysinit file with the beginning of #, followed by at least one white space character, and then have at least one non-whitespace character line;
Egrep "^#[[:space:]]+[^[:space:]]+"/etc/rc.d/rc.sysinit
12, the Netstat-tan command execution results in the "LISTEN", followed by or with a blank character end of the line;
Netstat-tan|egrep "listen[[:space:]]+$"
13, add user bash, Testbash, basher, Nologin (this one user's shell is/sbin/nologin), and then find the current system on its user name and the default shell of the same user information;
1. For user in Bash Testbash basher nologin;do ID $user &>/dev/null | | useradd $user; Done ;
2. ID nologin && usermod-s/sbin/nologin
3. Egrep "^ ([[: alnum:]]+) \>.*\1$"/etc/passwd
Some experiences about the beginning and ending of a word, anchoring back to reference
Example: add User bash, Testbash, basher, Nologin (This is a user's shell for/sbin/nologin), and then find information about the user on the current system with the same user name and default shell
Correct statement:egrep "^ ([[: alnum:]]+)\>. *\1$"/etc/passwd
Error statement:egrep "^ ([[: alnum:]]+). *\1$"/etc/passwd
The \1 reference in the error statement can be a string of any length in the user name string, which can be n,nf,nfs........nfsnobody for nfsnobody. As a result, the user's shell can be matched as long as the n,nf,nfs...nfsnobody ends. So the statement gets the wrong result.
The correct statement adds the ending anchor \>, so \1 refers only to the entire user name Nfsnobody, because
egrep "^ ([[: alnum:]]+). *\1$" The results of/etc/passwd are as follows
Sync:x:5:0:sync:/sbin:/bin/sync
Shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
Halt:x:7:0:halt:/sbin:/sbin/halt
Nobody:x:99:99:nobody:/:/sbin/nologin
nfsnobody:x:65534:65534:anonymous NFS user:/var/lib/nfs:/sbin/nologin
Ntp:x:38:38::/etc/ntp:/sbin/nologin
Nginx:x:500:500::/home/nginx:/sbin/nologin
Hadoop:x:509:601::/home/hadoop:/bin/bash
Bash:x:510:510::/home/bash:/bin/bash
Basher:x:512:512::/home/basher:/bin/bash
Nologin:x:513:513::/home/nologin:/sbin/nologin
Note: A back reference simply refers to the string that is matched in (pattern), not the pattern itself
Linux Fourth Week job