1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。

cp -r /etc/skell /home/tuser1 ; chmod -R 700 /home/tuser

2、编辑/etc/group文件,添加组hadoop。

echo 'hadoop:x:10004:Allen' >> /etc/group

3、手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号;其家目录为/home/hadoop。

echo 'hadoop:x:10004:10004::/home/hadoop:/bin/bash' >> /etc/passwd
echo "hadoop:*:16231:0:99999:7:::" >> /etc/shadow

4、复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其它用户没有任何访问权限。

cp -r /etc/skel /home/hadoop ; chmod 700 /home/hadoop

5、修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop。

chown hadop: /home/hadoop

6、显示/proc/meminfo文件中以大写或小写S开头的行;用两种方式;

grep -i “^s” /proc/meminfo
grep "^[Ss]" /proc/meminfo
egrep "^(s|S)" /proc/meminfo
awk '/^[Ss]/' /proc/meminfo
sed -n '/^[Ss]/p' /proc/meminfo

7、显示/etc/passwd文件中其默认shell为非/sbin/nologin的用户;

grep -v "/sbin/nologin$" /etc/passwd | cut -d":" -f1

8、显示/etc/passwd文件中其默认shell为/bin/bash的用户;

grep "/sbin/bash$" /etc/passwd | cut -d":" -f1

9、找出/etc/passwd文件中的一位数或两位数;

egrep "\<([0-9]|[1-9][0-9])\>" /etc/passwd
grep “/<[0-9]/{1,2/}/>” /etc/passwd

10、显示/etc/init.d/functions中以至少一个空白字符开头的行;

egrep "^ {1,}" /etc/init.d/functions
egrep "^ +" /etc/init.d/functions
grep -E '^\s' /etc/init.d/functions

11、显示/etc/services文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;

egrep "^#[[:space:]]+[^[:space:]]{1,}" /etc/services
egrep "^#[[:space:]]+[^[:space:]]+" /etc/services
grep -E "^#[[:space:]]+\S+" /etc/services

12、打出netstat -tan命令执行结果中以‘LISTEN’,后或跟空白字符结尾的行;

netstat -tan | egrep "LISTEN[[:space:]]{0,}$"

13、添加用户bash, testbash, basher, nologin (此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户的信息;

for user in bash testbash basher nologin;do useradd $user;done && chsh -s /sbin/nologin nologin && grep "^\([[:alnum:]]\+\>\).*\1$" /etc/passwd

随机推荐

  1. unable to execute dex: multiple dex files Cocos2dxAccelerometer

    原文转载:http://discuss.cocos2d-x.org/t/conversion-to-dalvik-format-failed-unable-to-execute-dex-multipl ...

  2. LeetCode241——Different Ways to Add Parentheses

    Given a string of numbers and operators, return all possible results from computing all the differen ...

  3. [NOIP2003普及组]麦森数(快速幂+高精度)

    [NOIP2003普及组]麦森数(快速幂+高精度) Description 形如2^P-1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果P是个素数,2^P-1不一定也是素数.到1998 ...

  4. bzoj 3944 Sum —— 杜教筛

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3944 杜教筛入门题! 看博客:https://www.cnblogs.com/zjp-sha ...

  5. bzoj1023 [SHOI2008]cactus仙人掌图 & poj3567 Cactus Reloaded——求仙人掌直径

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1023    http://poj.org/problem?id=3567 仙人掌!直接模仿 ...

  6. perl数组的长度与元素个数

    perl数组的长度与元素个数 $#数组名 ---表示数组中最后一个元素的下标,它等于元素个数减1. @数组名 ---表示数组中元素的个数. $标量=@数组名 ---将一个数组赋值给一个标量变量,标量得 ...

  7. window.onload的使用

    window.onload:当页面加载的时候可以调用某些函数 例如: 1.最简单的调用方式 直接写到html的body标签里面,如: <html> <body onload=&quo ...

  8. HTML--form表单中的label标签

    小伙伴们,你们在前面学习表单各种控件的时候,有没有发现一个标签--label,这一小节就来揭晓它的作用. label标签不会向用户呈现任何特殊效果,它的作用是为鼠标用户改进了可用性.如果你在 labe ...

  9. query.setFirstResult(0),query.setMaxResults(4)

    query.setFirstResult(0),query.setMaxResults(1);相当于MySQL中的limit 0, 1; String hql = "FROM Forum f ...

  10. BZOJ 2001 线段树+LCT (TLE)

    同是O(nlog^2n)怎么常数差距就这么大呢,,, 同是LCT  怎么我的和Po姐姐的常数差距就这么大呢 我绝对是脑子被驴踢了才写这个垃圾算法 //By SiriusRen #include < ...