测试

目录

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里面没找到啊

上一篇:js H5实现下拉刷新功能(马井堂)


下一篇:实现最简单的微信小程序组件拖拽