Links
“The art of command line” should have included most essential commmands. https://github.com/jlevy/the-art-of-command-line
“Linux Productivity Tools” by Ketan M. https://www.olcf.ornl.gov/wp-content/uploads/2019/12/LPT_OLCF.pdf
Plus all kinds of cheatsheets online. https://tmuxcheatsheet.com/
You would thank shellcheck.
My Tips
I don’t think there is any meaning memorising all the commands and options. I learn the commands when I use them. I forget if I don’t touch them for a long time.
On top of that, why would I bother when I have handy tools like tldr, cheat.sh and man.
The really important commands you should remember are:
brew install tlrc
tldr tar
# or
curl cht.sh/tar
# or
man tar
Commands
File
grep <pattern> <file>zcat <file.gzip>zless <file.gzip>head/tail -n 10tail -f <file>scp <server:path> <dest>du -sh <path> | sort -hcat <file> | tr '\n' ';'sedtldrteefind . -maxdepth 1 -type f -exec wc -l {} \;cmd > log.txt 2>&1redirect stderr and stdout to log.txtsplit --number 2 <file>Used one time when I have to split a 10G file into under 1G per file.
I can spend a section on sed and awk and more on find. But I will probably ask AI when I want to use them.
File permisson:
# user group other
-rwxrwxrwx
# directory
drwxrwxrwx
SSH
ssh-keygen -t ed25519 -a 32 -f ~/.ssh/id_ed25519 -C "comment"
Bash
-
set -euo pipefailexit immediately if a command exits with non-zero status. -
history -
Heredoc
cat << EOF line 1 line 2 EOF
System
topps auxlsof -i :8080lsof -p <PID> | wc -lcheck number of file descriptors.lshwdffree --humanShow free memoryuname -adetails about the current machine and the operating systemlsb_release -auptimewShow who is logged on and what they are doing.hostnamenohup <script.sh> &jobskill <pid>sudo nvme smart-log <device>. Checking the SSD status. Probably the last thing to confirm when a database was down.systemctl status <service>
Network
host <domain> <dns>ufwUncomplicated Firewallip addrdig example.comnetstat -tuln
DNS file: /etc/resolv.conf
Notes
An inode stores all metadata about a file, except for the filename.
Hard links:
- Only link to a file, not a directory
- Can’t reference a file on a different disk/volume
- Links will reference a file even if it is moved
- Links reference inode/physical locations on the disk
Symbolic (soft) links:
- Can link to directories
- Can reference a file/folder on a different hard disk/volume
- Links remain if the original file is deleted
- Links will NOT reference the file anymore if it is moved
- Links reference abstract filenames/directories and NOT physical locations.
- They have their own inode