其他分享
首页 > 其他分享> > 测试

测试

作者:互联网

目录

HW 1

1.Create a new directory called missing under /tmp;

mkdir /tmp/missing

检验:

image-20210729190920260


2.Look up the touch program. The man program is your friend.

man touch

结果:

image-20210729191336310


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:

image-20210729192316666

echo '#!/bin/sh' > /tmp/missing/semester
echo 'curl --head --silent https://github.com/siyuanluo' >> /tmp/missing/semester

单引号字符串非转义

检验:

vim /tmp/missing/semester

image-20210729192457708


5.Try to execute the file. Understand why it doesn’t work.

./semester
ls -l

结果:

image-20210729192854761

users的权限是-rw, 第一组, 没有执行权限x


6.Run the command by explicitly starting the sh interpreter.

sh semester

结果:

image-20210729193345938

解释: OS会通过sh命令的调用直接产生一个新的Shell进程,并将semester当作命令行参数传进去。新的Shell进程就会读取、解释并执行该脚本,而OS不关心该文件到底是什么,自然也就不要求可执行权限,只要求读权限就可以了


7.Look up the chmod program

man chmod

image-20210729193757700

太长头疼, 还是这个吧: Linux chmod 命令 | 菜鸟教程 (runoob.com)


8.Use chmod to make it possible to run the command ./semester.

chmod 744 semester
./semester

image-20210729194506541

给用户开权限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