カテゴリー: UNIX
UNIX コマンド
dotinstall:~ $ echo {a,b,c}
a b c
dotinstall:~ $ echo {1..10}{a..g}
1a 1b 1c 1d 1e 1f 1g 2a 2b 2c 2d 2e 2f 2g 3a 3b 3c 3d 3e 3f 3g 4a 4b 4c 4d 4e 4f 4g 5a 5b 5c 5d 5e 5f 5g 6a 6b 6c 6d 6e 6f 6g 7a 7b 7c 7d 7e 7f 7g 8a 8b 8c 8d 8e 8f 8g 9a 9b 9c 9d 9e 9f 9g 10a 10b 10c 10d 10e 10f 10g
dotinstall:~ $ mkdir test && cd test
mkdir: can’t create directory ‘test’: File exists
dotinstall:~ $ ls
test
dotinstall:~ $ mkdir app{1..5}
dotinstall:~ $ ls
app1 app2 app3 app4 app5 test
dotinstall:~ $ touch app{1..5}/test{1..3}{.jpg,.png,.gif}
dotinstall:~ $ ls app2
test1.gif test1.png test2.jpg test3.gif test3.png
test1.jpg test2.gif test2.png test3.jpg
dotinstall:~ $ rm app{1..5}/test{1..3}{.jpg,.gif}
dotinstall:~ $ ls app2
test1.png test2.png test3.png
dotinstall:~ $ cd
dotinstall:~ $ rm -r test/
dotinstall:~ $
UNIX コマンド
dotinstall:~ $ ls -l /etc/
total 208
-rw-r–r– 1 root root 7 May 29 2020 alpine-release
drwxr-xr-x 1 root root 4096 Sep 23 2020 apk
drwxr-xr-x 3 root root 4096 Sep 23 2020 ca-certificates
-rw-r–r– 1 root root 5613 Jun 18 2020 ca-certificates.conf
drwxr-xr-x 2 root root 4096 May 29 2020 conf.d
drwxr-xr-x 2 root root 4096 May 29 2020 crontabs
-rw-r–r– 1 root root 89 May 29 2020 fstab
-rw-r–r– 1 root root 693 Sep 23 2020 group
-rw-r–r– 1 root root 682 May 29 2020 group-
-rw-r–r– 1 root root 12 Sep 12 05:01 hostname
-rw-r–r– 1 root root 177 Sep 12 05:01 hosts
drwxr-xr-x 2 root root 4096 May 29 2020 init.d
-rw-r–r– 1 root root 570 May 29 2020 inittab
-rw-r–r– 1 root root 1748 Feb 9 2020 inputrc
-rw-r–r– 1 root root 54 May 29 2020 issue
-rw-r–r– 1 root root 309 Aug 9 2020 localtime
drwxr-xr-x 2 root root 4096 May 29 2020 logrotate.d
drwxr-xr-x 2 root root 4096 May 29 2020 modprobe.d
-rw-r–r– 1 root root 15 May 29 2020 modules
drwxr-xr-x 2 root root 4096 May 29 2020 modules-load.d
-rw-r–r– 1 root root 283 May 29 2020 motd
lrwxrwxrwx 1 root root 12 Sep 12 05:01 mtab -> /proc/mounts
drwxr-xr-x 8 root root 4096 May 29 2020 network
drwxr-xr-x 2 root root 4096 May 29 2020 opt
-rw-r–r– 1 root root 164 May 29 2020 os-release
-rw-r–r– 1 root root 1233 Sep 23 2020 passwd
-rw-r–r– 1 root root 1172 May 29 2020 passwd-
drwxr-xr-x 7 root root 4096 May 29 2020 periodic
-rw-r–r– 1 root root 238 May 29 2020 profile
drwxr-xr-x 1 root root 4096 Sep 23 2020 profile.d
-rw-r–r– 1 root root 1865 May 29 2020 protocols
-rw-r–r– 1 root root 54 Sep 12 05:01 resolv.conf
-rw-r–r– 1 root root 65 May 22 2020 securetty
-rw-r–r– 1 root root 14464 May 29 2020 services
-rw-r—– 1 root shadow 454 Sep 23 2020 shadow
-rw-r—– 1 root shadow 422 May 29 2020 shadow-
-rw-r–r– 1 root root 48 Sep 23 2020 shells
drwxr-xr-x 1 root root 4096 May 29 2020 ssl
-rw-r–r– 1 root root 3941 May 25 2020 sudo.conf
-rw-r–r– 1 root root 6169 May 25 2020 sudo_logsrvd.conf
-rw-r–r– 1 root root 3228 Sep 23 2020 sudoers
drwxr-x— 2 root root 4096 Sep 23 2020 sudoers.d
-r–r—– 1 root root 3174 May 25 2020 sudoers.dist
-rw-r–r– 1 root root 53 May 29 2020 sysctl.conf
drwxr-xr-x 2 root root 4096 May 29 2020 sysctl.d
drwxr-xr-x 13 root root 4096 Sep 23 2020 terminfo
-rw-r–r– 1 root root 5306 May 22 2020 udhcpd.conf
dotinstall:~ $ ls -l /etc/ | grep ‘sudo’
-rw-r–r– 1 root root 3941 May 25 2020 sudo.conf
-rw-r–r– 1 root root 6169 May 25 2020 sudo_logsrvd.conf
-rw-r–r– 1 root root 3228 Sep 23 2020 sudoers
drwxr-x— 2 root root 4096 Sep 23 2020 sudoers.d
-r–r—– 1 root root 3174 May 25 2020 sudoers.dist
dotinstall:~ $ ls -l /etc/ | grep ‘sudo’ | wc -l
5
dotinstall:~ $ ls -l /etc/ | grep ‘sudo’ | wc -l > results.txt
dotinstall:~ $ cat results.txt
5
dotinstall:~ $ rm results.txt
dotinstall:~ $
UNIX コマンド
dotinstall:~ $ echo ‘data’
data
dotinstall:~ $ echo ‘date’ > commands.txt
dotinstall:~ $ cat commands.txt
date
dotinstall:~ $ echo ‘cal’ > commands.txt
dotinstall:~ $ cat commands.txt
cal
dotinstall:~ $ echo ‘date’ >> commands.txt
dotinstall:~ $ cat commands.txt
cal
date
dotinstall:~ $ /bin/ash < commands.txt
September 2023
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Tue Sep 12 06:18:41 JST 2023
dotinstall:~ $ /bin/ash < commands.txt > results.txt
dotinstall:~ $ cat results.txt
September 2023
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Tue Sep 12 06:19:05 JST 2023
dotinstall:~ $ rm *
dotinstall:~ $
UNIX コマンド
dotinstall:~ $ ls -l
total 4
-rwxr–r– 1 dotinsta wheel 30 Sep 11 19:20 hello
dotinstall:~ $ echo $PATH
/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
dotinstall:~ $ export PATH=/home/dotinstall:$PATH
dotinstall:~ $ echo $PATH
/home/dotinstall:/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
dotinstall:~ $ hello
bash: /home/dotinstall/hello: bin/ash: bad interpreter: No such file or directory
dotinstall:~ $ hallo
bash: hallo: command not found
dotinstall:~ $ cd ..
dotinstall:/home $ which hello
/home/dotinstall/hello
dotinstall:/home $ $PATH
bash: /home/dotinstall:/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: No such file or directory
dotinstall:/home $ cd
dotinstall:~ $ rm hello
dotinstall:~ $
UNIX コマンド
dotinstall:~ $ ls
dotinstall:~ $ vi hello
dotinstall:~ $ cat hello
!bin/ash
echo ‘Hello there!’
dotinstall:~ $ vi hello
dotinstall:~ $ cat hello
!bin/ash
echo ‘Hello there!’
dotinstall:~ $
UNIX コマンド
dotinstall:~ $ vi hello
dotinstall:~ $:q
UNIX コマンド
dotinstall:~ $ ls -l /exc/shadow
ls: /exc/shadow: No such file or directory
dotinstall:~ $ ls -l /etc/shadow
-rw-r—– 1 root shadow 454 Sep 23 2020 /etc/shadow
dotinstall:~ $ cat /etc/shadow
cat: can’t open ‘/etc/shadow’: Permission denied
dotinstall:~ $ sudo !!
sudo cat /etc/shadow
root:!::0:::::
bin:!::0:::::
daemon:!::0:::::
adm:!::0:::::
lp:!::0:::::
sync:!::0:::::
shutdown:!::0:::::
halt:!::0:::::
mail:!::0:::::
news:!::0:::::
uucp:!::0:::::
operator:!::0:::::
man:!::0:::::
postmaster:!::0:::::
cron:!::0:::::
ftp:!::0:::::
sshd:!::0:::::
at:!::0:::::
squid:!::0:::::
xfs:!::0:::::
games:!::0:::::
cyrus:!::0:::::
vpopmail:!::0:::::
ntp:!::0:::::
smmsp:!::0:::::
guest:!::0:::::
nobody:!::0:::::
dotinstall:!:18528:0:99999:7:::
dotinstall:~ $ sudo
UNIX コマンド
dotinstall:~ $ ls
dotinstall:~ $ touch index.html
dotinstall:~ $ ls -l
total 0
-rw-r–r– 1 dotinsta wheel 0 Sep 8 21:06 index.html
dotinstall:~ $ rm -index.html
rm: unrecognized option: n
BusyBox v1.31.1 () multi-call binary.
Usage: rm [-irf] FILE…
Remove (unlink) FILEs
-i Always prompt before removing
-f Never prompt
-R,-r Recurse
dotinstall:~ $ ls
index.html
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
rm: can’t remove ‘index.html’: No such file or directory
dotinstall:~ $ ls
dotinstall:~ $
UNIXコマンド
dotinstall:~ $ ls
dotinstall:~ $ cp /etc/services .
dotinstall:~ $ wc services
417 1994 14464 services
dotinstall:~ $ wc -l services
417 services
dotinstall:~ $ head -n 3 services
Network services, Internet style
#
Note that it is presently the policy of IANA to assign a single well-known
dotinstall:~ $ tail -3 services
fido 60179/tcp # fidonet EMSI over TCP
Local services
dotinstall:~ $ grep ‘backup’ services
amanda 10080/tcp # amanda backup services
afbackup 2988/tcp # Afbackup system
afbackup 2988/udp
afmbackup 2989/tcp # Afmbackup system
afmbackup 2989/udp
kamanda 10081/tcp # amanda backup services (Kerberos)
amandaidx 10082/tcp # amanda backup services
amidxtape 10083/tcp # amanda backup services
dotinstall:~ $ rm services
dotinstall:~ $ ls
dotinstall:~ $