Man, all that syntax that just wouldn’t stay in memory if you’re not using it every day!.. Here’s how you do stuff on Ubuntu.
Replace example values with whatever you need. If you cannot tell example values from command names and other parameters, you probably shouldn’t be trying any of it.
Please keep in mind that this is a working note, an individual cheatsheet, not a comprehensive article on the subject. If you can use it, nice. If not, be nice. 🙂
General Information
Check how long it’s been since last system reboot:
$> uptime
Filesystem Details
List files in reversed order, i.e. newest last (-l detailed, -r reversed by -t time):
$> ls -lrt /path/to/somewhere
Report file system disk space usage (-h human-readable):
$> df -h
Cleaning Up (use with caution!)
Recursively remove directories (incl. contents) by (part of) name (may take a long time and seem hanging; mind the wildcards):
find . -type d -name "*partofname*" -print0 | xargs -0 rm -rf
Package Management
Sync with package repositories (don’t get confused by the word “update”, it’s not updating any packages, just the rep list):
$> sudo apt-get update
Gracefully update (i.e. upgrade) all outdated packages (incl. dependencies):
$> sudo apt-get dist-upgrade
Search for available packages (without installation status) by (part of) name:
$> apt search php
List installed packages filtered by (part of) name:
$> apt list --installed | grep php
Install a specific package:
$> sudo apt-get install phpmyadmin
Searching
Recursively find files by pattern:
$> find /path/to/somewhere/ -name *.txt
Find lines containing the pattern “error” in all files in the given directory (-r recursively; -n specify line number):
$> grep -rn /path/to/somewhere/ -e "error"
Archive Handling
List files in a compressed tarball (-t list files; -v verbose; -f from given file):
$> tar -tvf somearchive.tar.gz
Create a compressed tarball of the specified directory in the current directory (-c create; -z compress; -v verbose; -f from given file):
$> tar -zcvf somearchive.tar.gz /path/to/source/folder
Unpack a compressed tarball (-z uncompress gzip; -x extract archives; -v verbose; -f from given file):
$> tar -zxvf somearchive.tar.gz
Unpack a ZIP archive (-d optional destination folder):
$> unzip somearchive.zip -d tofolder
Leave a Reply