1.1 请详细描述 linux 系统从打开主机电源到进入登录界面整个过程的流程.
BIOS 开机自检
mbr 引导
grub 菜单
加载内核
运行 init 进程
读取 / etc/inittab 配置文件
执行 / etc/rc.d/rc.sysinit 进程
执行 / etc/re.d/rc 进程
进入登录界面
1.2 我想在 / data/oldboyedu 目录下面创建 一个 oldboy.txt 文件
- [root@oldboyedu ~]# cd /data/oldboyedu
- -bash: cd: /data/oldboyedu: No such file or directory
1. 为何出现这样的错误
这个目录不存在
2. 如何解决这个错误呢?
创建目录
mkdir -p /data/oldboyedu
1.3 接上题, 向 oldboy.txt 加入内容 "I love studying Linux." (不少于 2 种方法)
方法 1
cat>>oldboyedu/oldboy.txt<<eof
I love studying Linux.
eof
方法 2
echo 'I love studying Linux.'>/data/oldboyedu/oldboy.txt
a)说说这些特殊符号含义: \ > >> 2> 2>> #(井号) .(点) ..(两个点) ~ * $ |
\ 转义字符 撬棍 脱掉马甲打回原形(或类似含义)
> 重定向符号 先清空文件内容, 然后追加内容(或类似含义)
>> 追加重定向 追加到文件结尾(或类似含义)
2> 错误输出重定向
2>> 错误输出追加重定向
# 井号 注释或 root 用户命令提示符或 sed 分隔符(sed 's###g')
. 当前目录 或 正则任何一个字符 或 用于生效
.. 当前目录的上级目录
~ 当前用户家目录
* 所有字符或任意字符或正则表达式表示前一个字符连续出现 0 次或 0 次以上
$ 取变量内容 或 正则以... 结尾
| 管道 或 正则表示或者
b)test.txt 内容为:
- trainning
- fanbingbing
- lidao
1.4 请给出输出 test.txt 文件内容时, 不包含 trainning 字符串的命令.
方法 1
grep -v 'trainning' test.txt #不加引号也行
方法 2
tail -2 test.txt
方法 3
sed '/trainning/d' test.txt
方法 4
awk '!/trainning/' test.txt
1.5 入职新公司, 老大让你在服务器上限制 rm 命令, 当用户输入 rm 命令时候提示 "rm command is not allowed to use." 请问实现的步骤是?.
1)命令行测试
alias rm='echo command is not allowd to use'
2)永久生效
写入 / etc/profile
3)生效
source /etc/profile
1.6 取出文件 ett.txt 的第 30 到 40 行的内容.
注: ett.txt 由 seq 20 120>ett.txt 创建
方法 1
sed -n '30,40p' ett.txt
方法 2
awk 'NR==30,NR==40' ett.txt
方法 3
head -40 ett.txt|tail -11
方法 4
awk 'NR>=30&&NR<=40' ett.txt
1.7 通过修改文件( /etc/fstab 或 fstab ), 可以设定开机时自动挂载文件系统.
1.8 在 linux 系统中, 当 LAN(局域网)内没有条件记案例 DNS
- ls /var/log|wc -l
- find /var/log|wc -l
- tar zcf /tmp/oldboy.tar.gz `find /data -type d -name "oldboy"`
- tar zcf /tmp/oldboy.tar.gz $(find /data -type d -name "oldboy")
- ss -lntup |grep 22
- netstat -lntup|grep 22
- lsof -i:22
- ps -ef |grep 22# 这是错误的
- cp ` find /data -type f -mtime +7 -size +100k ` /tmp
- cp $( find /data -type f -mtime +7 -size +100k ) /tmp
- gg
- 1G
- :1
- G
- :$
- 100gg
- 100G
- :100
- 0(数字 0)
- ^
- u
- undo
- :help G
- :help :wq
- :h G
- nu===number
- egrep -n "3306\|1521" /etc/services
- grep -E "3306|1521" /etc/services
- oldboy
- xizi
- xiaochao
- egrep -v "^$" /oldboy/test.txt
- 1.41 No such file or directory
来源: http://www.bubuko.com/infodetail-2712783.html