Little Girl's Mostly Linux Blog

CommonCommands

Common Commands

This page was last updated on October 12, 2013.

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.

Also note that any command with sudo in it requires your password.

TASK COMMAND
Add a message to the System Log (/var/log/sys.log). logger your message here
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. sudo dmidecode
Display configuration file for file system mounting. cat /etc/fstab
Display CPU information. cat /proc/cpuinfo
Display CPU load, swapping, and I/O. vmstat
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 2013
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. ksysguard
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/kern.log
Display last few lines of system log dynamically. tail -f /var/log/syslog
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 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. sudo blkid
Identify my video card. lspci -nn | grep VGA
List all usb devices. lsusb
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 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 hostname
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 service network-manager restart
Restart the X server (also accepts gdm and kdm). sudo restart lightdm
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
Sort files numerically. sort -n
Start the X server. startx -- :1
Stop the X server (also accepts gdm and kdm). sudo service lightdm 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.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Comment:

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: