1.
vm@vm-virtual-machine:~/Desktop$ echo $SHELL
/bin/bash
2.
vm@vm-virtual-machine:/home$ cd ..
vm@vm-virtual-machine:/$ pwd
/
vm@vm-virtual-machine:/$ ls
bin dev lib libx32 mnt root snap sys var
boot etc lib32 lost+found opt run srv tmp
cdrom home lib64 media proc sbin swapfile usr
vm@vm-virtual-machine:/$ mkdir /tmp/missing
vm@vm-virtual-machine:/$ pwd
/
vm@vm-virtual-machine:/$ cd /tmp
vm@vm-virtual-machine:/tmp$ ls
missing
snap-private-tmp
snap.snapd-desktop-integration
systemd-private-26f510d262a34be8bf25f04c1bf7676f-bluetooth.service-CMy6I7
systemd-private-26f510d262a34be8bf25f04c1bf7676f-colord.service-Tx7U4V
systemd-private-26f510d262a34be8bf25f04c1bf7676f-ModemManager.service-Z519d9
systemd-private-26f510d262a34be8bf25f04c1bf7676f-power-profiles-daemon.service-1KnaCk
systemd-private-26f510d262a34be8bf25f04c1bf7676f-switcheroo-control.service-pPtgRh
systemd-private-26f510d262a34be8bf25f04c1bf7676f-systemd-logind.service-4fvAXy
systemd-private-26f510d262a34be8bf25f04c1bf7676f-systemd-oomd.service-qsT3bv
systemd-private-26f510d262a34be8bf25f04c1bf7676f-systemd-resolved.service-wRsCSw
systemd-private-26f510d262a34be8bf25f04c1bf7676f-systemd-timesyncd.service-cwQDPB
systemd-private-26f510d262a34be8bf25f04c1bf7676f-upower.service-sdB8CO
tracker-extract-3-files.1000
tracker-extract-3-files.127
VMwareDnD
vmware-root_579-3979708611
3.
vm@vm-virtual-machine:/$ man touch
4.
vm@vm-virtual-machine:/$ pwd
/
vm@vm-virtual-machine:/$ cd missing
bash: cd: missing: No such file or directory
vm@vm-virtual-machine:/$ pwd
/
vm@vm-virtual-machine:/$ cd tmp/missing/
vm@vm-virtual-machine:/tmp/missing$ ls
vm@vm-virtual-machine:/tmp/missing$ touch semester.txt
vm@vm-virtual-machine:/tmp/missing$ ls
semester.txt
5.
vm@vm-virtual-machine:/tmp/missing$ echo '#!/bin/sh' > semester.txt
vm@vm-virtual-machine:/tmp/missing$ echo curl --head --silent https://missing.csail.mit.edu >> semester.txt
vm@vm-virtual-machine:/tmp/missing$ cat -n semester.txt
1 #!/bin/sh
2 curl --head --silent https://missing.csail.mit.edu
也可以用vim写入
6.
vm@vm-virtual-machine:/tmp/missing$ ./semester.txt
bash: ./semester.txt: Permission denied
vm@vm-virtual-machine:/tmp/missing$ ls -l
total 4
-rw-rw-r-- 1 vm vm 61 3月 21 14:40 semester.txt
无法执行,原因是文件所有者无执行权限(权限为rw-,只可读写)
7.
vm@vm-virtual-machine:/$ man chmod
8.
vm@vm-virtual-machine:/tmp/missing$ sh semester
semester: 2: curl: not found
因为没装Curl,用以下命令安装:
sudo apt-get update
sudo apt-get install curl
于是有:
vm@vm-virtual-machine:/tmp/missing$ sh semester
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
x-origin-cache: HIT
last-modified: Mon, 20 Mar 2023 11:05:13 GMT
access-control-allow-origin: *
etag: "64183de9-1f86"
expires: Mon, 20 Mar 2023 12:27:46 GMT
cache-control: max-age=600
x-proxy-cache: MISS
x-github-request-id: FBE4:3E92:9BE09:10268E:64184EEA
accept-ranges: bytes
date: Tue, 21 Mar 2023 07:24:51 GMT
via: 1.1 varnish
age: 0
x-served-by: cache-nrt-rjtf7700056-NRT
x-cache: HIT
x-cache-hits: 1
x-timer: S1679383492.688454,VS0,VE304
vary: Accept-Encoding
x-fastly-request-id: f046c5a8fa1c5479dd625f4092e371e1c94b8ddf
content-length: 8070
用./semester运行:
vm@vm-virtual-machine:/tmp/missing$ ./semester
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Mon, 20 Mar 2023 11:05:13 GMT
access-control-allow-origin: *
etag: "64183de9-1f86"
expires: Tue, 21 Mar 2023 07:49:00 GMT
cache-control: max-age=600
x-proxy-cache: MISS
x-github-request-id: 3D6C:4D5F:241E92:26D5D3:64195F14
accept-ranges: bytes
date: Tue, 21 Mar 2023 07:39:00 GMT
via: 1.1 varnish
age: 0
x-served-by: cache-tyo11958-TYO
x-cache: MISS
x-cache-hits: 0
x-timer: S1679384341.627790,VS0,VE177
vary: Accept-Encoding
x-fastly-request-id: e406ae07c4099bb1e5d7b5d58427e0955c190c26
content-length: 8070
#!是一个特殊符号,/bin/sh是用来解释该脚本的的shell路径
注:最开始把 #!/bin/sh 误输入为 #!bin/sh/
9.