1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。
[root@localhost ~]# cp -r /etc/skel/ /home/tuser1 [root@localhost ~]# chmod -R go-rwx /home/tuser1/ [root@localhost ~]# ls -al /home/ | grep tuser1 drwx------. 3 root root 87 Jul 1 09:17 tuser1 [root@localhost ~]# ls -al /home/tuser1/ total 20 drwx------. 3 root root 87 Jul 1 09:17 . drwxr-xr-x. 17 root root 4096 Jul 1 09:17 .. -rw-------. 1 root root 18 Jul 1 09:17 .bash_logout -rw-------. 1 root root 193 Jul 1 09:17 .bash_profile -rw-------. 1 root root 231 Jul 1 09:17 .bashrc -rw-------. 1 root root 334 Jul 1 09:17 .emacs drwx------. 4 root root 37 Jul 1 09:17 .mozilla
2、编辑/etc/group文件,添加组hadoop。
[root@localhost ~]# echo "hadoop:x:1122:" >> /etc/group [root@localhost ~]# cat /etc/group | tail -1 hadoop:x:1122:
3、手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号;其家目录为/home/hadoop。
[root@localhost ~]# vi /etc/passwd "G"跳转到末行 "o"在下一行输入 hadoop:x:1122:1122::home/hadoop:/sbin/nologin
4、复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其它用户没有任何访问权限。
[root@localhost ~]# cp -r /etc/skel/ /home/hadoop/ [root@localhost ~]# chmod go-rwx /home/hadoop/ [root@localhost ~]# ls -al /home | grep hadoop drwx------. 3 root root 87 Jul 1 09:39 hadoop [root@localhost ~]# ls -al /home/hadoop/ total 20 drwx------. 3 root root 87 Jul 1 09:39 . drwxr-xr-x. 18 root root 4096 Jul 1 09:39 .. -rw-r--r--. 1 root root 18 Jul 1 09:39 .bash_logout -rw-r--r--. 1 root root 193 Jul 1 09:39 .bash_profile -rw-r--r--. 1 root root 231 Jul 1 09:39 .bashrc -rw-r--r--. 1 root root 334 Jul 1 09:39 .emacs drwxr-xr-x. 4 root root 37 Jul 1 09:39 .mozilla
5、修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop。
[root@localhost ~]# chown -R hadoop.hadoop /home/hadoop/ [root@localhost ~]# ls -al /home drwx------. 3 hadoop hadoop 87 Jul 1 09:39 hadoop [root@localhost ~]# ls -al /home/hadoop/ total 20 drwx------. 3 hadoop hadoop 87 Jul 1 09:39 . drwxr-xr-x. 18 root root 4096 Jul 1 09:39 .. -rw-r--r--. 1 hadoop hadoop 18 Jul 1 09:39 .bash_logout -rw-r--r--. 1 hadoop hadoop 193 Jul 1 09:39 .bash_profile -rw-r--r--. 1 hadoop hadoop 231 Jul 1 09:39 .bashrc -rw-r--r--. 1 hadoop hadoop 334 Jul 1 09:39 .emacs drwxr-xr-x. 4 hadoop hadoop 37 Jul 1 09:39 .mozilla
6、显示/proc/meminfo文件中以大写或小写S开头的行;用两种方式;
grep -i "^s.*" /proc/meminfo grep '[Ss].*' /proc/meminfo
7、显示/etc/passwd文件中其默认shell为非/sbin/nologin的用户;
[root@localhost ~]# egrep -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 amandabackup:x:33:6:Amanda user:/var/lib/amanda:/bin/bash tomcat:x:91:91:Apache Tomcat:/usr/share/tomcat:/bin/nologin postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash jobs:x:1000:1000:Jobs:/home/jobs:/bin/bash tom:x:1001:1001::/home/tom:/bin/bash jerry:x:65533:1002::/home/jerry:/bin/bash bash:x:1002:1003::/home/bash:/bin/bash basher:x:1003:1004::/home/basher:/bin/bash testbash:x:1004:1005::/home/testbash:/bin/bash user1:x:1006:1007::/home/user1:/bin/bash mageia:x:1100:1100::/home/linux/:/bin/bash slackware:x:2002:2016::/home/slackware:tcsh openstack:x:3003:3003::/home/openstack:/bin/bash
8、显示/etc/passwd文件中其默认shell为/bin/bash的用户;
[root@localhost ~]# egrep ".*(/bin/bash)" /etc/passwd root:x:0:0:root:/root:/bin/bash amandabackup:x:33:6:Amanda user:/var/lib/amanda:/bin/bash postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash jobs:x:1000:1000:Jobs:/home/jobs:/bin/bash tom:x:1001:1001::/home/tom:/bin/bash jerry:x:65533:1002::/home/jerry:/bin/bash bash:x:1002:1003::/home/bash:/bin/bash basher:x:1003:1004::/home/basher:/bin/bash testbash:x:1004:1005::/home/testbash:/bin/bash user1:x:1006:1007::/home/user1:/bin/bash mageia:x:1100:1100::/home/linux/:/bin/bash openstack:x:3003:3003::/home/openstack:/bin/bash
9、找出/etc/passwd文件中的一位数或两位数;
[root@localhost ~]# egrep -o "(\<[[:digit:]]{1,2}\>)" /etc/passwd
10、显示/boot/grub/grub.conf中以至少一个空白字符开头的行;
[root@localhost ~]# egrep "^[[:space:]]\+" /boot/grub/grub.conf
11、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;
[root@localhost ~]# grep "^#[[:space:]]\+[^[:space:]]" /etc/rc.d/rc.sysinit
12、打出netstat -tan命令执行结果中以‘LISTEN’,后或跟空白字符结尾的行;
[root@localhost ~]# netstat -tan | grep "LISTEN[[:space:]]*$"
13、添加用户bash, testbash, basher, nologin (此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户的信息;
useradd bash useradd testbash useradd basher useradd -s /sbin/nologin nologin [root@localhost ~]# 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:1002:1003::/home/bash:/bin/bash nologin:x:1005:1006::/home/nologin:/sbin/nologin
原创文章,作者:Anaconda,如若转载,请注明出处:http://www.178linux.com/21225
评论列表(1条)
写的很好,排版可以在漂亮一点,加油