As a tech, you’ll no doubt come in contact with Linux. This post has a few basic Linux commands you should know.

If you want more information on various commands you can enter man <command>.

Basic Usage

Command Function Example Usage
man view manual entry man mount
ls list directory content ls /home/user
mkdir make directory mkdir /home/user/new
rmdir remove directory rmdir /home/user/deleteme
cd change current directory cd /home/user/new
pwd print current directory pwd
rm remove (delete) file rm todelete
cat output file to std out (screen) cat /home/user/file.txt
grep regex search grep strtofind /home/user/file.txt (see man page); use grep -i for case insensitive
tail output last lines of file cat /home/user/log.txt | tail
more by-page view of file cat /home/user/log.txt | more
dmesg prints message buffer of kernel dmesg | more
top display process information top
mv moves the specified files mv -i originalfile newfile
cp copies the specified files cp -R sourcedestination

Basic Diagnostics

Command Function Example Usage
lspci list PCI devices lspci -v
lsusb list USB devices lsusb -v
df -h display free space on disks df -h
sudo fdisk -l list connected devices sudo fdisk -l
tail -f watch a log live tail -f /var/log/messages

Basic Networking and Processing

Command Function
ifconfig -a show net adapter information
ifconfig -a | grep HWaddr print MAC addresses
ps -A | grep <program name> kill processes by name
sudo /etc/init.d/networking restart restart networking
sudo /etc/init.d/gdm restart restart graphics system (gnome)
sudo dexconf reset graphics configuration
sudo ufw status get firewall status
sudo ufw enable turn on the firewall
ufw allow port allow port
ufw deny port block port
sudo apt-get -f install try to fix broken packages
sudo apt-get upgrade upgrade all packages

Pin It on Pinterest