第一题

我想在/data/da 目录下面创建 一个 da.txt 文件

[root@ll ~]# cd /data/oldboyedu

-bash: cd: /data/oldboyedu: No such file or directory

1.为何出现这样的错误

因为没有这个目录

2.如何解决这个错误呢?

创建这两个目录:mkdir -p /data/da

第二题

接上题,向 da.txt 加入内容 "I love studying Linux." (不少于 2 种方法)

方法一

命令格式:echo "I love studying Linux." >> /data/da.txt

[root@ll-01 ~]# echo "I love studying Linux." >> /data/da.txt

[root@ll-01 ~]# cat /data/da.txt

I love studying Linux.

方法二

命令格式:cat >/data/da.txt <<EOF

> I love studying Linux.

> EOF

[root@ll-01 ~]# cat >/data/da.txt <<EOF

> I love studying Linux.

> EOF

[root@ll-01 ~]# cat /data/da.txt

I love studying Linux.

第三题

把/data 目录复制到 /tmp 目录下

命令格式:cp -r /data/ /tmp/

[root@ll-01 ~]# cp -r /data/ /tmp/

第四题

说说这些特殊符号含义: > >> 2> 2>> #(井号) .(点) ..(两个点)

>:标准输出重定向,先清除文件内容,再将新内容放入文件。

>>:追加输出重定向,不清除文件内容,将新内容放入文件末尾。

2>:错误输出重定向,先清除文件内容,再将命令错误的提示放入文件。

2>>:错误追加输出重定向,不清楚文件内容,将命令错误的提示追加到文件末尾。

#(号):Linux中的注释符号,

.(点):表示当前路径。

..(点点):表示上一层路径。

第五题

test.txt 内容为:

trainning

fanbingbing

lidao

请给出输出 test.txt 文件内容时,不包含 trainning 字符串的命令。

方法一

命令格式: tail -2 /test.txt

[root@ll-01 ~]# tail -2 /test.txt

fanbingbing

lidao

方法二

命令格式:sed '/trainning/d' /test.txt

[root@ll-01 ~]# sed '/trainning/d' /test.txt

fanbingbing

lidao

方法三

命令格式:grep -v " trainning " /test.txt

[root@ll-01 ~]# grep -v " trainning " /test.txt

fanbingbing

lidao

方法四

命令格式:awk '!/trainning/' test.txt

[root@ll-01 ~]# awk '!/trainning/' test.txt

fanbingbing

lidao

第六题

入职新公司,老大让你在服务器上限制 rm 命令,当用户输入 rm 命令时候提示”rm command is not allowed to use.” 请问实现的步骤是?。

第一步:

命令格式:alias rm='echo rm command is not allowed to use.'

[root@ll-01 ~]# alias rm='echo rm command is not allowed to use.'

[root@ll-01 ~]# rm test.txt

rm command is not allowed to use. test.txt

第二步:写入 /etc/profile 配置文件

[root@ll-01 ~]# echo "alias rm='echo rm command is not allowed to use.'" >> /etc/profile

第三步:生效

[root@ll-01 ~]# source /etc/profile

第七题

取出文件 ett.txt 的第 30 到 40 行的内容。

方法一

命令格式:sed -n '30,40p' /ett.txt

[root@ll-01 ~]# sed -n '30,40p' /ett.txt

30

31

32

33

34

35

36

37

38

39

40

方法二

命令格式:awk 'NR==30,NR==40' /ett.txt

[root@ll-01 ~]# awk 'NR==30,NR==40' /ett.txt

30

31

32

33

34

35

36

37

38

39

40

方法三

命令格式:head -40 /ett.txt |tail -11

[root@ll-01 ~]# head -40 /ett.txt |tail -11

30

31

32

33

34

35

36

37

38

39

40

第八题

把 test.txt 文件中的 trainning 修改为 lll.

方法一

命令格式:find /data/ -type f -name "test.txt" |xargs sed -i 's#trainning#lll#g'

[root@ll-01 ~]# find /data/ -type f -name "test.txt" |xargs sed 's#trainning#lll#g'

lll

fanbingbing

lidao

[root@ll-01 ~]# find /data/ -type f -name "test.txt" |xargs sed -i 's#trainning#lll#g'

方法二

命令格式:sed -i 's#trainning#lll#g' $(find /data/ -type f -name "test.txt")

[root@ll-01 ~]# sed  's#trainning#lll#g' $(find /data/ -type f -name "test.txt")

lll

fanbingbing

lidao

[root@ll-01 ~]# sed -i 's#trainning#lll#g' $(find /data/ -type f -name "test.txt")

方法三

命令格式:find /data/ -type f -name "test.txt" -exec sed -i 's#trainning#lll#g' {} \;

[root@ll-01 ~]# find /data/ -type f -name "test.txt" -exec sed -i 's#trainning#lll#g' {} \;

[root@ll-01 ~]# find /data/ -type f -name "test.txt" -exec sed  's#trainning#lll#g' {} \;

lll

fanbingbing

lidao

第九题

查找出/data 目录下所有以.txt 结尾的文件,并且把文件中的 trainning 修改为 lll.

命令格式:

find /data/ -type f -name "*.txt" |xargs sed -i 's#trainning#lll#g'

sed -i 's#trainning#lll#g' $(find /data/ -type f -name "*.txt")

find /data/ -type f -name "*.txt" -exec sed -i 's#trainning#lll#g' {} \;

第十题

查找/data 下所有以 log 结尾的大于 1M 的文件复制到/tmp 下。

命令格式:find /data -type f -name "*.log" -size +1M

方法1

