Common Commands
Help Commands
|
Description |
| compgen -c | Show all commands |
| compgen -a | Show all alias commands |
| compgen -A function | Show available functions |
| man <command> |
Show manual page of a command (more info than --help) |
| <command> --help |
Show help page of a command (less info than man command) |
| <command> --version |
Show version of a command |
File & Folder Commands
Description
List files/folders in current directory (+infos)
mkdir newdir
Create a new folder
cd somefolder
Change/switch to another directory
cp file.txt file-copy.txt
Copy a file
mv file.txt file-renamed.txt
Rename a file
mv file.txt /tmp
Move file to another folder
rm file.txt
Remove a file
rm -rf folder
Remove entire folder (recursive)
ln -s original target
Create a symlink
pwd
Show path of current folder
Search & String Commands
Description
Search for a file (recursive)
grep -rin "search string"
Search for a string in current folder (recursive)
grep -rin "search string" | cut -c 1-100
Search for a string in current folder + limit output of string
sed -Ei 's/someString/newString/g' file.txt
Replace "someString" with "newString" in a file
head file.txt
Show first 10 lines of file
tail file.txt
Show last 10 lines of file
cat file.txt
Show full content of file
cat file.txt | grep "search string"
Pipe output of "cat" command to grep + filter string
OS Helper Commands
|
Description |
| du -csh . |
Show size of current folder |
| df -h |
Show partitions / drives |
| lsb_release -a |
Show OS Version / Informations |
Remote / Host Commands
Description
Download a file
curl -LI https://www.google.com
Show Header Informations of URL
whois <host>
Show NS, DNS, Register about a host (e.g.: whois google.com)
host <host>
DNS Lookup of a host (e.g.: host google.com)
dig <host>
DNS Lookup of a host (verbose) (e.g.: dig google.com)
rsync -avz myfolder somehost:/var/www/
Sync a folder to a remote host and specific path
rsync -avz somehost:/var/www/ .
Sync from remote host and specific path to local folder
rsync -avz <dirSource> <dirTarget> Sync entire Folder (locally)
rsync -avz <dirSource>/ <dirTarget> Sync only contents of folder (locally)
Command-Line Operators
|
Description |
| <command> > file.txt |
Write output of a command into a file (creates/overwrites file) |
| <command> >> file.txt |
Write output of a command into a file (appends at end of file) |
| <command1> && <command2> |
Do command2 only if command1 succeeds |
| <command1> || <command2> |
Do command2 only if command1 fails |
| <command1> | <command2> |
Pipe command1 output into command2 |
| ! |
Negation Operator (e.g. find . ! -user "root") |
| More about operators: https://www.makeuseof.com/linux-command-line-chaining-operators/ |
Other helpful Commands
|
Description |
| htop |
Very helpful utility to show all process, cpu, ram, .. |
| ps aux | grep http |
Show processes who accesses http |
| which <command> |
Show path location of a command |
| history | tail |
Show last 10 lines of your history (commands) |
| bash myCustomScript.sh |
Execute a custom shell script |