Linux命令练习二
Posted 山河执手
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux命令练习二相关的知识,希望对你有一定的参考价值。
Linux命令练习二
练习二:
(注意:我没截图的题不要在阿里云或腾讯云上尝试,防止系统异常)
1.通过init 来切换不同的运行级别,比如动 5-3 , 然后关机
init 5 init 3 init 0
2.假设我们的root密码忘记了,请问如何找回密码
开机引导界面输入回车—输入e ----新界面里选中第二行(编辑内核)----再输入e----在最后的字符后输入空格 1回车----进入单用户模式----passwd root
3. 请设置我们的运行级别,linux 运行后,直接进入到命令行终端(3)
可编辑 /etc/inittab 文件,设置为id:3:initdefault:
4. 使用绝对路径切换到root目录
cd /root 或者 cd ~
5 .使用相对路径到/root 目录
cd root/
6. 表示回到当前目录的上一级目录
cd …/
7. 回到家目录
cd /home
8. 创建一个目录 /home/dog
mkdir /home/dog
9. 创建多级目录 /home/animal/tiger
mkdir -p /home/animal/tiger
10. 删除一个目录 /home/dog
rmdir /home/dog
11. 创建一个空文件 hello.txt
touch hello.txt
12. 将 /home/aaa.txt 拷贝到 /home/bbb 目录下
cp /home/aaa.txt /home/bbb/
13. 将 /home/aaa.txt 删除
rm /home/aaa.txt
14. 递归删除整个文件夹 /home/bbb
rm -rf /home/bbb
15. 将 /home/aaa.txt 文件重新命名为 pig.txt
mv /home/aaa.txt /home/pig.txt
16. 将 /home/pig.txt 文件移动到 /root 目录下
mv /home/pig.txt /root/
17. /ect/profile 文并显示行号
cat -n /etc/profile
18. 采用more和less查看文件/etc/profile
more /etc/profile
less /etc/profile
19. 查看/etc/profile 的前面5行代码
head -n 5 /etc/profile
20. 查看/etc/profile 最后5行的代码
tail -n 5 /etc/profile
21.实时监控 hello.txt是否追加内容
cat -n /etc/profile cat /etc/profile >/home/hello.txt
以上是关于Linux命令练习二的主要内容,如果未能解决你的问题,请参考以下文章