computer_science:linux:linux_cheatsheet

This is an old revision of the document!


Linux Cheatsheet

Linux Cheatsheet

CommandDescriptionSyntaxExampleNotes
jobsList jobs running in the background
jobs
jobs
bgChanges a job to the background.
bg %n
bg %1<n> being the value from a job.
fgChanges a job to the foreground.
fg %n
fg %2<n> being the value from a job.
tmuxOpens a shell so the user can logout and the process keeps running in the background.
tmux
tmux →CTRL+B

CTRL+B - % - New Tab Horizontally


CTRL+B - “ - New Tab Vertically


CTRL+B - Arrows - Move in Tabs |

tmux attachAttachs the shell to the tmux shell in the background
tmux attach
tmux attach → DAttachs the shell to the last used tmux.


CommandDescriptionSyntaxNotes

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
lsShows 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


CommandDescriptionSyntaxNotes
ip a
OR
ifconfig
Check your machine IPs
ip a
ifconfig
dmidecode –type memoryShows 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 savingIn 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


  • computer_science/linux/linux_cheatsheet.1628149374.txt.gz
  • Last modified: 2023/12/01 12:07
  • (external edit)