The Forth Week
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
随机推荐
- 第一章 Java Collections Framework总览
1.Java容器 Java容器中只能存放对象,对于基本数据类型(byte,short,char,int,long,float,double,boolean),需要包装成对象类型(Byte,Short, ...
- 阿里大数据比赛sesson2_RF&GBRT(下)
-----------__-----------接上文---------__---------- 2.Xlab RF上手 2.1.训练特征表准备 训练的特征表gbrt_offline_section_ ...
- jQuery Uploadify在ASP.NET MVC3中的使用
1.Uploadify简介 Uploadify是基于jQuery的一种上传插件,支持多文件.带进度条显示上传,在项目开发中常被使用. Uploadify官方网址:http://www.uploadif ...
- 重装mysql
重装mysql方法. 转自http://blog.sina.com.cn/s/blog_73000beb01012eh4.html 1.删除 mysql 1.1 sudo apt-get autore ...
- codeforces 949B A Leapfrog in the Array
B. A Leapfrog in the Array time limit per test 2 seconds memory limit per test 512 megabytes input s ...
- P2597 [ZJOI2012]灾难 拓扑排序
这个题有点意思,正常写法肯定会T,然后需要优化.先用拓扑排序重构一遍树,然后进行一个非常神奇的操作:把每个点放在他的食物的lca上,然后计算的时候直接dfs全加上就行了.为什么呢,因为假如你的食物的l ...
- shell脚本-高级变量
shell脚本-高级变量 字符串变量切片 ${#var}: 返回字符串变量var的长度 ${var:offset}: 返回字符串变量var中从第offset个字符后(不包括第offset 个字符)的字 ...
- Vue使用html2canvas将页面转化为图片
需求是微信端将页面截屏之后保存到本地,使用了html2canvas插件 先引入插件 npm install --save html2canvas 之后在你所需要使用的页面引入 import html2 ...
- url参数为数组
//url中state参数为数组 ?baseline_id=12&version_id=34&state[]=complete&state[]=hangup&state ...
- Android 从服务器获取时间戳转换为年月日
用JAVA相关类转换.代码如下: Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(NumberUtils.ge ...