cp $(find /data -type f -name "*.log" -size +1M ) /tmp

方法2

find /data -type f -name "*.log" -size +1M |xargs cp -t /tmp

方法3

find /data -type f -name "*.log" -size +1M |xargs -i cp {} /tmp

方法4

find /data -type f -name "*.log" -size +1M -exec cp {} /tmp \;

第十一题

什么是 linux 的运行级别,请描述 linux 的运行级别不同数字的含义?(附加题)

  1. 运行级别0-6

0表示关机

1表示单用户

2 表示多用户但是没有NFS

3 表示完整的多用户状态  命令行模式 命令模式

4 没有使用

5 图形化界面模式

6 重启

  1. 如何查看运行级别

runlevel命令

  1. 如何配置运行级别

/etc/inittab文件

  1. 临时修改init命令

init 5

第十二题

请描述 buffer 和 cache 的区别(附加题)?

buffer:缓冲区,写buffer  数据写入到内存中的缓冲区

cache:缓存区,读cache   从内存中的缓存区读取数据

day4、Linux基础题目的更多相关文章

  1. Linux 基础(5)

    Linux 基础 (五) 一.shell相关知识 shell一般代表两个层面的意思,一个是命令解释器,比如BASH,另外一个就是shell脚本.通过解释器的角度来理解shel 命令分为: ==> ...

  2. Linux基础(4)

    Linux基础(四) 通过前面的知识的学习,来现学现卖咯! 1.题目:集群搭建 1.1.部署nginx反向代理三个web服务,调度算法使用加权轮询: 1.2.所有web服务使用共享存储nfs,保证所有 ...

  3. linux 基础 文件系统 用户权限

    描述Linux系统的启动过程? 1.开机自检 BIOS 2.MBR引导 3.GRUB菜单 4.加载内核 5.运行init进程 6.从/etc/inittab读取运行级别 7.根据/etc/rc.sys ...

  4. Linux基础练习题(二)

    Linux基础练习题(二) 1.复制/etc/skel目录为/home/tuer1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限. [root@www ~]# cp -r ...

  5. 大数据每日干货第四天(linux基础之一目录结构与常用命令)

           为了和qq空间同步,也写的第四天,前面几天明天会发布,本来打算把每天学的东西记录下来,通过朋友给的建议要发的话稍微系统化下,从大数据需要的linux基础,到离线数据分析包括hadoop. ...

  6. Linux课程实践一:Linux基础实践(SSH)

    一.SSH服务 1. 安装SSH (1)查看是否已经安装过ssh服务 rpm -qa |grep ssh (2)进行安装 sudo apt-get install openssh-server Ubu ...

  7. java基础题目总结

    有些基础题目由于工作中用的比较少但却又是不可少的,这样回答起来就会反应慢,不确定,不准确,特此开了文章记录遇到的不确定或者回答比较拗口的问题. 1.servlet是单例的吗,是安全的吗,是多线程吗 s ...

  8. 还是不想改报告,伊阿忆啊哟-Linux基础继续

    hi 虽然今天是最最美好的周六(前不着工作日后不着工作日),但老子还要来改报告,但额就是不想改,你拿我有啥办法啊... 争取完结Linux基础 一.Linux常用命令(三) 4.帮助命令 4.1 帮助 ...

  9. 原来今天是感恩节-Linux基础继续&MySQL和PHP

    hi 原来今天是感恩节.虽然一直没有过这个节日的习惯,但仅仅是听到感恩的消息,都能想到一幅幅画面.愿大家安好! 下午开题会议还是有所收获,悄悄的,就变向那个不喜欢自己的人了. 一.Linux基础(二) ...

随机推荐

  1. HDU 6113 度度熊的01世界

    度度熊的01世界 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  2. Codeforces 376C. Socks

    C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  3. Cocoapods安装过程

    1.升级Ruby环境 gem -v gem update --system 如果没有权限去升级Ruby ?就输入 sudo gem update --system 2.换掉Ruby镜像 首先移除现有的 ...

  4. jQuery选择器(属性过滤选择器)第六节

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  5. Scrum Meeting Alpha - 1 (团队任务分解)

    团队任务分解 Alpha阶段项目目标 实现一个博客园班级博客的Android 客户端: 实现班级博客的常用功能(不包括投票.公告.校区) 有一个较为简洁美观.操作方便的界面 添加消息提醒功能. 任务拆 ...

  6. NoSQL:redis缓存数据库

    一 Redis介绍 Redis和Memcached类似,也属于key-value nosql 数据库 Redis官网redis.io, 当前最新稳定版4.0.1 和Memcached类似,它支持存储的 ...

  7. C#生成缩略图源码

    先看调用的方法: ).ToUpper())                {                    case "JPG":                      ...

  8. Kotlin(二) 函数定义

    1.不带参数,不返回值的函数 fun sum(){} 2.带参数,不带返回值的函数 fun sum(a:Int){} 3.带参数,带返回值的函数 fun sum(a:Int,b:Int) : Int{ ...

  9. Eclipse的几个常用快捷键

    键盘操作 功能 Alt + /    语句或变量名自动补全 Ctrl + Shift + F 语句格式化 Ctrl + / 单行注释(或取消单行注释) Ctrl + Shift + /   多行注释 ...

  10. mysql主从同步+mycat读写分离+.NET程序连接mycat代理

    背景 最近新项目需要用到mysql数据库,并且由于数据量大的原因,故打算采用1主1从(主数据库负责增.删.改操作:从数据库负责查操作)的数据库架构,在实现主从之后还要实现读写分离的代理,在网上搜寻了很 ...