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.
[[email protected] ~]# cp-a/etc/skel//home/tuser1[[email protected] ~]# chmod-r 700/home/tuser1/[[email protected] ~] # ll-d! $ll-D/home/tuser1/drwx------3 root root 4096 2015-03-27/home/tuser1/
2. Edit the/etc/group file and add the group Hadoop.
[Email protected] ~]# echo "hadoop:x:3000" >>/etc/group[[email protected] ~]# tail-1! $tail-1/etc/grouphadoop:x : 3000
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.
[[email protected] ~]# echo hadoop:x:3000:3000:hadoop:/home/hadoop:/bin/bash >>/etc/passwd[[email protected] ~] # TAIL-1! $tail-1/etc/passwdhadoop:x:3000:3000:hadoop:/home/hadoop:/bin/bash
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.
[[email protected] ~]# cp-a/etc/skel//home/hadoop[[email protected] ~]# chmod 700-r/home/hadoop/
5, modify the/home/hadoop directory and all the internal files of the owner of Hadoop, belong to Hadoop group.
[Email protected] ~]# chown-r hadoop:hadoop/home/hadoop/[[email protected] ~]# ll-d! $ll-D/home/hadoop/drwx------. 3 Hadoop Hadoop 87 June 10:34/home/hadoop/
6. Display the lines in the/proc/meminfo file beginning with uppercase or lowercase s, in two ways;
[[email protected] ~]# grep -i ^s /proc/meminfo swapcached: 0 kBSwapTotal: 4194300 kbswapfree: 4194300 kbshmem: 34752 kBSlab: 253416 kBSReclaimable: 176732 kbsunreclaim: 76684 kb[[ email protected] ~]# grep ^[ss] /proc/meminfo swapcached: 0 kBSwapTotal: 4194300 kBSwapFree: 4194300 kBShmem: 34752 kBSlab: 253408 kBSReclaimable: 176724 kBSUnreclaim: 76684 kb
7. Display the default shell of the/etc/passwd file as a non-/sbin/nologin user;
[Email protected] ~]# grep-v/sbin/nologin$/etc/passwd | Cut-d:-f1rootsyncshutdownhaltshhadoop
8. Display the user whose default shell is/bin/bash in/etc/passwd file;
[Email protected] ~]# grep/bin/bash$/etc/passwd | cut-d:-f1 Rootshhadoop
9. Find out one or two digits in the/etc/passwd file;
[[email protected] ~]# grep-o ' [0-9]\{1,2\} '/etc/passwd
10. Display the line beginning with at least one blank character in/boot/grub/grub.conf;
[[email protected] ~]# grep ' ^[[:space:]]\+ '/boot/grub/grub.conf root (hd0,0) Kernel/vmlinuz-2.6.18-128.el 5 ro root=label=/rhgb quiet initrd/initrd-2.6.18-128.el5.img
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;
[[email protected] ~]# grep ' ^#[[:space:]]\+[^[:space:]]\+ '/etc/rc.d/rc.sysinit
[[email protected] ~]# netstat -tan | grep ' LISTEN[[:space:]]* ' tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:845 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* listen tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN tcp 0 0 :::22 :::* listen
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;
[[email protected] ~]# useradd bash[[email protected] ~]# useradd testbash[[email protected] ~]# useradd Basher[[email Pro Tected] ~]# useradd-s/sbin/nologin nologin[[email protected] ~]# grep ' ^\ ([[: alnum:]]\+\>\). *\1$ '/etc/passwd sync:x : 5:0:sync:/sbin:/bin/syncshutdown:x:6:0:shutdown:/sbin:/sbin/shutdownhalt:x:7:0:halt:/sbin:/sbin/haltbash:x : 501:501::/home/bash:/bin/bashnologin:x:504:504::/home/nologin:/sbin/nologin
14. Display the lines in the/proc/meminfo file beginning with uppercase or lowercase s; in three different ways;
[[email protected] ~]# grep -i ^s /proc/meminfo swapcached: 0 kBSwapTotal: 4096564 kbswapfree: 4096564 kbslab: 72724 kb[[email protected] ~]# grep ^[ss] /proc/ meminfo swapcached: 0 kBSwapTotal: 4096564 kBSwapFree: 4096564 kBSlab: 72732 kb[[email protected] ~]# sed -n '/^[ss]/p ' /proc/meminfo SwapCached: 0 kbswaptotal: 4096564 kbswapfree: 4096564 kbslab: 72736 kb
15. Display the default shell of the/etc/passwd file as a non-/sbin/nologin user;
[Email protected] ~]# grep-v/sbin/nologin$/etc/passwd | Cut-d:-f1rootsyncshutdownhaltnewssihuabashtestbashbasher
16. Display the user whose default shell is/bin/bash in/etc/passwd file;
[Email protected] ~]# grep/bin/bash$/etc/passwd | Cut-d:-f1rootsihuabashtestbashbasher
17. Find out one or two digits in the/etc/passwd file;
[[email protected] ~]# grep-o ' [0-9]\{1,2\} '/etc/passwd
This article is from the "Chase Dream" blog, please be sure to keep this source http://387227.blog.51cto.com/377227/1811659
Linux Fourth week