!?CF? = Run previous command containing the CF string
!129 *doc = Append *doc to command 129 from history
!99 = Run command number 99 from history
!ls = Run the previous ls command
!ls:s/CF/l = Run previous ls command, replacing CF with l
ls -la = Display files/directories beginning with dot (.)
ps auwx | mail -s ‘Process List’ james@sitename.com = A list of currently running processes is sent to the same user with subject of ‘Process List’.
sudo exportfs -rv = Verbose reload of exported shares
/etc/init.d/ntp = Show usage statement (with no options)
> /tmp/newfile2.txt = Create a blank file
alsamixer = Show alsamixer screen with playback view
alsamixer -c 1 = Use alsamixer on second (1) sound card
alsamixer -V all = Show with playback and capture views
alsamixer -V playback = Show only playback channels (default)
apropos umount = Search the man page descriptions for instances of a keyword
apt-cache depends = Print dependencies for a package (whether it’s installed or not).
apt-cache depends picasa = Shows dependencies for Picasa
apt-cache pkgnames = List all packages installed on the system.
apt-cache search
apt-cache search picasa = Search for a package called Picasa
apt-cache search umount = Search the cached list of packages that may contain a command or description of umount.
apt-cache show
apt-cache show picasa = Show information on Picasa
apt-cache stats = Print statistics on all packages installed.
apt-cache stats = Total numer of packages available
apt-config -V = Print version information of installed APT utilities.
aptitude help = Lists help for aptitude usage.
aptitude search
aptitude show
arp -v = List ARP cache entries by name
arp -vn = List ARP cache entries by IP address
arping 10.0.0.23 = Query subnet to see if 10.0.0.23 is in use
arping -c 2 10.0.0.51 = Query 10.0.0.50 and stop after 2 counts
arping -f 10.0.0.50 = Query 10.0.0.50 and stop at the first reply
at 08/22/08 = Start a command at current time on August 22, 2008
at now +3 min = Start command running in three minutes
at now +7 days = Start a command in 7 days
at teatime = Start command at 4pm today
atq = Display que of at jobs
atrm 15 = Delete at job number 15
aumix = With no options, aumix runs screen-oriented
aumix -l q -m q = List current settings for line and mic only
aumix -m 70 -m R -m q = Set mic to 70%, set it to record, list mic
aumix -q = Show left/right volume and type for all channels
aumix -v 80 -m 0 = Set volume to 70% and microphone to 0
cal = Show current month's calendar
cal 2011 = Show whole year’s calendar
cal -j = Show Julian calendar (numbered from January 1)
cat /bin/ls | strings = List all ASCII text in ls
cat /proc/cpuinfo = View CPU details
cat -b myfile.txt = Show line numbers only on non-blank lines
cat md5sum.txt | grep Release.gpg |md5sum -c = Verify one particular file listed in md5sum.txt file
cat mp3list | mpg321 -@ - = Pipe playlist to mpg321
cat myfile.txt | head = View top of a file
cat myfile.txt | less = Page through the contents of a file
cat myfile.txt | sed s/john/john/ = Replace only the first occurrence of john in each line with john
cat myfile.txt = Send entire file to the screen
cat myfile.txt > copy.txt = Direct file contents to another file
cat myfile.txt >> myotherfile.txt = Append file contents to another file
cat -n myfile.txt = Show line numbers with output
cat -s myfile.txt = Display consecutive blank lines as one
cd - = Change to previous working directory
cd $HOME = Change to your home directory
cd $OLDPWD = Change to previous working directory
cd .. Change to parent of current directory
cd /home/ch
cd /usr/bin = Change to usr/bin from root directory
cd ~ = Change to your home directory
cd ~/public_html = Change to public_html in your home directory
cd ~john = Change to john’ home directory
cd ~jo
cd = Change to your home directory
cd usr/bin = Change to usr/bin beneath current directory
cdparanoia -- “1:[40]-” = Rip tracks 1 from 40 secs in to end of the CD
cdparanoia -- “33-83” abc.wav = Rip tracks 33-83 to one file (abc.wav)
cdparanoia -a -- “52” = Rip track 52 and save to AIFC format
cdparanoia -B -- “54-74” = Rip tracks 54-74 into separate files
cdparanoia -B = Rip tracks as WAV files by track name
cdparanoia -f -- “34” = Rip track 34 and save to AIFF format
cdparanoia -vsQ = Checking CD drive for SCSI, MMC, CDDA support for copying files from CD to hard drive
cdparanoia -w -- “11” my.wav = Rip track 11 and name it my.wav
chgrp market test/ = Change group to market
chown john test/ = Change owner to john
chown john:market test/ = Change owner to john and group to market
chown -R john test/= Change all files below test/ to owner john
chsh -s /bin/sh = Change current user’s shell to /bin/sh
convert -charcoal 5 house.jpg char-house.png = Colorise image file
convert -colorize 175 house.jpg color-house.png = Colorise image file
convert icon.gif icon.bmp = Convert a GIF to a BMP file
convert photo.tiff photo.pcx = Convert a TIFF to a PCX file
convert -resize 1024x768 hat.jpg hat-sm.jpg = Convert image file
convert -rotate 220 sky.jpg sky-final.jpg = Rotate image 220 degrees
convert -rotate 15 house.jpg house-final.jpg = Rotate image 15 degrees
convert -sample 50%x50% dog.jpg dog-half.jpg = Convert image file
convert -sepia-tone 75% house.jpg oldhouse.png = Colorise image file
convert -swirl 300 photo.pcx weird.pcx = Swirl image file
convert -thumbnail 120x120 a.jpg a-a.png = Create a thumbnail
convert -thumbnail 120x120 -border 8 a.jpg a-b.png = Create thumbnail with a border
convert -thumbnail 120x120 -border 8 -rotate 8 a.jpg a-c.png = Create and rotate thumbnal with border
convert space.jpg space.png = Convert a JPEG to a PNG file
crontab -e = Create a personal crontab file
crontab -eu john = Edit another user’s crontab (root only)
crontab -l = List contents of your crontab file
crontab -r = Delete your crontab file
date ‘+%A %B %d %G’ = Display day, month, day of month, year
date ‘+The date today is %F.’ = Add words to the date output
date = Display current date, time and time zone
date --date=’3 May’ +%A = Display day on which May 4 falls Wednesday
date --date=’6 weeks’ = Display date 6 weeks from today
date --date=’7 months 8 days’ = Display date 7 months 8 days from today
debsums = This command will check every file on the system against the stock md5sum files.
df -h = Display space on file systems in human-readable form
df -hi = Add inode info
df -hl = Display space for local file systems only
df -hT = Display file system type with space
diff file1.txt file2.txt = Show difference between two files
dig +short www.yahoo.com = Display only name/IP address pair
dig +trace www.yahoo.com = Recursively trace DNS servers
dig yahoo.com mx = Queries for the mail exchanger
dig yahoo.com ns = Queries for the authoritative name servers
dig www.yahoo.com @4.2.2.1 = Query DNS server at 4.2.2.1
dig -x 66.113.99.70 = Get DNS information based on IP address
disown %3 = Disconnect job %3 from current shell
disown -a = Disconnect all jobs from current shell
disown -h = Protect all jobs from HUP sent to current shell
dmesg | grep “[ ]ata\|^ata” = Show ata kernel device information
dpkg -L initscripts = List all the files contained in the initscripts package
dpkg-query -S umount = Search the list of installed packages for the filename umount, revealing the package it is in.
dstat -t -c 3 = View CPU usage continuously with time stamps
du -h /home/ = Show disk space usage for /home directory
du -sh /home/john = Display disk use for another user as root
echo $HISTFILE $HISTSIZE $HISTFILESIZE =
echo $PA
echo $PATH = Show the current PATH
echo john | tr ‘[:lower:]’ ‘[:upper:]’ = Translate john into john
echo john | tr a-z A-Z = Translate john into john
elinks www.yahoo.com = Opens file name or URL you request
ethtool -h | less = View options to the ethtool command
fc = Edit the previous command, then run it
fc 999 = Edit command number 999, then run it
fc -e /usr/bin/nano 999 = Use nano to edit command 999
find / ! -group root -type f -print 2> /dev/null | xargs ls -l = Find files that are not owned by group root, exclamation mark means not
find /home/john/ -atime +66 = Find files that have not been accessed in /home/john for more 66 days
find /sbin/ -perm 750 -print = Find files is sbin directory with permission 750
find /sbin/ -type f ! -perm /o+w -print | xargs ls -l = Find files that are not writable by others
find /usr -name umount = Search the /usr file system for a filename or directory named umount.
find /var -user john -exec ls -l {} \;= Find files owned by user john in var directory and executes ls -l commandon it
find /var -user john -print | xargs ls -l = Find files owned by user john in var directory and executes ls -l commandon it
finger -l john = User information (long)
finger -s john = User information (short)
flac -8 top.wav -o top.flac = Raises compression level to 8
flac now.aiff -o now2.flac = Encodes AIFF to FLAC (now.flac)
flac now.wav = Encodes WAV to FLAC (now.flac)
free = List memory usage in kilobytes (-k default)
free -b = List memory usage in blocks
free -g = List memory usage in gigabytes
free -m = List memory usage in megabytes
free -mt = List memory usage with totals displayed (Swap + Mem)
free -s 5 = Continuously display memory usage every 5 seconds
from the /etc/passwd file
fuser /boot = Show parent PIDs for processes opening /boot
fuser -l = List supported signals
fuser -m /boot = Show all PIDs for processes opening /boot
fuser -mauv /boot = Verbose output of processes with /boot open
fuser -u /boot = Show PIDs/user for this shell open in /boot
gnome-terminal --geometry 90x33 = Start terminal 90 characters by 33 lines
gnome-terminal --tab --tab --tab = Start a terminal with three open tabs
gnome-terminal -x alsamixer = Start terminal with alsamixer displayed
gnome-terminal --zoom=2 = Start terminal with larger font
grep 192.123.13.1 /var/log/httpd/access-log | wc -l = Lists how many entries in Apache log come from a specific IP address/webpage
grep 404 /var/log/httpd/access_log = Show lines containing 404
grep --color -Rn VirtualHost /etc/httpd/conf* = Colorise the term VirtualHost
grep john myfile.txt = Show lines containing john
grep -i selinux /var/log/messages = Search file for the term selinux not case sensitive
grep -R VirtualHost /etc/httpd/conf* = Search for the term VirtualHost in /etc/httpd/conf and /etc/httpd/conf.d directories
grep -Rl VirtualHost /etc/httpd/conf* = Display only the names of the files that contain the term VirtualHost
grep -Rn VirtualHost /etc/httpd/conf* = Locate line numbers where the term VirtualHost occurs
grep -v “ 400 “ /var/log/httpd/access_log* = Show lines without “ 420 “
groups john = List the groups that a user belongs to
head -15 myfile.txt = Show the first 15 lines of a file
head myfile.txt = View top of a file
head -n 15 myfile.txt = Show the first 15 lines of a file
history 15 = List last 15 commands in history
host 13.173.93.70 = Reverse DNS lookup
hostname = View the local computer’s full DNS host name
hwclock -r = Display current hardware clock settings
hwclock --systohc = Reset hardware clock from system clock
identify home.jpg = Information about image
identify -verbose home.jpg | less = Information about image
ifconfig = Check network interface status
ifconfig -a = Show all connections
ifconfig eth0 = Display the address information and status of eth0 Ethernet interface
info ls = The previous command shows information on the ls command
iostat -c 30 = Display CPU stats every 30 seconds
iostat -c -t = Print time stamp with CPU report
iostat -c -t 20 10 = Repeat every 20 seconds for 10 times
ip addr help = View help for the addr object
ip addr show eth0 = Info about etho NIC
ip help = View ip usage statement
ip r = Display basic routing
ip route = Check defualt gateway
ip route = Display basic routing
ip route help = View help for the route object
ip route show = Display basic routing information
ip tunnel help = View help for the tunnel object
ipcalc -bmn 192.55.16.100/27 = calculate a host computer’s netmask from its CIDR IP address
iwconfig = Search for wireless cards
jobs = Display background jobs for current shell
jobs -l %2 = Display information only for job %2
jobs -l = Display PID with each job’s information
kill %3 = Kill the process represented by job %3
kill 888 = Send SIGTERM to process with PID 888
kill -9 444 = Send SIGKILL to process with PID 444
kill -SIGCONT 555 = Continue a stopped process (pid 555)
killall -SIGHUP sendmail = Have sendmail processes reread config files
killall spamd = Kill all spamd daemons currently running
last = List the most recent successful logins
less file.txt = Page through a text file
lftp john@site.com = Authenticated connection
lftp mirrors.kernel.org = Anonymous connection
lftp Start = lftp with no connection
lftp -u john example.com = Authenticated connection
lftp -u john,Mypwd example.com = Authentication with password
ln myfile myfile-hardlink = Create hard link
ln -s myfile myfile-symlink = Create symbolic link
locate mount = Use the locate command to search its list of (configurable) directories for mount
ls | tr ‘\n’ ‘ ‘ = Replace newline characters with spaces
ls | tr -d ‘\n’ = Delete new lines (resulting in one line)
ls -C = Show files listing in columns
ls --color = always = Show file types as different colors
ls -F = Add a character to indicate file type
ls -l Files and directories in current directory
ls -lh = List file sizes in human-readable form (K, M, etc.)
ls -li = Lists the inode associated with each file
ls -ln = List numeric user/group IDs, instead of names
ls -lR = List files recursively, from current directory and subdirectories
ls -lS = Orders files by size
ls -lt = Orders files by time recently changed
ls -lu = Orders files by time recently accessed
lsmod = Display all loaded modules
lsof /mnt/sda1 = List anything open on /mnt/sda1 file system
lsof | less = List processes holding files and directories open
lsof +d /mnt/sda1/dx = List anything open under /mnt/sda1/dx directory
lsof -c bash = List files open by bash shells
lsof -d cwd = List directories open as current working directory
lsof -u john = List files and directories open by user john
lspci | grep -i wireless = Search for wireless PCI cards
lspci = List PCI hardware items
lspci -v = List PCI hardware items with more details
lspci -vv List PCI hardware items with even more details
mail -s ‘My Linux version’ john@example.com < /etc/lsb-release = Sends the contents of the /etc/lsb-release file to the user john@example.com. The subject (-s) is set to ‘My Linux Version’.
man 5 crontab = Shows the section 5 man page for crontab
man 8 umount = View section 8 of the man page for umount
man –a crontab = Shows all man page sections, in succession, for crontab
man crontab –P more = Uses the pager program more for paging through the crontab man page
man –f crontab = Equivalent to the whatis command
man –k crontab = Equivalent to the apropos command
md5sum -c md5sum.txt = Verify all the files listed in the current directory and listed in md5sum.txt file contained in the current directory
md5sum whatever.iso = Verify file
message and attaches the file /etc/lsb-release
method for updating a system.
minicom -s = Create your modem settings
mkdir /tmp/new = Create “new” directory in /tmp
mkdir -m 700 /tmp/new2 = Create new2 with drwx — — — permissions
mkdir -p /tmp/a/b/c/new = Create parent directories as needed for “new”
modinfo snd_ens1371 = Info about partcular module
modprobe -l | grep c-qcam = List all modules, then look for c-qcam
more myfile.txt = Page through the contents of a file
mount = List mounted file systems remote and local
mount -t ext2 = List mounted ext2 file systems
mount -t ext2 -l = List mounted ext2 file systems with labels
mpg321 -@ mp3list = Play songs from playlist of MP3s
mpg321 yoursong.mp3 = Play MP3 file
mpg321 -z *.mp3 = Play files in pseudo-random order
mpg321 -Z *.mp3 = Same as -z, but repeat forever
mutt -s “My Linux Version” -a /etc/lsb-release \john@example.com < email-body.txt = Sends the file email-body.txt as the body of the
mutt= Begin mutt session
netstat -i = Get network interface statistics for eth0
netstat -ic = Refresh network statistics every second
netstat -s | less = Show summary of TCP, ICMP, UDP activities
nice = Run nice to determine current niceness
nice -n 12 nroff -man a.roff | less = Format man pages at low priority
nohup nice -9 gcc hello.c & = Run gcc uninterrupted and higher priority
nohup updatedb & = Run updatedb with no ability to interrupt
ogg123 /usr/share/example-content/ubuntu\ Sax.ogg = Play example file
ogg123 /var/music/ = Play songs in /var/music and sub dirs
ogg123 -@ myplaylist = Play songs from playlist
ogg123 http://vorbis.com/music/Lumme-Badloop.ogg = Play web address
ogg123 mysong.ogg = Play ogg file
ogg123 -z *.ogg = Play files in pseudo-random order
oggenc ab.flac -o new.ogg = Encodes FLAC to Ogg (new.ogg)
oggenc ab.wav = Encodes WAV to Ogg (ab.ogg)
oggenc ab.wav -q 9 = Raises encoding quality to 9
pgrep init = Show PID for any process including ‘init’ string
pgrep -l init = Show PID and name for any process including ‘init’ string
pgrep -lu john = List all processes owned by user john
ping
ping 10.0.0.1 = Check availabiity of ip address
ping -a 10.0.0.1 = Add an audible ping as ping progresses
ping -c 4 10.0.0.1 = Ping 4 times and exit (default in Windows)
ping -i 3 10.0.0.1 = Send packets in 3-second intervals
ping -q -c 5 10.0.0.1 =Show summary of pings (works best with -c)
ping -s 1500 10.0.0.1 = Set packet size to 1500 bytes
play *.wav = Play all WAV files in directory (up to 32)
play hi.au vol .6 = AU file, lower volume (can lower distortion)
play inconceivable.wav = Play WAV file (may be ripped from CD)
play -r 14000 short.aiff = AIFF, sampling rate of 14000 hertz
ps = List all processes running
ps auwwx = Show every running process, long BSD style, unlimited width
ps auwx | grep “\[*\]” = Show bracketed commands
ps auwx | grep init = Show init lines from ps output
ps auwx | head -15 = Show the first 15 lines of ps output
ps auwx | head n -15 = Show the first 15 lines of ps output
ps auwx | less = Page through the output of ps
ps auwx | more = Page through the output of ps (press spacebar)
ps auwx | tail -n 15 = Display the last 15 lines of ps output
ps auwx = Show every running process, long BSD style, wide format
ps aux = Show every running process, long BSD style
ps ax = Show every running process, short BSD style
ps axjf = Show process hierarchy in BSD-style output
ps -C httpd = Display running httpd processes
ps -e = Show every running process
ps -eF = Show every running process, extra full-format listing
ps -ef = Show every running process, full-format listing
ps -ef --forest = Show process hierarchy in forest format
ps -ejH = Show process hierarchy with process/session IDs
ps -el = Show every running process, long listing
ps -eo ppid,user,%mem,size,vsize,comm --sort=-size = Sort by mem use
ps -eo ppid,user,bsdstart,bsdtime,%cpu,args --sort=-%cpu = Sort by CPU use
ps -eo ppid,user,nice,cputime,args --sort=-nice = Sort by low priority
ps -eo ppid,user,stat,tname,sess,cputime,args --sort=user = Sort by user
ps -fp $(pgrep nautilus) = Search for nautilus and run ps (full)
ps -fu john = Show all processes run by user john with process ID
ps -Fu john = Show all processes run by user john with SZ and PSR
ps -p `pgrep metacity`= Search for metacity and run ps (short)
ps -p 5413 -o pid,ppid,bsdtime,args = Display info for PID 5413
ps -u john = Show all processes run by user john
ps -u john u = Show all processes run by user john with cpu and memory usage
ps -U john,john -o pid,ruser,tty,stat,args = See info for 2 users
pstree = Show processes alphabetically in tree format
pwd = Print current working directory
renice +2 -u john = Renice john’ processes +2
renice +5 433 = Renice PID 433 by +5
route = Display local routing table information
route -n = Display routing table without DNS lookup
runlevel = Display current and previous run levels
scp myfile john@server1:/tmp/= Copy myfile to server1
scp -P 1333 myfile server1:/tmp/ = Connect to a particular port
scp -p myfile server1:/tmp/ = Preserve permissions and timestamps on the copied files
scp -r mydir john@server1:/tmp/ = Copies all mydir to remote /tmp
scp server1:/tmp/myfile . = Copy remote myfile to local working dir
sdo apt-get remove packagename = Uninstall package
sed ‘s/\/home\/bob/\/home2\/bob/g’ < /etc/passwd = Replaces the first occurrences of the text /home/bob to /home2/bob
sed ‘s-/home/bob/-/home2/bob/-’ < /etc/passwd = Replaces the first occurrences of the text /home/bob to /home2/bob
sed ‘sD/home/bob/D/home2/bob/D’ < /etc/passwd = Replaces the first occurrences of the text /home/bob to /home2/bob
sed -e s/john/john/g -e s/john/john/g < myfile.txt = All occurrences of john are changed to john and occurrences of john are changed to john
sed s/3/TREE/ < f1.txt > f2.txt = Change 4 to FOUR and send to f2.txt
sed s/john/john/g < myfile.txt > mynewfile.txt = Replace all occurrences of john in file with john and redirect the output to file mynewfile.txt
seq 1 7 > f1.txt = Send a sequence of numbers to f1.txt
setserial -a /dev/ttyS0 = View serial port details
setserial -g /dev/ttyS0 /dev/ttyS1 /dev/ttyS2 /dev/ttyS3 = See port info
setserial -ga /dev/ttyS0 /dev/ttyS1 = Check multiple port details
sha1sum whatever.iso = Verify file
slabtop = Display kernel slab memory cache information in a screen-oriented view
sox head.wav tail.wav output.wav = Concatenat two files into one single output file
sox now.wav now.aiff = Encodes WAV to AIFF (now.aiff)
sox sound1.wav output.wav trim 1 9 = Keep from 1-9 seconds of file
sox sound1.wav output.wav trim 34 = Trim 34 seconds from start
soxmix head.wav tail.wav output.wav = Mix two files into one single file
strings /bin/ls | grep -i libc = Find occurrences of libc in ls
strings /bin/ls = List all ASCII text in ls
stty -F /dev/ttyS0 -a = View tty settings for serial port
sudo /etc/init.d/networking restart = Shutdown and bring up network interfaces
sudo /etc/init.d/nfs-kernel-server reload = Reload exported shared directories
sudo /etc/init.d/ntp force-reload = Reload settings in config file
sudo /etc/init.d/ntp restart = Restart NTP service (first off, then on)
sudo /etc/init.d/ntp start = Start Samba service immediately
sudo /etc/init.d/ntp status = Check if the NTP service is running (smbd)
sudo /etc/init.d/ntp stop = Stop NTP service
sudo /etc/init.d/ntp try-restart = Restart NTP service (if already running)
sudo /usr/sbin/exportfs -v = Show all shared directories
sudo apt-get autoclean = Can be run anytime to delete partially downloaded packages, or packages no longer installed.
sudo apt-get clean = Removes all cached packages from /var/cache/apt/archives to free up disk space.
sudo apt-get -d install
sudo apt-get dist-upgrade = Updates the entire system to a new release, even if it means removing packages. Note: This is not the preferred
sudo apt-get -f install = Do a sanity check for broken packages. This tries to fix any “unmet dependency” messages.
sudo apt-get install
sudo apt-get install packagename = Install package you want
sudo apt-get --purge remove
sudo apt-get update = Consults /etc/apt/sources.list and updates the database of available packages. Be sure to run this command
sudo apt-get update = Refresh the list of cached packages
sudo apt-get update packagename = Update to new version of the package
sudo apt-get upgrade = Check updates for all installed packages and then prompt to download and install them.
sudo apt-get upgrade pakagename = Upgrade before updating a package
sudo aptitude = Starts the curses interface. Use Ctrl+t to access the menu and the q key to quit.
sudo aptitude autoclean = Removes all outdated .deb files from the /var/cache/apt/archives directory. This maintains a current cache without filling up the disk.
sudo aptitude clean = Removes all downloaded .deb files from the /var/cache/apt/archives directory.
sudo aptitude dist-upgrade = Upgrades all packages to their most recent versions, removing or installing packages as necessary. The upgrade option is advised over dist-upgrade.
sudo aptitude download
sudo aptitude install
sudo aptitude remove
sudo aptitude update = Updates the available package indexes from the APT sources.
sudo aptitude upgrade = Upgrades all packages in use to their latest versions.
sudo apt-key list = List gpg keys that APT knows about.
sudo arp -d 10.0.0.50 = Delete address 10.0.0.50 from ARP cache
sudo arp -s 10.0.0.51 00:0B:6A:02:EC:95 = Add IP and MAC addresses to ARP
sudo arping -I eth0 10.0.0.50 = Specify interface to query from
sudo badblocks /dev/sda1 = Physically scan hard disk for bad blocks
sudo badblocks -v /dev/sda1 = Add verbosity to hard disk scan
sudo badblocks -vsn /dev/sda1 = Check bad blocks, non-destructive
sudo badblocks -vsw /dev/sda1 = Check bad blocks, destructive, could erase all data on a partition
sudo cat /var/log/messages* | less = Page through /var/log/messages
sudo chage -d 5 perry = Force user’s password to expire in 5 days
sudo chage -I 40 frank = Make account inactive in 40 days
sudo chage -l vern = View password expiration information
sudo chmod -R 000 /tmp/test = Close all permissions below /tmp/test
sudo chmod -R 700 /tmp/test = Open permission only to owner below /tmp/test
sudo chmod -R a+rwx /tmp/test = Open all permissions to all below /tmp/test
sudo chsh -s /bin/sh john = Change a user’s shell to /bin/sh
sudo cp /usr/share/zoneinfo/America/Chicago /etc/localtime = Change current time zone to that of America/Chicago
sudo date 081215212008 = Set date/time to Aug. 12, 2:21PM, 2008
sudo date --set=’+7 minutes’ = Set time to 7 minutes later
sudo date --set=’-1 month’ = Set date/time to one month earlier
sudo dd if=/dev/hda1 of=/dev/hdb2 = Clones the first partition of the primary master IDE drive to the second partition of the primary slave IDE drive
sudo dmidecode | less = List hardware components
sudo du -h --max-depth=1 /home = Display disk space one level below /home
sudo du -h --max-depth=1 /home = Display disk space two levels below /home
sudo du -sch /home /var = Show multiple directory and total summaries
sudo du -sh --exclude=’*.iso’ /home/john = Exclude ISO images from disk space
sudo e2label /dev/sda2 = Dispay lable of partition
sudo e2label /dev/sda2 mypartition = Change label of partition
sudo eject /dev/cdrom = Unmount and eject a CD
sudo ethtool eth0 = See settings for NIC at eth0
sudo ethtool -i eth0 = Display driver information for NIC
sudo ethtool -S eth0 = Show statistics for NIC at eth0
sudo ethtool -s eth0 speed 10 duplex half autoneg off = Turn off auto-negotiation and hard-set the speed to 10 Mpbs, half-duplex
sudo exportfs -r = Reload exported shared directories
sudo fdisk /dev/sda = Start interactive fdisk session with disk 1
sudo fdisk -l /dev/sdb = List disk partitions for a specific disk
sudo fdisk -l = List disk partitions for every disk
sudo fuser -k /boot = Kill all processes with /boot files open (SIGKILL)
sudo groupadd -g 1701 sales = Create new group with GID of 1701
sudo groupadd marketing = Create new group with next available GID
sudo groupadd -o -g 74 mysshd = Create group with existing GID
sudo groupdel myad = Remove existing myad group
sudo groupmod -g 491 myadmin = Modify myadmin to use GID 491
sudo groupmod -n myad myadmin = Change name of myadmin group to myad
sudo halt -h = Put hard drives in standby mode before halting
sudo halt -n = Don’t run sync to sync hard drives before shutdown
sudo hdparm /dev/hda = Display hard disk settings (IDE drive)
sudo hdparm /dev/sda = Display hard disk settings (SATA or SCSI drive)
sudo hdparm –I /dev/sda = Display detailed drive information
sudo hwclock --adjust = Adjust hardware clock time for drift
sudo hwclock --hctosys = Reset system clock from hardware clock
sudo hwclock --set --date=”3/18/08 18:22:00” = Set clock to new date/time
sudo ifdown eth0 = Take the eth0 network interface offline
sudo ifup eth0 = Bring the eth0 network interface on
sudo init 5 = Change the current run level to 5 (X Desktop)
sudo init q = Start or stop changed processes in inittab file
sudo ip r add 192.168.0.0/24 via 10.0.0.100 = Add route no interface
sudo ip r add 192.168.0.0/24 via 10.0.0.100 dev eth0 = Add route to interface
sudo ip r del 192.168.0.0/24 = Delete route
sudo iptables -F = Flush all iptables rules
sudo iptables -L = Current rules for firewall
sudo iptables -L --line-numbers = Show line number in chain for each rule
sudo iptables -n -L = Filter rules, IP numbers (no DNS lookup)
sudo iptables -nvL --line-numbers = Our tech editor’s favorite combination
sudo iptables -t nat -L = Display current iptables nat table
sudo iptables -v -L = Verbose output (with packet/byte counts)
sudo iwconfig wlan0 ap any = Use any access point available
sudo iwconfig wlan0 channel 3 = Set the channel to 3
sudo iwconfig wlan0 essid “MyWireless” = Set essid to MyWireless
sudo iwconfig wlan0 key 1234-5555-66 = Set encryption key to 1234-5555-66
sudo iwconfig wlan0 mode Ad-Hoc = Change from Managed to Ad-Hoc mode
sudo iwconfig wlan0 retry 20 = Set MAC retransmissions to 20
sudo iwconfig wlan0 sens -50 = Set sensitivity to –50
sudo lastb = List the most recent unsuccessful logins
sudo ln –s /usr/share/zoneinfo/America/Chicago /etc/localtime = Change current time zone to that of America/Chicago via symlink
sudo lsof | grep mymount = Find open files on mymount partition
sudo mii-tool -F 10baseT-FD eth0 = Force speed/duplex to 10baseT-FD
sudo mii-tool -r eth0 = Re-enable auto-negotiation for an old NIC
sudo mii-tool -v = Show verbose output of settings for old NIC
sudo mkfs -t ext3 /dev/sdb1 = Create ext3 file system on sba1
sudo mkfs -t ext3 -v -c /dev/sdb1 = More verbose and scan for bad blocks
sudo mkfs.ext3 -c /dev/sdb1 = Same result as previous command
sudo mkswap /dev/sda1 = Format sda1 as a swap partition
sudo mkswap -c /dev/sda1 = Check swap area for bad blocks
sudo modprobe c-qcam = Load module for Color QuickCam
sudo modprobe -r c-qcam = Remove module for Color QuickCam
sudo mount -t ext3 /dev/sda1 /mnt/mymount/= Mount a et3 type local file system on /mnt/mymount
sudo mount /dev/sda1 /mnt/mymount/ = Mount a local file system on /mnt/mymount
sudo mount -v --move /mnt/mymount/ /tmp/mydir/ = Move a file system from one point to another
sudo mount -v -t ext3 -o ro /dev/sda1 /mnt/mymount/= Mount read only
sudo mount -v -t ext3 -o rw /dev/sda1 /mnt/mymount/ Mount read/write = Mount write only
sudo netstat -tanp | grep -i listen = View daemons listening to a port
sudo netstat -tanp = View active TCP connections
sudo netstat -uanp = View active UDP connections
sudo nice -n -10 gimp = Launch gimp at higher priority
sudo nmap 10.0.0.1 = Scan ports on computer at 10.0.0.1
sudo nmap -vv 10.0.0.1 = Show maximum verbosity from nmap output
sudo nmap -vv -P0 -O -p 100-200 10.0.0.1 = No ping, OS fingerprint, ports 100-200
sudo nmap -vv –sP 10.0.0.0/24 = Scan hosts on an entire network
sudo passwd -i 14 vern = Days after expiration account is disabled
sudo passwd john = Add password for user john
sudo passwd -l john = Lock the user account (john)
sudo passwd -n 2 vern = Set minimum password life to 2 days
sudo passwd -u john = Unlock a locked user account (john)
sudo passwd -w 10 vern = Warn of password expiration 10 days in advance
sudo passwd -x 300 vern = Set maximum password life to 300 days
sudo ping -f 10.0.0.1 = Send a flood of pings (must be root)
sudo ping -I 10.0.0.155 10.0.0.1 = Set source to 10.0.0.155
sudo ping -I eth0 10.0.0.1 = Set source to eth0 (use if multiple NICs)
sudo reboot = Reboot the computer
sudo renice -3 `pgrep -u john spamd` = Renice john’ spamd processes –3
sudo route add default gw 10.0.0.2 = Add 10.0.0.2 as default gateway
sudo route add -net 192.168.0.0 netmask 255.255.255.0 eth0
sudo route add -net 192.168.0.0 netmask 255.255.255.0 gw 10.0.0.100
sudo route del -net 192.168.0.0 netmask 255.255.255.0 = Delete a route
sudo sfdisk /dev/sda < sda-table = Restore partition table from file
sudo sfdisk –d /dev/sda | sfdisk /dev/sdb = Copy partition table from disk to disk
sudo sfdisk –d /dev/sda > sda-table = Back up partition table to file
sudo shutdown 10 ‘Bye!’ = Send custom message to users before shutdown
sudo shutdown 10 = Shutdown in ten minutes after warning the users
sudo shutdown -r 10 = Reboot in ten minutes after warning the users
sudo swapoff -v /tmp/swapfile = swapoff on /tmp/swapfile
sudo swapon /dev/sda1 = Turn swap on for /dev/sda1 partition
sudo swapon -v /dev/sda1 = Increase verbosity as swap is turned on
sudo swapon -v /tmp/swapfile = Turn swap on for the /tmp/swapfile file
sudo swapon -v -p 1 /dev/sda1 = Assign top swap priority to sda1
sudo sysctl -a | less = List all kernel parameters
sudo sysctl kernel.hostname = List value of particular parameter
sudo sysctl -p = Load parms from /etc/sysctl.conf
sudo sysctl -w kernel.hostname=joe = Set value of kernel.hostname
sudo tail -f /var/log/messages = Watch cotents of a text file grow over time
sudo tcpdump | grep -v ssh = Find packets except those associated with ssh
sudo tune2fs -i 0 /dev/sda1 = Disable time-dependent checking
sudo tune2fs -i 12 /dev/sda1 = Check after 12 days
sudo tune2fs -i 11d /dev/sda1 = Check after 12 day
sudo tune2fs -i 9w /dev/sda1 = Check after 9 weeks
sudo tune2fs -i 3m /dev/sda1 = Check after 3 months
sudo umount -v /dev/sda1 = Unmount by device name
sudo umount -v /mnt/mymount/ = Unmount by mount point
sudo umount -vl /mnt/mymount/ = Perform a lazy unmount when te device is busy
sudo useradd billyq = Prevent creation of home directory, no -m
sudo useradd -c “John T. Watson” tlot = Add user’s full name to comment field
sudo useradd -D -b /home2 -s /bin/csh = Set default base dir and shell
sudo useradd -D -e 2020-01-01 = Set all new users to expire in 2020
sudo useradd -e 2020-08-01 jerry = Add account to expire August 01, 2020
sudo useradd -f 0 jdoe = Create a disabled account
sudo useradd -G support,sales timd = Add user to support and sales groups
sudo useradd -m -d /home/jj jones = Create /var/x/jj home directory
sudo useradd -m john = Add user named john
sudo useradd -s /bin/tcsh joeq = Assign a new default shell (tcsh); you must install this shell
sudo useradd -s /sbin/nologin billt = Keep user from shelling in
sudo useradd -u 1101 -g 1300 skolmes = Use specific UID and GID for user
sudo usermod -c “John Watts” tlot = Change user’s name in comment field
sudo usermod -L john = Lock the user account named john
sudo usermod -s /bin/sh joeq = Change default shell to sh
sudo usermod -U john = Unlock user account named john
sudo wvdial = Dial out and connect to your ISP
sudo wvdialconf /etc/wvdial.conf = Scan serial ports, create config file
sudo# renice -5 $(pgrep firefox) = Search for firefox, improve its priority
swapon -s = View all swap partitions that are on
tail -15 myfile.txt = Display the last 15 lines in a file
tail -f /var/log/httpd/access_log = Watch web server messages live
tail -f /var/log/maillog = Watch mail server messages live
tail -f /var/log/messages = Watch system messages live
tail -n 15 myfile.txt = Display the last 15 lines in a file
top = Display system uptime, tasks, CPU usage, and memory usage, followed by a list of running processes, sorted by CPU usage
top -b = Run in non-interative non-screen-oriented mode
top -d 50 = Change update delay to 50 seconds (from default 3)
top -n 5 = Refresh the screen 5 times before quitting
top -p 19,26 = Only display processes 19 and 26
top -u john = Only see processes of effective user name john
touch /tmp/newfilename.txt = Create a blank file
tr -d f < file.txt = Delete every letter f from the file
tr f F < file.txt = Replace every f in the file with F
tracepath boost.yahoo.com = Use UDP to trace the route
tracer
traceroute boost.yahoo.com = Follow the route taken to a host
traceroute -I boost.yahoo.com = Use ICMP packets to trace a route
traceroute -n boost.yahoo.com = Disable name resolution in trace
traceroute -p 25 boost.yahoo.com = Connect to port 25 in trace
uname -a = Display all available kernel info
uname -r = Display name of kernel release
unix2dos < myunixfile.txt > mydosfile.txt = Convert Unix file into DOS file
useradd -D = List default settings for useradd
userdel jimbo = Delete user, not user’s home directory
userdel -r john = Delete user, home directory, and mail spool
users = List who is currently logged in (short form)
vmstat 6 = Display memory use over a given time period (6 seconds)
vmstat -d = Display disk read, write, and input/output statistics
vmstat -m | less = Page through kernel slab memory cache
vmstat -n 2 15 = Output every two seconds, repeat 15 times
vmstat -p sda1 = Display read/write stats for a disk partition
vmstat -s | less = Display event counters and memory statistics
vmstat -S k = Display output in 1000-byte kilobytes
vmstat -S K = Display output in 1024-byte kilobytes
vmstat -S m = Display output in 1000k megabytes
vmstat -S M = Display output in 1024k megabytes
vmstat -S M -s | less = Display statistics in megabytes
watch ‘cat /proc/loadavg’ = Watch output of command every seconds
watch ‘ls –l mydownload.iso’ = Watch size of iso file as it downloads
watch -d ‘ls -l’ = Watch difference between outputs of same command
watch -n 10 ‘ls -l’ = Watch output of command every 10 seconds
watch netstat -i = Refresh network statistics (screen oriented)
wc /var/log/*.log = Counts number of lines, words, bytes for all .log files in /var/log directory
wc /var/log/dmesg = Counts number of lines, words, bytes in file
wget -c http://example.com/DVD.iso = Resume download where stopped
wget -E http://www.aspexamples.com = Append .html to downloaded files
wget ftp://user:password@ftp.example.com/path/to/file
wget http://example.com/DVD.iso = Begin downloading large file in one session
wget http://www.wiley.com = Download only the Web page
wget https://help.ubuntu.com/7.04/common/img/headerlogo.png = Download file from a server which does not require username or password
wget -m http://www.linuxtoys.net = Mirror an entire website
wget -mEkK http://www.linuxtoys.net = Make local copy of website
wget -p http://www.wiley.com = Download Web page and other elements
wget -pk http://www.wiley.com = Download pages and use local file names
wget -pkK http://www.wiley.com = Rename to local names, keep original
wget --user=user --password=password ftp://ftp.example.com/path/to/file = Supply username and password
whenever sources.list is changed.
whereis mount = Show where the first binary and man page are for the mount command
which mount = Find the first occurrence of the mount command in the PATH
who -u = List who is currently logged in (long form)