A handy crib sheet of various commands I need to remember and don’t use all that often.
command | notes |
---|---|
su - root | preserve the path when changing to superuser (note the sp between – and root) |
tasksel | this will allow other display managers to be installed (ie. gnome) |
find / -name apt | find all commands with the regex name “apt” (no quotes) |
find / -name apt 2> /dev/null | as above, but redirect errors to the null device |
grep -Ril "text-to-find-here" / | find in files |
which | locate the command which would have been executed |
dmesg -w | grep -i “mode” | display kernel messages containing “mode” (must be su) |
inxi -Gx | system information, -Gx returns graphics related stuff |
xrandr --verbose | show monitor configuration |
grep '/usr/s\?bin' /etc/systemd/system/display-manager.service | show which display manager is installed |
sudo apt-get install gdm3 | install gdm3 display manager |
apt update && apt full-upgrade | Install any upgrades |
apt-get remove --autoremove | remove package and any other dependent package which is no longer needed |
apt-get purge --autoremove | as above, but also delete configuration and/or data files of the package |
apt-mark showmanual | show manually install packages |
apt list --installed | grep -w "installed]" | grep htop | show all manually installed packages containing ‘htop’ |
apt-cache policy htop | |
ls /etc/apt/sources.list.d/ | show custom package sources |
dpkg -L htop | List files ‘owned’ by the htop package |
dpkg -S uname | Find the package containing the file ‘uname’ |
<command> `uname -r` | command substitution |
df -hx tmpfs | show the file system sizes in human readable form, exluding tmpfs |
tar -xvzf community_images.tar.gz | extract a tar.gz |
Other commands
How to exclude a package from apt-get autoremove?
apt-get autoremove -s \
| sed -ne 's/Remv \(linux[^[]*\)\[.*/\1/gp' \
| xargs apt-get remove -y
![]() |
Frank Ray & Associates is a software engineering consultancy that builds high quality software for businesses. |