设为首页 加入收藏

TOP

拓展练习 (基础部分)(四)
2019-09-02 23:06:58 】 浏览:63
Tags:拓展 练习 基础 部分
c
21.接19题,只取出重复的列
Sort file.txt|uniq -c |grep -v ‘1’

Sort file.txt|uniq -d
22.接19题,只取出不重复的列
Sort file.txt|uniq -c |grep ‘1’

Sort file.txt|uniq -u
23.已知sort.log文件内容如下,请根据文件内容的第二列进行倒序排序。

cat >>sort.log<<'EOF'

218.65.30.25 68652

218.65.30.53 34326

218.87.109.154 21201

112.85.42.103 18065

112.85.42.99 17164

218.87.109.151 17163

218.87.109.150 17163

218.65.30.61 17163

218.65.30.126 17163

218.65.30.124 17163

EOF

Sort rnk2  sort.log  (sort默认的分隔符是空格)

Sort rnk2  sort.log|column -t(排列的整齐)
24.取出系统中的文件/etc/passwd的第七列
Cut -d ‘:’ -f 7 /etc/passwd
25.统计/var/log下的文件个数,不统计下级目录。
 ll /var/log |grep ‘^-’|wc -l

Tree -L 1 、var/log|tail-1
26.统计/var/log下的所有文件和目录个数,不包含隐藏文件。
Tree /var/log |tail-1
27.以“:”为分隔符,取出/etc/passwd第一行的最后一列的内容
Head -1 /etc/passwd|cut -d ‘:’-f 7
28.将群发的access-log文件在本地解压,将解压后的文件上传到linux系统中,根据该文件进行答题取出访问的ip地址最多10个,并统计访问的次数。(提示,文件很大,不要直接打开,不然会刷屏)
cut  -d ' '  -f1  access.log |sort  |uniq  -c |sort  -rn  |head
29.执行ifconfig ens33 命令,要求只取出ip地址,如:10.0.0.98
ifconfig ens33|head -2|tail -1|cut -d ' ' -f10

ifconfig  | head -2 |tail -1| cut -c 14-23
30.执行ip a s ens33 命令,要求只取出ip地址,如:10.0.0.98
ip a s ens33|head -3|tail -1|cut -d ' ' -f6|cut -d ‘/’ -f1

ip a s ens33 | head -3 | tail -1 |cut -c 10-18
31.过滤出/etc/passwd以nologin结尾的内容,并统计行数
grep ‘nologin$’ /etc/passwd|wc -l
32.使用ifconfig命令获取当前的IP地址
Ifconfig etho|grep netmask|cut -d ‘ ’-f 10

Ifconfig etho|grep netmask|cut -c 14-23

Hostname - I
33.将/etc/sysconfig/selinux文件中的SELINUX=enforcing替换为SELINUX=disabled

将/etc/sysconfig/selinux文件中的SELINUX=enforcing替换为SELINUX=disabled

[root@oldboyedu ~]# sed -i.bak 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux 
34.分析如下日志内容,每个域名被访问次数

[root@student tmp]# cat web.log
imghttp://www.driverzeng.com/index.html
imghttp://www.driverzeng.com/1.html
imghttp://post.driverzeng.com/index.html
imghttp://mp3.driverzeng.com/index.html
imghttp://www.driverzeng.com/3.html
imghttp://post.driverzeng.com/2.html

Cut -d ‘/’ -f 3 access.log|uniq -c
35.用普通用户身份登陆虚拟机上完成练习
36..在用户家目录下创建6个文件 song1.mp3 ~ song6.mp3
Touch song{1..6}.mp3
37.把上题创建的songX.mp3文件移动到Music目录下(不存在则创建)
Madir music

Mv song{1..6}.mp3 music/    或者 mv song* music/
38.在用户家目录下创建三个目录,分别为 friends,family,work
Mkdir friends family workl
39.切换到friends目录下,把Music目录下的song1.mp3 ~ song3.mp3 拷贝到当前目录
Cd friends/

Cp ../music/song{1..3}.mp3 .
40.切换到family目录下,把Music目录下的song4.mp3 ~ song6.mp3 移动到当前目录
Cd ../family 

Mv ../music/song{4..6}.*  ./
41.切换到用户主目录
cd
42. 删除family目录
Rm -fr family/
43. 切换到friends目录,把目录下的所有文件删除
Rm -f ./*
44.切换到主目录,把friends目录删除
cd

Rm -fr friends/

第五部分

Linux文件管理---文件软硬链接&VIM编辑

1.文件在Linux上被分成两个部分,分别为什么?且每个对应的存储的是什么?
用户数据:文件数据块(data block),数据块是记录文件真实内容的地方,称为block

元数据:文件的附加属性,例如文件大小,创建时间,属组,属主等,称为inode
2.Linux系统有两种链接文件,分别为?
软链接

硬链接
3.什么是软链接?
相当于windows的快捷方式,软链接文件会将incode指向源文件的block

当我们访问这个软连接文件时,其实就是在访问源文件的本身
4.什么是硬链接?
若一个inode号对应多个文件名,则称这些文件为硬链接。换句话说,硬链接就是同一个文件使用了多个别名
5.已知文件/root/oldboy/oldboy.txt,请给其创建一个软连接为/root/oldboy.txt
Ln -s /root/oldboy/oldboy.txt  /root/oldboy.txt
6.给其文件/root/oldboy/oldboy.txt,请给其创建一个硬连接为/opt/oldboy.txt
Ln /root/oldboy/oldboy.txt  /opt/oldboy.txt
7.已知目录/root/oldboy/data,请给其创建一个软连接为/root/data
Ln -s /root/oldboy/data  /root/data
8.给其目录/root/oldboy/data,请给其创建一个硬连接为/opt/data
Ln /root/oldboy/data  /o
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇操作系统:进程的概念和与程序的.. 下一篇新手小白Linux(Centos6.5)部署j..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目