Common Commands
This page was last updated on October 05, 2009.
Note that these are all single-line commands, even if they wrap on your screen. If you select them by highlighting them and pasting them into your terminal window or a text editor, the resulting paste will be a single line.
| TASK | COMMAND |
| Check disk free space. | df -h |
| Check hard drive for bad blocks. | badblocks |
| Convert all Windows ASCII CR characters in a file to newlines. | tr '\r' '\n' desinationfile |
| Copy a file. | cp filename /path/to/destination |
| Copy a folder. | cp foldername /path/to/destination |
| Create an empty file. | touch file |
| Display BIOS information. | dmidecode |
| Display configuration file for file system mounting. | cat /etc/fstab |
| Display CPU information. | cat /proc/cpuinfo |
| Display CPU information. | hwinfo --cpu |
| Display CPU load, swapping, and I/O. | vmstat |
| Display CPU, network load, etc. | xosview |
| Display current directory. | pwd |
| Display currently mounted file systems. | cat /etc/mtab |
| Display current RAM and swap use. | free |
| Display Daylight Savings Times. | zdump -v /etc/localtime | grep 2009 |
| Display directories in current directory sorted by size. | du -k --max-depth=1 | sort -n |
| Display directory contents. | ls |
| Display directory contents as a list. | ls -l |
| Display directory contents as a list by age. | ls -ltr |
| Display directory contents as a list by size. | ls -lSr |
| Display directory contents including hidden files. | ls -al |
| Display directory size. | du -sh /path/to/directory |
| Display dynamic CPU, network load, etc. (KDE3) | ksysguard |
| Display dynamic CPU temperature. | lm-sensors |
| Display dynamic RAM and CPU information. | top |
| Display groups. | cat /etc/group |
| Display groups user is in. | groups username |
| Display kernel and operating system information. | uname -a |
| Display kernel messages shown while booting. | cat /var/log/messages |
| Display last few lines of dmesg dynamically. | tail -f /var/log/messages |
| Display libraries a program depends on. | ldd /path/to/program/executable/file |
| Display man page not in path. | man /path/to/manpage |
| Display my computer’s name. | hostname |
| Display my hardware as an HTML file. | sudo lshw -html > filename.html |
| Display my kernel version. | uname -r |
| Display my user and group ID and groups I belong to. | id |
| Display my username. | whoami |
| Display my Linux Distribution. | cat /etc/lsb-release |
| Display my Linux Distribution. | cat /etc/*release |
| Display my Linux Distribution. | lsb_release -a |
| Display network interface information. | ifconfig |
| Display package version and dependencies. | dpkg -s packagename |
| Display partition tables. | sudo fdisk -l |
| Display routing table using numerical addresses. | route -n |
| Display routing table using numerical addresses. | netstat -rn |
| Display static RAM information. | cat /proc/meminfo |
| Display subdirectories of current directory. | find -type d -ls |
| Display subdirectories of specified directory. | find /path/to/parent/directory -type d -ls |
| Display the status of your OpenGL subsystem. | glxinfo |
| Display what I’m doing. | finger username |
| Display what’s using this file. | fuser |
| Display where a package is installed. | dpkg -L packagename |
| Display who’s logged in and when they logged in. | who |
| Display who’s logged in and what they’re doing. | w |
| Download a web page. | wget URL |
| Find drives on the computer. | sudo lshw -class disk |
| Find the device location of NTFS partitions. | sudo fdisk -l | grep NTFS | awk '{print $1}' |
| Get the UUID of a drive or drives. | vol_id --uuid /dev/sda3 |
| Get the UUID of a drive or drives. | sudo blkid |
| Identify my video card. | lspci -nn | grep VGA |
| List all active serial devices(/dev/ttyS*). | setserial -bg /dev/ttyS[0-9]* |
| List all installed hardware. | lsdev |
| List all scsi devices. | lsscsi |
| List all scsi devices. | hwinfo --scsi |
| List all usb devices. | lsusb |
| List all usb devices. | hwinfo --usb |
| List commands that are currently running. | ps -ef |
| List currently loaded kernel modules. | lsmod |
| List devices on the pci bus. | sudo lspci -vv > filename.txt |
| List devices on the pci bus. | hwinfo --pci |
| List files that are currently open. | lsof | less |
| List login history. | last |
| Make a directory. | mkdir directoryname. |
| Move a file. | mv filename /path/to/destination |
| Move a folder. | mv foldername /path/to/destination |
| Output of a command to stdout and also to .txt file. | commandname | tee file.txt |
| Ping $host to see if it’s alive on the network. | ping $host |
| Reconfigure Xorg or create a new xorg.conf file. | sudo dpkg-reconfigure -phigh xserver-xorg |
| Read ‘x’ from keyboard (this is for scripting). | read x |
| Release my IP. | sudo dhclient -r eth0 |
| Remove all Windows ASCII CR characters from a file. | tr -d '\r' destinationfile |
| Rename a file. | mv filename newfilename |
| Rename a folder. | mv foldername newfoldername |
| Rename all files in current directory, changing spaces to underscores. | rename 's/ /_/g' * |
| Rename all files in current directory to lower case. | for i in `ls -1`; do file1=`echo $i | tr [A-Z] [a-z]`; mv $i $file1 2>/dev/null; done |
| Rename all files in current directory to upper case. | for i in `ls -1`; do file1=`echo $i | tr [a-z] [A-Z]`; mv $i $file1 2>/dev/null; done |
| Renew my IP. | sudo dhclient eth0 |
| Restart the computer. | sudo shutdown -r now |
| Restart the computer. | sudo reboot |
| Restart the network. | sudo /etc/init.d/networking restart |
| Restart the X server. | sudo /etc/init.d/?dm restart |
| Run a command with low priority. | nice commandname |
| Save kernel messages shown while booting to .txt file. | dmesg > filename.txt |
| Shut down the computer. | shutdown -h now |
| Sniff the network. | ethereal |
| Sort files numerically. | sort -n |
| Start the X server. | /etc/init.d/?dm start |
| Stop the X server. | sudo /etc/init.d/?dm stop |
| Time a command. | time commandname |
| Update the locate database. | sudo updatedb |
| Upgrade a package. | dpkg -i packagename |
Obligatory Happy Ending
And they all lived happily ever after. The end.
