Commands
Main article: commands
ls : show a directory listing
df -h : show how much disk space is left
du -csh myfolder : show how much space is in use by the folder myfolder
cd : change directory
cp -r : copy a file
rm -r : delete a file
mkdir : make a directory
chmod : change the file permissions
pwd : show current working directory
whoami : show your user name
hostname : show your host's name
uptime : show the uptime of your host
top : show the top CPU consuming processes
Hard drives
Main article: hard drive commands
hwinfo --storage-ctrl : discover your hard disk controller
hwinfo --block : discover what disks you have
hwinfo --partition : discover what partitions you have
fdisk : divide your disk devices into partitions
(USE WITH CAUTION!!)
NetWorking
Main article: Network commands
hwinfo --netcard :find out your NIC's type and abilities
ethtool : find out if a cable has been plugged in (link detection)
ping : find out if a computer is reachable
ifconfig : set your IP-address
route : set your default gateway
nmap : find out about ports information on a computer
General notes on commands
Commands may be invoked as simple commands. In these examples, the $ that
starts each line is a shell prompt and not meant to be typed
$ ls
Or they may be invoked as complex commands.
$ ls -l /bin
Here "-l /bin" are a pair of arguments (separated from each other and the
command by whitespace) and "-l" is specifically an option, since it modifies the
behavior of ls (it produces a long listing), while "/bin" simply specifies a target for ls
to act on.
They may also be invoked in multiples where the semicolon is a command
separator.
$ cd /bin; ls
That's two commands on one line. You may also execute one long command on two
lines by escaping the carriage return with a backslash. (See scripting for further
details on metacharacters and escaping and quoting.)
$ cd really long command line \
that we would like to finish here
Another way to invoke multiple commands is conditionally, where (in bash) "&&"
means to execute the second command only if the first returns with an exit code of
0 (i.e., it succeeds).
$ cd /bin && ls
With the semicolon command separator, had the change of directory failed, ls would
still have been invoked and simply listed the contents of the current directory. With
the conditional operator, ls would not be invoked if cd had failed.
Similarly, "||" means to execute the second command only if the first returns a nonzero exit code (i.e., it fails).
$ cd /bing 2>/dev/null || echo 'I kinna do it, Cap'\''n!'
This will cd to the directory named "bing" if it in fact exists and the command will
exit. Since it probably doesn't, being a typo, the second command will execute and
print a somewhat more entertaining error message than is usual.
Learning about commands with local documentation
A Linux system should have documentation in the form of man pages and possibly
GNU info pages (see also texinfo). In a manner similar to this page's alphabetical
list, if you know the command you wish to learn more about,
$ man command
will show you the manual page of command.
If you do not know the command but would like to see commands relevant to a
topic, use
$ apropos subject
or
$ man -k subject
to find suitable commands.
Unfortunately, while most man pages will be informative and complete, many GNU
utilities distribute very sketchy man pages whose primary purpose is to redirect the
user to the info system. In that case,
$ info command
will invoke that system of documentation.
Many commands have an "-h", "-H", "-help", "--help" option or some combination
thereof. Unfortunately, some commands understand other things by "-h" or "-H" so
unexpected and possibly unpleasant results may occur.
There are also extensive miscellaneous files usually found in /usr/doc, /usr/local/doc,
/usr/src/linux/Documentation (kernel docs), and elsewhere.
Access
Man pages are monolithic and some are quite long, and it's occasionally hard to find
what you want. The tradeoff is that the man command automatically puts you in a
pager that allows you to search for specific text, usually using key bindings like vi.
This can be good if you know what to look for.
Info pages are usually subdivided, and contain some directory and hyperlink
information. The tradeoff is that you need to be at least minimally familiar with the
key bindings used for navigation. They are a subset of those for emacs.
Alternatively, you can export the entire tree as a single text document and view
through a pager with the command
$ info --subnodes command | less
this loses the hyperlinks, but you can use the same navigation skills you use on a
man page.
Lists of commands
In our Category Command you will find all commands in this wiki, but without
explanation. The next chapter lists the most relevant ones with a short explanation
so you can decide if the respective command is right for you. If you add to this list,
your contribution should be didactic, understandable for newcomers, focused on the
"real world" and contain sensible examples.
By name
This is a list of commands that gives you just enough information to decide what
command you want to use.
A
alias - allows you to create shorter or more familiar names for commonly
used commands
apropos - search the manual page names and descriptions
apt-get - a package management frontend for Debian-based distributions
at - execute a command-line task at a specified future time
awk - print only the nth word of an input line and more
badblocks - a command disk utility
bash - a shell
beep - customized audible alerts
bg - run a process in the background
bunzip2 - unpack files packed with bzip2
bzip2 - a pack utility
cat - receive strings from stdin or a file and output them to stdout or a file
cd - change to directory
chgrp - change the group ownership of a file
chmod - change the permission mode of a file
chown - change the owner of a file
chroot - change the position of a root directory in filesystem
chsh - change the shell of a user
clear - clear the terminal screen
cmp - compare arbitrary files.
cp - copy a file
cpio - pack or unpack files in cpio archives or tarballs
cron - schedule tasks to be executed regularly at a specific time
crontab - control the cron service
cut - display specific coloumns of a file delimited by a character
cvs - a version management system
date - output or set date and time
dd - dump a disk to/from a file and more
df - show how much free disk space there is
diff - show the difference between two files and more
dig - show answer of DNS lookup of queried name server
disown - disowns a job (removes the pid of the job). Even when the shell
exits, the job won't stop running
du - show how much disc space is used up
echo - echo a string/value to stdout
emacs - a text editor (and much more)
env - show all environment variables
exit - exit most shells
export - set an environment variable in bash and sh
fdisk - partition a disc
fg - fetch a process from the background to the foreground
file (command) - determine a file's type
find - find a file depending on its name, size, change date or other attributes
ftp - get files from the internet
fuser - identify processes using files or sockets
g++ - compile C++ code
gcc - compile C code
grep - grab for patterns in a file and more
groups - show what groups your user is in
gunzip - unpack files from a special format
gzip - pack files in a special format
halt - shut down your computer
head - show only the first n lines of a file and more
hexdump - show a file's content in hexadecimal numbers and more
history (command) - show a command history in the bash shell
hostname - show your computer's name
hwinfo - show your available hardware
id - show your user and groups ids
ifconfig - show your ip address and more
info - show info about a given command
init - change runlevel
iptables - show your firewall configuration
iptraf - Interactive IP LAN monitor
jobs - gives a list of current background jobs (processes)
kill - kill a process
killall - kill all processes with a given name
ldd - show dynamic libraries needed by an executable
less - show output in a viewer where you can scroll and search
ln - link a file
ls - list files in a directory
lshal - list HAL devices
lshw - list hardware
lsmod - list loaded kernel modules
lsof - list open files and listening sockets
lspci - list all pci devices
lsusb - list usb devices
make - compile software and more
man - get help on commands
md5sum - compute the md5 sum of a file and more
mkdir - make a directory
mkfs - format a device
minicom - communicate over your RS232 interface
more - show input in a searchable pager
mount - prepare a device for reading and writing
mv - move a file (or rename a file)
netcat - Send some bytes to the network
netstat - get information on listening sockets, open ports and more
nice - set a process's priority
nm - list the names of functions in an object file
nmap - network and port scanner tool
notepad - a simple text editor, good for folks transitioning to linux, provided
by wine.
objdump - show information about object files
openssl - create cryptographic server certificates and more
passwd - change user password
ping - show if a given computer is up and running
ps - show running processes
pwd - show your current working directory
quota - manage how much resources the user is allowed to consume
rar - rar files/directories
read - read a string from your keyboard and more
reboot - reboot the computer
rename - rename a file
rm - delete a file
rmdir - remove empty directories
route - manage your network routing table
rpm - a package management backend for Redhat and Fedora
rsync - synchronize your folders over the network
scp - (secure copy) over a network
screen - a terminal multiplexer
sed - manipulate a stream of characters (scripting language)
setenv - change the value of an environment variable in the csh
shuf - generate random permutations
shutdown - shutdowns/reboots the system
sleep - wait/delay some time
ssh - login into / execute commands in a remote host
su - change user
sudo - execute the command as another user (usually root- /etc/sudoers)
tail - show only the last n lines of a file and more
tar - pack files in a special format
tcpdump - dump the tcp network traffic
tee - multiplex cli output
time - show the time needed by a command to finish
top - show the top CPU consuming processes and more
touch - create a file or update its time stamp
traceroute - show the route a packet takes over the network
tac - print the file in reverse. (opposite of cat) (cat X tac)
tune2fs - adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
ulimit - show the limits of your user
umount - unmount a device (Often requires sudo permissions)
uname - show the running kernel's version and more
uniq - remove repeated lines in a sorted file
unrar - extract .rar files
unzip - unpack files
uptime - show the time since your computer was last switched on
useradd - add a user
userdel - delete a user
usermod - modify a user
Vgcreate - create lvm volume groups
Vgdisplay - display lvm volume groups
Vgs - show information about lvm volume groups
Vgscan - scan for lvm volume groups
vim - a text editor, not entirely unlike Notepad, but more powerful and
programmable.
Vmstat - show input/output values, swap, memory consumption and more
w - print who is logged in to your system
wc - word count (word,line,char)
wget - The non-interactive network downloader
whereis - locate the binary, source, and manual page files for a command
which - print the path where you find an executable file
who - see who is on the system
whoami - print your effective user name
xargs - hand over stdin as a parameter
xev - show information about your keystrokes and more
xkill - kill a window that is in your way
xosview - show CPU/memory/hard Drive activity and more
yes - repeatedly output a string
yum - a package management frontend for Redhat & Fedora
yast - a package management frontend for SUSE
zcat - apply cat on Gzip files
zcmp - apply cmp on Gzip files
zdiff - apply diff on Gzip files
zgrep - apply grep(search in) possibly compressed files
zip - pack a file
zless - apply less on a compressed file
zmore - apply more on a compressed file
By category
Cryptography Commands
Directory Commands
Disk and Tape Drive Commands
File Commands
Internet and Network Commands
Kernel-commands
Managing Sessions
Packing and Unpacking Files
Programming-related Commands
Scripting
Shells
System Information
Startup/Shutdown Commands
Text Viewing and Processing Tools
User commands
Internet and network Commands
ethtool
command to show if a network cable is plugged in e.a.
ftp
Used to establish a connection with a specified host using the File
Transfer Protocol.
ifconfig
Displays/establishes information about the network interfaces.
ifup
Bring up network interface.
ifdown
Bring up network interface.
iptraf
Interactive IP LAN monitor
iwconfig
Displays/establishes information about the wireless interfaces.
ip
Used to manage IP network interfaces.
lsof
Command to show what processes are making use of a port e.a.
nmap
Command to show which ports are open e.a.
netstat
Displays information about the Linux networking subsystem.
nslookup
Looks up the numerical IP address of the specified host.
ping
Sends a packet to a designated address and waits for a response.
route
Configure IP4 routing
scp
Copy files over the network.
showmount
Displays the Network Filesystem mounts available.
smbclient
Launches an interactive samba utility which resembles ftp.
smbmount
Mounts a remote Samba service at the specified mount point.
smbumount
Unmounts the specified Samba mount point.
ssh
Control a remote computer over the network.
telnet
Opens a terminal window on the remote host and starts an interactive
session.
traceroute Prints the route that packets take to network host
wvdial
Initiates a PPP dial-up connection.