(linux)
commands

Note: This page was originally created for the commands of a generic UNIX system, I've since changed it to just Linux compatibility. That doesn't mean the commands listed will not work in a general UNIX environment. On the contrary, most will...but a few will not exist, be named slightly differently, or will have different options in that operating system.

Linux is case-sensitive. That means Eric is different from eric. For the most part enter everything in lowercase, but there are some exceptions.

commands and descriptions:
Commands are generally entered in this format: command -options argument(s). Options are similar to DOS switches like /? but instead of a slash require a hyphen instead. Some options may be used in combination with each other...example: ls -la.

fix this -
apt-get update - update list of packages
apt-get upgrade - upgrade installed packages
apt-get install <package>
apt-get remove <package>
apt-get dist-upgrade - upgrades system
apt-cache search <phrase>

adduser [username]
Begins the adduser wizard

alias
Displays aliases already set. Set an alias like so: alias ls='ls -F', temporarily or permanently with by adding to ~/.bashrc

apropos
[keyword]
Searches whatis database for commands that match search criteria. "man -k" provides this same functionality

bg [job#]
Resumes suspended job (ctrl-z) in the background. If a job is not specified then the current job is resumed.

cal
Displays current month and year
cal [month as # or ##] [year as ####]
Displays the particular month of the year that was specified.
cal [year as ####]
Displays the entire monthly calendar for that particular year.

cat [file] 
Concatenate files and display to standard output (screen)
Options:

cd [directory]
Change directory. Works like the DOS cd command
"cd" Takes you to your home directory when no arguments are given
"cd .." Takes you up one to the parent directory of your current location
"cd ../.." Takes you up two parent directories, etc
"cd -" Returns to previous directory
"cd ~" Takes you to home directory
"cd ~resinblade" Takes you to specified user's home directory
"cd ~resinblade/dirname" Takes you to specified directory in user's home directory

cfdisk
Curses based fdisk-like utility

chage [username]
Manages user accounts password aging
Options:

chattr +(or - or =)[attribute] [file/directory]
Changes file attributes specified files.
Attributes:
a = append-only
A = no access time updates
c = compressed (automatically uncompressed on access)
d= not backed up by dump command
i = immutable (file cannot be modified in any way)
s = secure deletion (file zeroed out upon deletion)
S = synchronous updates (files synced to disk when modified)
u = undeletable
Options:

chfn
Change finger information such as full name, office location, work/home phone#

chgrp [group] [file/directory]
Changes group ownership of files
Options:

chkconfig [service]
View and change service runlevel information
Options:

chmod [file] or [directory]
Change access mode. Changes file access permissions, default assumes all user types (a)
0 = none
1 = execute
2 = write
3 = write and execute
4 = read
5 = read and execute
6 = read and write
7 = read, write, and execute
Options:

chown [owner] [file/directory]
Changes owner of files. Can also be used as "chown [owner:group or owner.group] [file]" to change both owner and group
Options:

chpasswd
Changes user passwords in batch. Format: username:password

chsh

Changes your login shell
Options:

chvt #
Changes to virtual terminal specified

clear

Clears the screen and puts the prompt in the upper-left hand corner (like the DOS "cls" command)

cmp [file1] [file2]
Compares two files and notifies if differences are found

cp [source file]
[destination file/destination directory]
Copies files
Options:

crontab
Crontab management
Options:

cut [file]
Displays specified fields/columns of a file. The default delimiter is a tab
Options:

date
Displays the current date and time
Options:

df
Displays system's disk space usage
Options:

Filesystem            Size  Used Avail Use% Mounted on
/dev/hda6             981M  380M  551M  41% /
/dev/hda1              47M   12M   33M  26% /boot
/dev/hda9             9.7G  9.2G  450M  96% /home
/dev/hda7             1.5G   33M  1.4G   3% /tmp
/dev/hda10             21G   18G  1.8G  92% /usr
/dev/hda8             2.9G  556M  2.2G  20% /var

diff [file1] [file2]
Displays differences between files line-by-line
Options:

dmesg
Displays kernel boot messages pertaining to hardware

dpkg
(Debian's packaging system)
dpkg-reconfigure - change settings of an existing package
dselect - text based menu package management
alien - rpm2deb and deb2rpm conversions
Options:

du
Displays a summary of disk usage for each file and a total usage value, lists recursively from current location
Options:

dump
Filesystem backup utility
Options:

echo [content]
Used to echo a string to the screen. Using "echo *" displays all the files in current directory

eject [mount point or device]
Ejects removable media. If no mount point or device is specified then cdrom is assumed

env
Displays environment variables

exec [command]
Takes over current shell process and executes specified command. Closes out once finished.

exit

Exit current shell. If currently in login shell then exit will log you out of the session completely

expand [file]  <----fix this
Displays specified fields/columns of a file. The default delimiter is a tab.
Options:

fdisk [drive device] 
Used to alter disk partitions and display partition info
Options:

Useful commands (within fdisk):
d   delete a partition
l    list known partition types
n   add a new partition
p   print the partition table
t    change a partitions system id (filesystem type)
q   quit without saving changes
v   verify the partition table
w  write table to disk and exit

Command (m for help): p

Disk /dev/sda: 54.5 GB, 54596272128 bytes
255 heads, 63 sectors/track, 6637 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1           4       32098+  de  Dell Utility
/dev/sda2               5        6637    53279572+   5  Extended
/dev/sda5               5         258     2040223+  82  Linux swap / Solaris
/dev/sda6             259         264       48163+  83  Linux
/dev/sda7             265         391     1020096   83  Linux
/dev/sda8             392        1028     5116671   83  Linux
/dev/sda9            1029        4852    30716248+  83  Linux
/dev/sda10           4853        5043     1534176   83  Linux
/dev/sda11           5044        6637    12803773+  83  Linux

Command (m for help): l

 0  Empty                  1e  Hidden W95 FAT1    80  Old Minix                  be  Solaris boot
 1  FAT12                   24  NEC DOS                 81  Minix / old Lin           bf  Solaris
 2  XENIX root           39  Plan 9                      82  Linux swap / So       c1  DRDOS/sec (FAT-
 3  XENIX usr             3c  PartitionMagic          83  Linux                        c4  DRDOS/sec (FAT-
 4  FAT16 <32M         40  Venix 80286            84  OS/2 hidden C:        c6  DRDOS/sec (FAT-
 5  Extended              41  PPC PReP Boot        85  Linux extended       c7  Syrinx
 6  FAT16                   42  SFS                          86  NTFS volume set     da  Non-FS data
 7  HPFS/NTFS            4d  QNX4.x                    87  NTFS volume set     db  CP/M / CTOS / .
 8  AIX                        4e  QNX4.x 2nd part     88  Linux plaintext        de  Dell Utility
 9  AIX bootable         4f  QNX4.x 3rd part       8e  Linux LVM                df  BootIt
 a  OS/2 Boot Manag  50  OnTrack DM             93  Amoeba                  e1  DOS access
 b  W95 FAT32            51  OnTrack DM6 Aux    94  Amoeba BBT           e3  DOS R/O
 c  W95 FAT32 (LBA)   52  CP/M                        9f  BSD/OS                   e4  SpeedStor
 e  W95 FAT16 (LBA)   53  OnTrack DM6 Aux    a0  IBM Thinkpad hi     eb  BeOS fs
 f  W95 Ext'd (LBA)      54  OnTrackDM6            a5  FreeBSD                ee  EFI GPT
10  OPUS                     55  EZ-Drive                  a6  OpenBSD              ef  EFI (FAT-12/16/
11  Hidden FAT12        56  Golden Bow             a7  NeXTSTEP             f0  Linux/PA-RISC b
12  Compaq diagnost  5c  Priam Edisk              a8  Darwin UFS           f1  SpeedStor
14  Hidden FAT16 <3   61  SpeedStor               a9  NetBSD                 f4  SpeedStor
16  Hidden FAT16        63  GNU HURD or Sys     ab  Darwin boot         f2  DOS secondary
17  Hidden HPFS/NTF   64  Novell Netware        b7  BSDI fs                 fd  Linux raid auto
18  AST SmartSleep     65  Novell Netware        b8  BSDI swap            fe  LANstep
1b  Hidden W95 FAT3  70  DiskSecure Mult       bb  Boot Wizard hid    ff  BBT
1c  Hidden W95 FAT3   75  PC/IX

fg [job#]
Bring background job back to foreground. If no job is specified then the current job is brought to the foreground

file
[filename]
Attempts to determine filetype of specified file

find
[optional location]
Searches for files. Operators that can be used between expressions: ! = not, -a = and, -o = or
Options:

finger [user]
Displays user information
Login: resinblade                              Name: Eric
Directory: /home/resinblade             Shell: /bin/bash
On since Wed Aug 25 10:25 (EDT) on tty7 from :0
    7 hours 19 minutes idle
On since Wed Aug 25 10:27 (EDT) on pts/0 from :0.0
   20 minutes 54 seconds idle
On since Wed Aug 25 13:23 (EDT) on pts/1 from :0.0
On since Wed Aug 25 13:24 (EDT) on pts/2 from :0.0
   19 minutes 3 seconds idle
No mail.
No Plan.

free

Displays system memory usage
Options:

grep [pattern] [optional file]
Display results that match specified pattern
Options:

groupadd [group]
Creates specified group
Options:

groupdel [group]
Removes specified group

groupmod [group]
Alters group settings for specified group
Options:

groups
Lists groups that current user is a member of

grpck
Checks the integrity of the /etc/group files


gzip/gunzip 
[file/directory]
Compress files
Options:

halt
Shuts down the system

head [file]

Display first 10 lines of specified file
Options:

hdparm [drive device]
K <---Fix this
/dev/sda:
 IO_support    =  0 (default)
 readonly      =  0 (off)    
 readahead     = 256 (on)    
 geometry      = 4863/255/63, sectors = 78125000, start = 0

sectors * 512 = size of drive

Options:

history
Lists entire history of command line input
Stored by default in ~/.bash_history or possibly another file specified in the variable HISTFILE.
The size of the history file depends on these two variables - HISTFILESIZE and HISTSIZE.
HISTFILESIZE = max number of lines in history file
HISTSIZE = max number of commands remembered in history file.
Options:

hostname
Displays system hostname
Options:

iastlog
Displays last login time for all users. Pulls data from /var/log/lastlog
Options:

logger
Logs input to syslog

id

Displays real and effective UIDs and GIDs of current user

ifconfig
Displays status of network interfaces. "ifconfig eth0 | grep inet", displays just the line listing the IP address
Options:

[program name/command]
Displays info documentation for specified topic. CTRL-H will list the basic commands for info
q = quits info
TAB = cycle through nodes (links) on page
n = next node
p = previous node
ENTER = goto selected node
u = move up in hierarchy

init [runlevel]
Changes system to specified runlevel

jobs
Lists jobs running in the background


kbdconfig
(deprecated, was used in Red Hat)
Used to change keyboard mapping. Must be root to run. Located in /usr/sbin


kill [PID]
Terminates an open process. Default kill signal is TERM (15).
Kill signals:
1 - SIGHUP, used with daemons to issue a restart
9 - SIGKILL, forcibily kills a process
15 - SIGTERM, default kill method, asks a program to stop
-SIGSTOP, suspends a process
-SIGCONT, resumes a process
Options:

killall [process name]
Kills all instances of named process. Default kill signal is TERM (15).
Options:

last
Displays last users to login

ldd [executable path]

Display shared library dependencies for specifed program

less [text file]
Displays contents of a text file and allows scrolling throughout it. A text viewer that in my opinion is superior to "more". Running less as "less +F" will run it in follow mode (useful for lgo files)
up, down arrow keys = scrolling
h = display help
/string = search forward for specified string
?string = search backward for specified string
n = repeat last search
#G = go to specified line number
page down, spacebar = go forward one screen at a time
page up, b = go back one screen at a time
q = quit

ln [file/location] [new link]
Creates a hardlink by default (new name for the same file)
Options:

locate [search criteria]
Searches for files based on criteria. "updatedb" (requires root) must be ran for up-to-date results

look [string]

This command looks up words in a dictionary, useful for checking spelling. Entering "e" as the character would show all words in the dictionary that begin with the letter "e", and so on.

logout
Used to terminate login shells only

lpq

Displays printer queue status
Options:

lpr [file] or [file] [file] [file] <----several files at once
Prints file to default printer
Options:

lprm [print job ID]
Cancels specified print job. If no print job is specified then the current job on the default printer is canceled.
Options:

ls or ls [directory]
This command lists a directory's contents much like the DOS "dir" command.
Options:

lsattr [file]
Lists file attributes for specified file

lsof
Lists open files

md5sum [file] 
Computes and verifies MD5 checksums of files
Options:

mii-tool [ethernet interface] 
Outdated - replaced by ethtool.  Views and alters media-independent interfaces (ethernet cards)
Must be root to run
eth0: negotiated 100baseTx-FD flow-control, link ok
Options:

mkdir [directory]
This makes (creates) a empty directory

Options:

mkswap [device]
Sets up partition to be used as swap space

more [text file]
Similar to "less" but not as good...
enter = advance a line
space = advance a page

mount [device i.e. /dev/sda2]
[mount point i.e. /mnt]
Mounts storage devices on the system. Running with no arguments will display current mounts.

Options:

mouseconfig (deprecated, was used in Red Hat)
Used to change mouse configuration. Must be root to run. Located in /usr/sbin

mv [source file] [destination file/desination directory]
Renames (moves) a file.
Options:

netconfig (deprecated, was used in Red Hat)
Used to change TCP/IP network settings. Must be root to run. Located in /usr/sbin


netstat
Displays list of open sockets
Options:

newgrp [group]
Temporarily changes user's initial login group to specified group.
Options:

nl [file]
Numbers lines of specified file

nslookup [domain name]
Queries DNS servers and returns IP information


od
[file]
Dumps a file in octal format
Options:

passwd
Will change your password. It will ask you to enter your current password, then enter the new one twice.
Note on passwords: A password must be at least 6 alphanumeric characters long with a number being in one of those 6 characters (this isn't true in Linux, but isn't a bad idea at all). Always choose a password that is not a normal english word or something easily guessed. Make it as complex as possible, but within reason so you can remember it.
Options (root only):

paste [file1] [file2]
Merges contents of files
Options:

ping [destination]
Sends a ICMP ECHO_REQUEST to network host specified.
Options:

printenv
Displays the list of environment variables.
printenv [variable name]
This will display just that one variable.

ps

Displays a snapshot of currently running processes. Common ways to list all processes: ps -ef & ps auxwww
PID     TTY       TIME        CMD
30050 pts/0    00:00:00 bash
30122 pts/0    00:00:00 ps
Options:

Other output from -l:
PID=Process ID
PPID=Parent Process ID
PRI=Process priority 0=High, 127=Low
NI=Nice value -20=Greater chance of high priority, 19=Greater chance of low priority
ADDR=Memory address
WCHAN=What the process is waiting for while sleeping
SZ=Size of process in memory (in KB), approximately the size of the executable.

pstree
Displays process hierarchy in tree form

pwck
Checks the integrity of /etc/passwd and /etc/shadow files


pwd

Displays current directory you are in (print working directory)

reboot
Restarts the system

restore
Restores files from dump backups
Options:

rm [file]
This command removes (deletes) a file.
Options:

rmdir [directory]
Removes an empty directory

Options:

route
Displays routing table
Options:

rpm [package file]
Manages RPM packages.  rpm -Uvh is a common way of installing packages. rpm -qa | grep [package name] is a good method for checking if a package is already installed
Options:

runlevel
Displays previous and current runlevels

sed

Stream editor, used to manipulate text.
Options:

service [service name] start/restart/stop/status
Reports or manipulates service state. Requires superuser access.
Options:

set
Displays the list of environment variables


shutdown -[options]
[time (in minutes) or now] [optional warning message]
Shutdowns the system in various ways. Requires superuser access.
Options:

sort [file]
Sorts the contents of a file in ascending alphabetical/numerical order
Options: startx
This command launches the X-windows system (if it's installed)

stat [file]
C
File: `writing.txt'
Size: 414             Blocks: 4          IO Block: 4096   regular file
Device: 309h/777d       Inode: 808403      Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/resinblade)   Gid: (  500/resinblade)
Access: 2007-03-29 21:10:08.000000000 -0400
Modify: 2007-03-20 20:46:23.000000000 -0400
Change: 2007-05-04 08:22:01.000000000 -0400

File: "me_djy.avi"
ID: 0        Namelen: 255     Type: ext2/ext3
Block size: 1024       Fundamental block size: 1024
Blocks: Total: 10070256   Free: 175239     Available: 175239
Inodes: Total: 1280000    Free: 1228093

Options:

strings [file]
Displays any ASCII characters available in specified file.
Options:

su [optional username]
Substitute user that's currently logged with the user specified. If no user is specified then it's assumed to be root
Options:

sudo/sudo echo

suspend
Sends current job to the background

swapoff [device] 
Disables device for swapping
Options:

swapon [device] 
Enables device for swapping
Options:

tac [file]
Displays file in reverse, opposite of cat


talk [user]
Begins talk session with specified user


tail [file]

Display last 10 lines of specified file
Options:

tar [archive]
Tape archiver program. Used for combining files into a single archive or extracting files from an archive. Typical operation is similar to - tar xvf <file name>
Options:

telinit [runlevel]
Changes system to specified runlevel

time [command]
Displays the amount of time taken to execute specified command. Total execution time, user CPU time, & system CPU time.

top

Displays currently running tasks in real time and their amount of resource usage. Tasks using most CPU time will be listed near the top of the screen
Options: touch [file]
Changes file timestamps, or if a non-existant filename is used then create a blank file with specified name
Options: tr -[options] [set1] [set2] < [file]
Translate (replace) characters or delete them. Set1 is the character(s) that will be replaced by the character(s) in set2. The file must be supplied as an input to the tr command. The specified file is not actually altered, changes are just sent to display.

A range can also be specified like so: tr 'd-g' 'D-G' < [file]
Options:

traceroute [destination]
Display the route packets take to the specified network host (tracert in Win environment)

tty
Display what terminal the current user is connected to

ulimit
Lists and changes system limitations
Options:

umask [###]  <---umask value
Displays default umask setting is typically 022. To find the actual file permission subtract the umask value from 666 for files and from 777 for directories. Umask 022 will result in files being 644 and directories as 755
Options:

umount [path]
Unmount filesystem mounted at specified path


unalias [alias]

Remove specified alias


uname

Displays system information such as kernel version, processor type, hostname, etc. No options specified defaults to -s
Options:

uniq
Displays only unique lines from text file. Typically output is piped to uniq
Options:

uptime
Displays how long the system has been up

urpmi [optional username]
Mandriva specific rpm tool
Options:

useradd [username]
Creates specified user account. Must have superuser access to use
Options:

userdel [username]
Deletes specified user account. Must have superuser access to use
Options:

usermod [username]
Modifies existing user accounts. Must have superuser access to use
Options:

users
Lists users currently logged into the system

vlock

Locks a terminal/console until user's password is entered. This package typically is not installed by default. To lock a X-Windows session run xlock (xlockmore)

vmstat
Display virtual memory usage


w

Displays who is currently logged in and what process they are running. Pretty much just like "who", but with extra info

wall [message]
Sends message to every user's terminal

wc [file]

Displays word count of specified file + various other counts. Default output: 16 124 693 unity.txt (newline(lines), word, & byte count(chars))
Options:

whatis [program name/command]
Displays a one line description of a program/command's function.
"man -f" provide this same functionality. Sometimes the whatis database needs to be created by issuing a "makewhatis" command (requires root access)

whereis [program name/command]
Locates and displays the path to a program/command's binary, source, and man pages.


which
[program name/command]
Displays the full path of program/command
Options:

who
Displays who is currently logged into the system
Options:

whoami
Displays username of currently logged in user

xxd [file]
Hexdumps (plus ASCII representation) specified file. If no file is specified then stdin is used


For in-depth knowledge of a command type man [command name]. "man" is a helpful manual program. To scroll down in man hit the enter key and to exit hit q.