测试
作者:互联网
目录
- HW 1
- 1.Create a new directory called missing under /tmp;
- 2.Look up the touch program. The man program is your friend.
- 3.Use touch to create a new file called semester in missing.
- 4.Write the following into that file, one line at a time:
- 5.Try to execute the file. Understand why it doesn’t work.
- 6.Run the command by explicitly starting the sh interpreter.
- 7.Look up the chmod program
- 8.Use chmod to make it possible to run the command ./semester.
- 9.Use | and > to write the “last modified”date output by semester into a file called last-modified.txt in your home directory.
HW 1
1.Create a new directory called missing under /tmp;
mkdir /tmp/missing
检验:
2.Look up the touch program. The man program is your friend.
man touch
结果:
3.Use touch to create a new file called semester in missing.
touch /tmp/missing/semester
4.Write the following into that file, one line at a time:
echo '#!/bin/sh' > /tmp/missing/semester
echo 'curl --head --silent https://github.com/siyuanluo' >> /tmp/missing/semester
单引号字符串非转义
检验:
vim /tmp/missing/semester
5.Try to execute the file. Understand why it doesn’t work.
./semester
ls -l
结果:
users的权限是-rw, 第一组, 没有执行权限x
6.Run the command by explicitly starting the sh interpreter.
sh semester
结果:
解释: OS会通过sh
命令的调用直接产生一个新的Shell进程,并将semester
当作命令行参数传进去。新的Shell进程就会读取、解释并执行该脚本,而OS不关心该文件到底是什么,自然也就不要求可执行权限,只要求读权限就可以了
7.Look up the chmod program
man chmod
太长头疼, 还是这个吧: Linux chmod 命令 | 菜鸟教程 (runoob.com)
8.Use chmod to make it possible to run the command ./semester.
chmod 744 semester
./semester
给用户开权限x, 顺序是rwx, 全开就是111(2)->7
9.Use | and > to write the “last modified”date output by semester into a file called last-modified.txt in your home directory.
最后一问有点不太会... 哪个是last-modified time... output里面没找到啊
标签:tmp,测试,missing,chmod,semester,file,touch 来源: https://www.cnblogs.com/wind2375like/p/15764446.html