My Most-Used Linux Commands Reference


All of these commands give you command-line option help by typing:
[command] --help
Don't use the brackets, they are there to denote the command.
Some of these commands are in optional packages. Follow the prompt.
Many of these commands will return a permissions error unless you
precede it with 'sudo'. (Without the quotes, dear.)

Get more detailed help by typing:
man [command]

Run multiple commands on one line:

Use the semicolon to run one after another until something goes wrong.
[command 1] ; [command 2]
Use double-ampersands (logical AND) to run next only when previous exits normally.
[command 1] && [command 2]
Use double pipe (logical OR) to run next only when previous exits with error.
[command 1] || [command 2]
Use both to do [if command 1 good, [command 2], else [command 3]]
[command 1] && [command 2] || [command 3]


ls - list files
lspci - lists recognized pci bus stuff
lshw - lists hardware drivers and stuff
uname -a - displays the linux kernel version and hostname
lsb_release -a - shows the distribution version


arp - list active computers on network.
ip addr - show current Ethernet interfaces and IP address.
netstat - shows contents of /proc/net files.
tcpdump - inspect packets
ping - finds if remote computer is up
hostname - displays or changes my computer's hostname
traceroute - traces route from my computer to remote
tracepath - similar to traceroute
findsmb - find Windows shares
ifconfig - lists all interfaces running
ip - has pretty much replaced ifconfig. ip addr shows interface addressing
ifup - bring an interface up - ifup wlan0 (this is NOT: if up. It's "eye-eff" up. if for "interface".
ifdown - take an interface down
route - displays or modifies routing table
rfkill - overrides wireless status
    ex: rfkill unblock wlan
    sudo rfkill block wifi - to turn off wifi
    sudo rfkill block bluetooth - to turn off bluetooth
iwconfig - displays wireless network interface information
    Provides signal strength info
    ex: iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY
iwlist - show info about WiFi interface.
    ex: iwlist wlan0 scanning == show me everything around me
    iwlist wlan0 freq == show me what bands work on this device
dhclient - get an IP address via dhcp
    ex: sudo dhclient wlan0
host - provides basic info about an Internet host
dig - part of dnsutils package. "$ dig NS"
whois - find the domain owner's information
wget - download file from website
curl - like wget with more - "curl -T " uploads file


tmux - split one terminal into multiple terminals in one screen. CTRL-B % splits. CTRL-B ? for help.
nmap - very powerful net scanner.
    ex: sudo nmap -sn to list all devices on network.
    ex: sudo nmap -A to show a lot of info on one device.
links - text mode browser with mouse support
pdftk - burst, combine, password protect pdf docs
rl - randomize-lines, input text file, randomize the lines, output to file
bless - GUI hex editor
nvtop - NVIDIA card monitor. Must be running nvidia drivers.
smartctl - See "DISK SPECIFIC".
imagemagik - work with image files
    convert example.png -resize 1024 example.png (note only 1 dash in option)
    - - resizes using only width, keeping ratio, to same filename.
    - - (my personal scaling suffixes for Github: -s is 640. -vs is 320.)


ssh - logs you in to the remote computer terminal. Default port is 22. Other ports more secure.
    ex: ssh -p[port] user@remoteHost
scp - Secure Copy. Copies files to or from remote over ssh.
    ex: scp -P[port] user@remoteHost:/path/to/file.ext /path/to/local/folder/
    NOTE: reverse the order of the last two parts to copy a local file to a remote folder.
ssh-keygen - generates a public/private key pair for you to use in automated authentication
ssh-copy-id - authorizes you on a remote computer so you don't have to provide a password every time.
    NOTE: you have to already have access to the remote for this to work. You'll be prompted for your
        login password during the process.
    ssh-copy-id -i ~/.ssh/[key] -p [port] user@host.address
As a general rule: on your local device, ensure permissions are:
    0600 on the private key (owner read/write only, group & other NO)
    0644 on the public key (owner read/write, group & other read only)


df - free disk space "df -h" produces short numbers
du - disk usage - "du -s /500gig" for summary
lsof - list open files: -i shows files open through network
sudo update-grub - re-reads drives and configures boot loader
dd - VERY powerful disk utility. Create disk images and more.
    ex: dd if=/dev/sda2 of=mysda2part creates a disk image named mysda2part.
Check network speed using a combination of dd and ssh:
    dd if=/dev/zero bs=1M count=1000 | ssh -p[port] user@remote-computer 'dd of=/dev/null'
blkid - get the UUID for a disk. Use 'sudo blkid /dev/part'
smartctl - part of smartmontools. See SMART data for a drive. 'sudo smartctl --all /dev/sda'


adduser - add a new user. Also adds users to groups.
addgroup - add a new group.
mkpasswd - use to encrpyt passwords (read before using)
passwd - change user password. SU can change forgotten passwords.
usermod - make changes to user accounts.
groups - shows what groups a user belongs to.


find - Find a file. "sudo find / -name Adafruit*"
cat - Hugely useful program. Takes stuff in and puts it out.
nc - netcat - does the same across a network connection.
cp - copy files. 'cp -ar source dest' = recursive, keeps stamps.
rsync - heavy-duty network file sync.
dd - create disk images and more.
chmod - change permissions flags on files and directories
chown - change the owner and group of a file or folder
chgrp - change only the group of a file or folder


Open text editor
    ex: sudo nano my_script
    opens the nano text editor under root permissions
First line must be:
#! /bin/bash
Then put your command line commands one at a time like a DOS batch file.
sudo chmod 774 my_script
    changes the permissions flags to allow execution by owner:group
    in this case owner:group is root:root


Ghostscript (gs) is a powerful tool for converting graphics files.
Example: Convert .ps file of a certain size to a .pdf file.
gs -q -sDEVICE=pdfwrite -g5584x5024 -r300 -sOutputFile=UNT_racks.pdf

Last edited 04/08/2024 is here courtesy of