Personal lists of useful Linux shell commands.


System Info
dmesg # boot message
dmesg | less # view line by line

sudo lshw # complete info about computer!
uname -a # server info
cat /etc/*release # OS
lsb_release -a # OS
arch # processor
df -hT # mounted file systems
cmount -l # lists all mounted filesystems
env | sort # environmental variables
lsmod # modules
lspci -nnk | grep VGA # video driver

Memory Usage
free -mto # memory in MBs totaled w/o
cat /proc/meminfo # memory usage information
cat /proc/swaps # swap information

Init System
sudo /sbin/init --version

Process Info
ps -ef --sort uid,pid # all processes sort by
user and by UID
ps aux --sort -rss # all processes sorted my memory usage descending
ps -efww | grep java | grep -v grep # full info all java processes but not grep
pgrep -fl java # full info all java processes
top # Linux tasks

Kill Process by Port
lsof -i :your_port
kill -9 your_pid

Startup / Shutdown
sudo shutdown now
sudo reboot

Command Shell History
history | grep search_term
!100 # # of item to re-execute
!previous_command # re-execute last use of that command


File System


Change Directories
cd .. # back one level
cd ~ # home
cd / # root
cd /dir1/dir2
cd /dir\ with\ spaces\ in\ name

List Directories
ls .conf # .*,
search_string., etc.
lsblk # list block devices
lsblk -fs # list block devices with filesystems info
ls -Alh # hidden files, file info, human-readable
ls -dl */ # list all directories
ls *.jpg -Al --block-size=M # list all JPEGs in Megabytes

List USB Devices
lsusb -s 1:4 -v

Display Contents of File
cat name_of_file

Make File
touch name_of_new_file

Create Symbolic Link
sudo ln -s ~/path/to/

sudo su
sudo !!
sudo chmod -R 777 file_or_dir_name
sudo chmod a+rwx filename
rm -rf file_or_dir_name(remove directory and contents

awk -F":" '{ print "username: " $1
"\t\tuid:" $3 }' /etc/passwd # list all users

cut -d: -f1,3

getent group groupname | awk -F: '{print $4}' # list users in a group

Find File(s
find / -name 'file_to_find'
find /path -type d -empty # find all empty directories in path
find ~ -size +100M -ls # find all +100M files in home directory

Search Files Recursively
grep -r

Delete Directory of Files
sudo rm -rf

Secure Copy to and from Remote System
scp .xyz
~/ /path/ user@
scp -rp user@
~/local_path/ # copy all directories starting
with search_term

Display Part of File – Log File Examples
head -25
tail -150 /var/log/messages
cat /var/log/messages | grep "search_term"



Renew IP Address
sudo dhclient -r
sudo dhclient
/etc/init.d/networking restart

Change Hostname
sudo nano /etc/hostname
sudo /etc/init.d/ start

Edit Hosts File
sudo nano /etc/hosts

Edit Network Settings Files

List All Ports
netstat -tulpn
cat /etc/services

List Network Interfaces
ip addr
ip addr show wlan0
ip link

Misc Network Commands
sudo arp-scan

(Address Resolution Protocol # ARP) Scanner)

nc > /dev/null; echo $? # is port open?
ping domain_or_ip -c 3
traceroute domain_or_ip route PRINT # show IP
routing table

Detailed WLAN Information
iwlist scan
iwlist wlan0 scan | less

sudo nano /etc/ssh/sshd_config # change from port
sudo service ssh restart
sudo ss -lnp | grep sshd # show ports


Software Installation

Package Manager for Debian-based Ubuntu
dpkg -l
dpkg -l name_to_find

APT Package Handling Utility for Debian-based Ubuntu
sudo apt-get update && sudo apt-get upgrade
apt-cache search "partial_name_of_package"
apt-get install name_of_package
apt-get install package1 package2 package3
sudo apt-get --reinstall install package1
sudo apt-get clean
sudo apt-get autoremove

Yum Package Management for RHEL/Oracle Linux distros
sudo yum update
yum clean packages
yum list installed | less

Uncompressing Various File Types
sudo tar xvfJ
sudo tar zxvf file_to_uncompress.tar.gz

Check File
sha256sum file_to_check # check SHA256 # 256-bit)
md5sum file_to_check # check MD5 # 128-bit) checksums
sum file_to_check # checksum and count the blocks in a file

Execute Shell File
chmod +x
sudo ./

Find Library Version Information
pkg-config --modversion

Start a Service
service service_name stop | start | restart |
status # Stop/Start/Check service

chkconfig service_name on # Set the service to start




Setting Environmental Variable
sudo nano ~/.bashrc
bash --login


Java Info
which java
java -version

sudo update-alternatives --config java # get next #

Execute jar File
java -jar jar_file_name.jar

Raspberry Pi

Firmware Update
sudo apt-get install git-core # 1x
sudo wget -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update # 1x
sudo rpi-update # to update each time

Duplicate SDHC Card
sudo dd if=dev/sdb
of=~/sdhc-card-bu.bin # Copy to HDD
sudo dd if=~/sdhc-card-bu.bin of=/dev/sdb # Copy back to new SDHC

Computer Vision

OpenCV, cvBlob, FFMpeg
Link: Install
OpenCV 2.4.* in Ubuntu 12.04 Precise Pangolin

pkg-config --modversion opencv # Which version of OpenCV?
pkg-config --modversion cvblob # Which version of cvBlob?
sudo ldconfig -v # Configure dynamic linker run-time bindings


  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: