Commands Flashcards
Head -n 5 filename.txt
Tail -n 5 filename.txt
Head
Tail
-n (number)
The first 5 lines
and the last 5 lines
Head -n +3 filename.txt
Tail -n +3 filename.txt
Head
Tail
-n (number)
Go to the third line and show us everything above that
Go to the third line and show us everything above that
Sort filename.txt
Sort -r filename.txt
Sorts by alphabetical order
Sort reverse
Cut -c 1-3 filename.txt
Cut -d, -f 2 filename.txt
Cut (By character) first three
Cut (delimiter) (field) by comma field 2
Grep red filename.txt
Grep -i red filename.txt
Grep red in file
Grep same thing case insensitive
Grep -E el?o filename.txt
Grep (extended regex) el?o
(Means zero or one times)
Extended regex only for the ? Not for
[ ], ., or *
Wc -c -m -l filename.txt
Word count (bytes) (characters) (lines)
Ln originalfile.txt linkfile.txt
Ln - s originalfile.txt linkfile.txt
Hard link two files
Symbolic link two files
ID
Uid=1000(zahir) gid=1000(zahir) groups=1000(zahir),4(adm),24(cdrom),27(sudo) etc
Last
Shows the last users that logged in
Zahir :1 :1 Mon Mar 4 17:29
Has a still logged in column,
9 columns deep
Who
Shows who’s logged in
Zahir :1 2024-03-04 17:29 (:1)
5 columns deep
W
Shows what they are doing
20:41:08 up 3:12, 1 user, Load average
Free -h
Shows how much memory is available
-h human readable
Total used free shared (header)
Ps aux
Process status (in terminal)
Aux shows all processes
Ps has a small header, top has a giant header
Top
Current running processes live
Top has a huge header