List of some Linux commands that I use, with a description of what they do. Primarily intended as my personal reminder, but if it helps anyone else – great! 🙂
1. Warning
Just a few things you should have in mind when reading this:
Firstly, there are three rules when running Linux commands you find on the Internet (copy/paste):
- Don’t run a command unless you understand exactly what it does.
- Don’t run a command unless you understand exactly what it does.
- Don’t run a command unless you understand exactly what it does.
This goes for the commands shown here as well.
Secondly, I am not a Linux expert.
(Any additions or corrections are more than welcome)
Thirdly, I’m running this on Linux Mint. It probably works on Ubuntu as well. I suppose it should work with most Debian-based Linux distributions, but I haven’t tested it.
2. Linux commands list (random order)
Every Linux system I’ve worked with so far opens the command prompt via a keyboard shortcut:
(left-side control keys) ALT + CTRL + T (letter).
2.1. System info
To get useful help from the Linux Mint forum and similar places, it’s best to share your computer info – so any experts can have an idea of what you’re working with.
Operating system version display (and your computer name):
hostnamectl
Hardware and installed drivers list:
lshw
2.2. Network and Internet
Computer’s IP address:
ifconfig
DNS settings list:
systemd-resolve --status
Flush DNS cache:
resolvectl flush-caches
OR
sudo /etc/init.d/dns-clean start
Network (bandwidth) usage statistics:
sudo apt install vnstat
sudo systemctl enable vnstat
vnstat -m
Windows PowerShell command to save ping results in a text file (until I make a dedicated Windows-related article 🙂 ):
ping.exe -t www.google.com|Foreach{"{0} - {1}" -f (Get-Date),$_} >> c:\test\ping-result-2023-10-18.txt
Chrome update was not working on Ubuntu (22.04) – this fixed it:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get install -f
Ubuntu 22.04 Viber installation:
wget https://download.cdn.viber.com/cdn/desktop/Linux/viber.deb
sudo apt install ./viber.deb
2.3. System tweaking
For some basic fixes and patches, see the Linux Tweaking section.
Computer is powered off (shut-down) using:
sudo shutdown -h now
Removing old kernel versions (enter “y” after running the command):
dpkg-query -W -f '${Version}\n' 'linux-image-[^g]*'|sort -u|sed -e '/^$/d' -e 's/\~[^~]*$//' -e 's/\.[^.]*$//' -e "/$(uname -r|sed 's/-generic//')/d" -e 's/.*/linux-*-&*/'|tr '\n' ' '|xargs -pr sudo apt-get remove --purge -y
If that fails, for whatever reason, try this:
dpkg-query -W -f '${Version}\n' 'linux-image-[^g]*'|sort -u|sed -e '/^$/d' -e 's/\~[^~]*$//' -e 's/\.[^.]*$//' -e "/$(uname -r|sed 's/-generic\|-lowlatency//')/d" -e 's/.*/linux-*-&*/'|tr '\n' ' '|xargs -r sudo apt-get remove --purge -y
To install Microsoft fonts (Arial and the bunch 🙂 ):
sudo apt-get install msttcorefonts
Last updated:
Originally published:
# get ip address
ip a
# get dns server ip
cat /run/systemd/resolve/resolv.conf
resolvectl status
# flush dns cache
resolvectl flush-caches
# poweroff
poweroff OR halt
# purge old kernels
sudo apt purge $(dpkg -l | awk ‘/linux-(image|headers|modules)/ && !/’$(uname -r | sed -E ‘s/-[a-z]+//’)’/ && !/hwe/ {print $2}’)