1、复制/etc/skel目录到/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。
[root@EASTED tmp]# cp -r /etc/skel/ /home/tuser1/ [root@EASTED tmp]# cp -r /etc/skel/ /home/tuser1/ [root@EASTED tmp]# ls -al /home/tuser1/ 总用量 4 drwx------. 3 root root 17 1月 2 21:31 . drwxr-xr-x. 10 root root 4096 1月 2 21:29 .. drwx------. 3 root root 74 1月 2 21:31 skel
2、编辑/etc/group文件,添加组hadoop
hadoop:x:1004: :wq
或
[root@EASTED tmp]# echo "hadoop:x:1004:" >> /etc/group [root@EASTED tmp]# cat /etc/group hadoop:x:1004:
3、手动编辑/etc/passwd文件新增一行,添加用户hadoop,基本组的id号;其家目录为/home/hadoop
[root@EASTED tmp]# vi /etc/passwd hadoop:x:1004:1004::/home/hadoop:/bin/bash -- INSERT --
4、复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其它用户没有任何访问权限。
[root@EASTED tmp]# cp -r /etc/skel/ /home/hadoop [root@EASTED tmp]# chmod 700 /home/hadoop/ [root@EASTED tmp]# ls -al /home/hadoop/ 总用量 16 drwx------. 3 root root 74 1月 2 21:59 . drwxr-xr-x. 11 root root 4096 1月 2 21:59 .. -rw-r--r--. 1 root root 18 1月 2 21:59 .bash_logout -rw-r--r--. 1 root root 193 1月 2 21:59 .bash_profile -rw-r--r--. 1 root root 231 1月 2 21:59 .bashrc drwxr-xr-x. 4 root root 37 1月 2 21:59 .mozilla [root@EASTED tmp]#
5、修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop
[root@EASTED tmp]# chown -R hadoop:hadoop /home/hadoop/ [root@EASTED tmp]# ls -al /home/hadoop/ 总用量 16 drwx------. 3 hadoop hadoop 74 1月 2 21:59 . drwxr-xr-x. 11 root root 4096 1月 2 21:59 .. -rw-r--r--. 1 hadoop hadoop 18 1月 2 21:59 .bash_logout -rw-r--r--. 1 hadoop hadoop 193 1月 2 21:59 .bash_profile -rw-r--r--. 1 hadoop hadoop 231 1月 2 21:59 .bashrc drwxr-xr-x. 4 hadoop hadoop 37 1月 2 21:59 .mozilla
6、显示/proc/meminfo文件中以大写或小写开头的行;用两种方式;
[root@EASTED tmp]# grep ^[sS] /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 9788 kB Slab: 116176 kB SReclaimable: 58352 kB SUnreclaim: 57824 kB [root@EASTED tmp]# grep -i ^s /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 9788 kB Slab: 116188 kB SReclaimable: 58360 kB SUnreclaim: 57828 kB
7、显示/etc/passwd文件中其默认shell为非/sbin/nologin的用户;
[root@EASTED tmp]# grep -v "/sbin/nologin$" /etc/passwd root:x:0:0:root:/root:/bin/bash sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt lyf:x:1000:1000:LYF:/home/lyf:/bin/bash LiangYF:x:1001:1001::/home/LiangYF:/bin/bash slackware:x:1002:1002::/home/slackware:/bin/tcsh houyuan:x:1003:1003::/home/houyuan:/bin/bash hadoop:x:1004:1004::/home/hadoop:/bin/bash
8、显示/etc/passwd文件中其默认shell 为/bin/bash的用户
[root@EASTED tmp]# grep "/bin/bash$" /etc/passwd root:x:0:0:root:/root:/bin/bash lyf:x:1000:1000:LYF:/home/lyf:/bin/bash LiangYF:x:1001:1001::/home/LiangYF:/bin/bash houyuan:x:1003:1003::/home/houyuan:/bin/bash hadoop:x:1004:1004::/home/hadoop:/bin/bash
9、找出/etc/passwd文件中的一位或者两位数;
[root@EASTED tmp]# grep "\<[0-9]\{1,2\}\>" /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin saslauth:x:993:76:Saslauthd user:/run/saslauthd:/sbin/nologin rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin radvd:x:75:75:radvd user:/:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin gdm:x:42:42::/var/lib/gdm:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin
10、显示/boot/grub/grub.conf中以至少一个空白字符开头的行;
[root@EASTED grub]# grep " ^[[:space:]]+" /boot/grub/grub.conf
11、显示/etc/rc.d/sysinit 文件中以#开头,后面跟至少一个空白字符,而后又至少一个非空白字符的行;
[root@EASTED grub]# grep "^#[[:space:]]+[^[:space:]]" /etc/rc.d/rc.sysinit
12、打出netstat -tan命令执行结果中以'LISTEN',后面跟空白字符结尾的行;
[root@EASTED grub]# netstat -tan | grep "LISTEN[[:space:]]*$" tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 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 tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN
13、添加用户bash,testbash,basher,nologin(此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名默认shell 相同的用户信息;
[root@EASTED ~]# grep "^\([[:alnum:]]\+[^:]\>\).*\1$" /etc/passwd sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt bash:x:1006:1006::/home/bash:/bin/bash nologin:x:1012:1012::/home/nologin:/sbin/nologin
14、显示/proc/meminfo文件中以大写或者小写s开头的行;用三种方式;
[root@EASTED tmp]# grep ^[sS] /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 9788 kB Slab: 116176 kB SReclaimable: 58352 kB SUnreclaim: 57824 kB [root@EASTED tmp]# grep -i ^s /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 9788 kB Slab: 116188 kB SReclaimable: 58360 kB SUnreclaim: 57828 kB [root@EASTED ~]# grep -E "^(s|S)" /proc/meminfo SwapCached: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Shmem: 9788 kB Slab: 116384 kB SReclaimable: 58500 kB SUnreclaim: 57884 kB
原创文章,作者:LYF,如若转载,请注明出处:http://www.178linux.com/65610