====== Linux Cheatsheet ======
[[engineering:computer_science:linux:linux|Linux]] Cheatsheet
===== Jobs: =====
^Command^Description^Syntax^Example^Notes|
|jobs|List jobs running in the background|
jobs
|jobs| |
|bg|Changes a job to the background.|
bg %n
|bg %1| being the value from a job.|
|fg|Changes a job to the foreground.|
fg %n
|fg %2| being the value from a job.|
\\
===== tmux =====
^Command^Description^Syntax|
|tmux list-sessions|Shows all live tmux sessions|
tmux list-sessions
|
|tmux attach| \\ Attaches to the last active tmux session. \\ \\ The session can be specified. \\ |
tmux attach
tmux attach-session -t
|
|CTRL+B - D|Dettachs to the current tmux session|
CTRL+B - D
|
|CTRL+B - %|Creates a New Horizontally Aligned Tab|
CTRL+B - %
|
|CTRL+B - "|Creates a New Vertically Aligned Tab|
CTRL+B - "
|
|CTRL+B - Arrows|Moves to existent Tabs|
CTRL+B - Arrows
|
\\
===== Disks and File Transfer: =====
^Command^Description^Syntax^Notes|
| \\ scp -r * remoteuser@remoteserver:/remote/folder/ |Copy all files and folders recursively from local to remote|
scp -r * remoteuser@remoteserver:/remote/folder/
| |
|du -sh /mnt/zebrabackup01/test |Shows folder size|
du -sh /mnt/zebrabackup01/test
| |
|ls|Shows object cont in folder|
ls | wc -l
| |
|
du -smh * | sort -nr | head -15
|List Files by Size in Human Readable Way > Sort and Reverse it > Show Top 15|
du -smh * | sort -nr | head -15
| |
\\
===== Administration: =====
^Command^Description^Syntax^Notes|
|ip a \\ **OR** \\ ifconfig|Check your machine IPs|
ip a
ifconfig
| |
|dmidecode –type memory|Shows the installed memory on your system|
dmidecode --type memory
| |
|
find /var/log -type f -regex ".*\.gz$"
find /var/log -type f -regex ".*\.[0-9]$"
|Find Rotated and Compressed Logs|
find /var/log -type f -regex ".*\.gz$"
find /var/log -type f -regex ".*\.[0-9]$"
|Add '-delete' to actually delete the files found. |
|
for CLEAN in $(find /var/log/ -type f)
do
cp /dev/null $CLEAN
done
|Empty all Log Files|
for CLEAN in $(find /var/log/ -type f)
do
cp /dev/null $CLEAN
done
|Deleting the files can cause issues. Emptying them is safer and recommended. |
|
sudo !!
|Re-run last command as root|
nano /etc/example.log
sudo !!
| |
|CTRL+x+e |Opens an editor, to create long / complex commands. Runs on saving|In Terminal: \\ CTRL+x+e \\ ls -l \\ CTRL+X \\ ENTER| |
|fc |Opens the last command in an editor to make it easier to fix it.|
fc
| |
|disown -a && exit |Exit Terminal but leave all processes running|
disown -a && exit
| |
\\