Title here
Summary here
呢個指令可以睇手冊頁中唔同嘅章節(Section)。
man man
man - an interface to the system reference manuals
The table below shows the section numbers of the manual followed by the types of pages they contain.
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions, e.g. /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
man 1 ls/cp/mv
man 2 write/open/close
man 3 printf/malloc/free
man 4 tty/null/random
man 5 passwd/fstab
man 7 man
man 8 ifconfig/iptables/mount
man 9 fork # not work
fortune
可以隨機嘅名言警句同笑話。
apt install fortune/fortune-mod/fortunes-zh
man 6 fortune
fortune - print a random, hopefully interesting, adage
可以結合 cowsay
同 lolcat
一齊玩。
fortune | cowsay | lolcat
Print Working Directory。
man pwd
pwd - print name of current/working directory
man cat
cat - concatenate files and print on the standard output
cat -n FILE
cat -b FILE
man ls
ls - list directory contents
ls -lh
drwx------ 9 root root 4.0K Aug 7 22:38 root
crw-rw-rw- 1 root tty 5, 0 Aug 7 22:33 /dev/tty
brw-rw---- 1 root disk 252, 0 Aug 7 21:30 /dev/vda
d
目錄,-
文件,l
鏈接,c
字符設備,b
塊設備。ls -ld */
包括隱藏文件
ls -ld .*/ */
ls -ld /usr
ls -lF /
/
:目錄*
:可執行文件@
:符號鏈接|
:命名管道=
:套接字ls ~ | wc -l
ls
命令嘅輸出中有隱藏字符 \n
。
ls ~ | od -c
0000000 f i l e \n f o o \n f o o b a r \n
0000020
仲可以用 cat -A
。
ls ~ | cat -A
file$
foo$
foobar$
顯示文件類型
man file
file — determine file type
file /dev/tty
/dev/tty: character special (5/0)
file /dev/vda
/dev/vda: block special (252/0)
注意結尾斜杆。
file /bin
/bin: symbolic link to usr/bin
file /bin/
/bin/: directory
more
命令只能按回車加載,less
命令更強大,因為 less is more。
man less
less - opposite of more
man usermod
usermod - modify a user account
usermod -s /sbin/nologin kuga
呢個命令會喺 /etc/passwd
中把 bin/sh
改為 /sbin/nologin
kuga:x:1000:1000::/home/kuga:/sbin/nologin
下面嘅命令會俾 kuga 用戶授權 sudo 用戶組。
usermod -aG sudo kuga
man ln
ln - make links between files
go rocks
man df
df - report file system disk space usage
df -h
df -h -t ext4
df -h -t apfs
ext4
係 Linux 嘅文件系統類型,apfs
係 macOS 嘅文件系統類型。
Disk Usage
man du
du - estimate file space usage
du -sh ~/Downloads
du -ah ~/Downloads/* | sort -rh | head -n 5
du -ah ~/Downloads --max-depth=1 | sort -rh | head -n 10
du -sh ~/Downloads/* | sort -rh | head -n 5