Homework1
Course: Z6110X0002 Linux Programming
Homework1
StudentName: 邢云婷
Student ID:6103115099
Class:CS 153
要求
- Install a completely new command-line only Linux system, which shall be no graphic mode nor any graphic package.
- You can do so by completely wipe your current system (I strongly suggest), or install it in a virtual machine environment, or in a virtual container (if you know what a container is).
- The Linux distribution shall be your own freedom of choice. I suggest Fedora (for frequent users), CentOS (for juniors), Ubuntu (for beginners), or your choice.
- After you successfully installed a system, run some test program to show it works. The test programs are freedom of choices.
- After you test your programs, find a way to completely destroy your newly installed system. How to destroy your system is also the freedom of your choice.
- Last but not least, you are asked to rebuild your system once more, test it one more time, and destroy it one more time using different methods.
- After all, what you need to do is writing a report on your experience with Linux, including but not limited to, all problems you faced when you tried to install a completely cmd-based system, how you solve it, and how you destroy them, with screenshot proofs of every step you did.
- Please, please, please write me a decent report.
安装 Linux 系统
-
我的操作系统是mac os,由于实验要求必须在Linux系统下进行,而且需要破坏系统,所以我安装了VMware Fusion,然后选择了Fedora。
安装Fedora
-
安装成功,进入Linux终端
安装成功
运行测试程序
- 对CPU进行简单测试
echo "scale=5000; 4*a(1)" | bc -l -q
![](https://img.haomeiwen.com/i4017304/cf3fe17bb4b993d3.png)
- 对IO进行简单测试
利用dd进行测试:
time dd if=/dev/zero of=test bs=1M count=4096
![](https://img.haomeiwen.com/i4017304/68889ca93df4f609.png)
![](https://img.haomeiwen.com/i4017304/128ea839967d20d0.png)
![](https://img.haomeiwen.com/i4017304/c2f884dc391fde22.png)
破坏Linux操作系统
-
毁掉根目录
rm -rf /
rm 的 -r 递归删除,和 -f 强制删除是很危险的选项
![](https://img.haomeiwen.com/i4017304/aca4ebe1297e7cee.png)
![](https://img.haomeiwen.com/i4017304/099f55a6a3c19a5c.png)
![](https://img.haomeiwen.com/i4017304/901fe3d63df0b5f9.png)
-
全部硬盘清零
sudo dd if=/dev/zero of=/dev/sda
![](https://img.haomeiwen.com/i4017304/78014df8f6470d05.png)
![](https://img.haomeiwen.com/i4017304/c5405197456fa3c6.png)
-
向硬盘中写入垃圾数据
sudo dd if=something of=/dev/sda
我写入了一个original-ks.cfg 文件
![](https://img.haomeiwen.com/i4017304/4b30b7441d21bf2b.png)
运行结果:此时没有什么异常但重启后提示如下图
![](https://img.haomeiwen.com/i4017304/544d7faf96b0b962.png)
困难与收获
-
镜像文件下载错误,安装时一直摘要安装源,可是并没有安装源的网址,浪费了不少时间。经过同学的帮助找到了正确的镜像文件,安装成功。
-
在测试阶段,很多网络上的测试包的网址都是无效的,因此浪费了很多时间。
-
刚使用操作系统时,root用户和普通用户的转换和使用情况不了解。出现错误时不知道错误产生原因。通过google才对此有了清晰的认识。
错误原因--未使用root用户
-
熟悉学习了很多Linux指令
-
查看命令
ls -l 显示文件列表
ls -al -a 显示所有档案及目录 (ls内定将档案名或目录名称开头为"."的视为隐藏档,不会列出) -
删除文件和目录(删除文件或目录都可以用rm搞定)
rm 1.c //将1.c这个文件删除
rm -rf (强制删除文件或目录,删除时不提示.) -
建立文件和目录
touch 1.txt
cat > 2.txt (用定向符创建文件,填写内容后,按ctrl+d保存内容)
mkdir mywork 建立mywork这个目录 -
进入root权限
sudo - root -
dd命令备份
dd if="input_file" of="out_file" bs="block_size" count="number"
参数:
if:就是input file可以是设备
of:就是output file也可以是设备
bs:规划的一个block的大小,如果没有设定时,预设是512bytes
count:多少个bs的意思. -
查看linux系统占用的资源(top,free,uptime)
top 查看后台程序,监控系统性能
top -d 2 每两秒列新一次
top -d -2 -p3690 查看某个PID
感想
这次作业开始之前一直觉得会很难,不过整体的过程还算顺利。压力测试网上很多别人可以的方法就是不能用很崩溃,而且莫名其妙,不过还是成功了。毁掉系统成功时很爽,有点体会到了程序员控制一切的快感。学习到了很多新知识,也对Linux有了基本的了解,很有趣,希望下次能完成的更好。
网友评论