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. 进销存管理系统, 刚学C++

    各位大神们.有什么补充的能够评论一下吗? #include<iostream> #include<string> using namespace std; int G=0;// ...

  2. s:actionmessage页面样式失效

    1,  s:actionmessage页面样式失效: 2,解决方式: 将样式直接写入s:actionmessage标签中:<span><s:actionmessage cssSt ...

  3. caffe代码阅读10:Caffe中卷积的实现细节(涉及到BaseConvolutionLayer、ConvolutionLayer、im2col等)-2016.4.3

    一. 卷积层的作用简单介绍 卷积层是深度神经网络中的一个重要的层,该层实现了局部感受野.通过这样的局部感受野,能够有效地减少參数的数目. 我们将结合caffe来解说详细是怎样实现卷积层的前传和反传的. ...

  4. oc85--利用宏定义简化单例

    //Singleton.h // 以后就可以使用interfaceSingleton来替代后面的方法声明. \表示下一行也是上一行的内容. #define interfaceSingleton(nam ...

  5. 局部覆盖element-ui的默认样式

    最近项目中遇到的问题,只想在某个页面里面单独更改element-ui的样式,而不影响全局 有两种方法: 1.在需要更改的组件里新增一个style标签[重点:不要加scoped],然后直接获取class ...

  6. BZOJ 3514 LCT+主席树

    思路: //By SiriusRen #include <bits/stdc++.h> using namespace std; ; ],fa[N],minn[N],rev[N],q[N] ...

  7. scala的枚举

    package com.test.scala.test /** * 枚举 */ object Enum extends Enumeration { val Red,Yellow,Green=Value ...

  8. ASP.NET 之正则表达式

    转载自:http://www.regexlib.com/cheatsheet.htm?AspxAutoDetectCookieSupport=1 Metacharacters Defined MCha ...

  9. Boost Bimap示例

    #include <string> #include <iostream> #include <boost/bimap.hpp> template< clas ...

  10. python框架之Flask基础篇(四)-------- 其他操作

    1.蓝图 要用蓝图管理项目,需要导入的包是:from flask import Buleprint 具体大致分为三步: 1.先在子模块中导入蓝图包,然后再创建蓝图对象. 2.然后将子模块中的视图函数存 ...