Common Commands

From SlackWiki
Revision as of 03:22, 2 June 2009 by Erik (talk | contribs) (Copy from old)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here is a list of common commands and some descriptions:

Changes the directory. Example: cd /
 rm options filename
Removes Files. Example: rm filename
Options: -R - Removes all files and subdirectories (very dangerous). Example: rm -R /home/bill/public_html/
 rmdir directory
Removes an Empty Directory. Example: rmdir /home/bill/emptydir
Mounts filesystems and partitions, etc
Example: mount /mnt/cdrom <--Only useable if /mnt/cdrom is listed in /etc/fstab
Example: mount -t iso9660 /dev/hdc /mnt/cdrom
 ls options optional_directory_path (if no directory path is given, the current directory is listed)
Lists files and directories. Example: ls
-a - Lists ALL files and directories, even hidden ones. Example: ls -a
-l - Lists files and directories with details (e.g. permissions) Example: ls -l /home/bill/
-la - Lists ALL files and directories, even hidden ones with details. Example: ls -la
 gunzip filename
Uncompresses gzip'd files. Example: gunzip somefile.tar.gz
 tar options filename
Extracts files from .tar files.
-xvf - extract file.tar tar -xvf file.tar
-zxvf - uncompress and extract from a gzip'd tar archive (*.tar.gz or *.tgz) tar -zxvf kernel-2.6.7.tar.gz
-jxvf - uncompress and extract from a bzip2'd tar archive (*.tar.bz2) tar jxvf kernel-2.6.7.tar.bz2
Console File manager
Easy console text editor. NOTE: Pico is in the PINE package. If you didn't install Pine, you won't have pico. (You CAN install pico as a stand-alone binary). An alternative to Pico is GNU Nano. It has many features, including syntax highlighting.
 vi, vim, elvis
Console text editors - depending on your setup, one of these is accessed as 'vi'. Vim & Elvis are Vi clones (with a few more features). Between Vim and Elvis, Vim is more featureful, but elvis is in /a and installed by default. You can install vim (or xvim/gvim, gui-enabled versions) instead of, or in addition to elvis.
Program to find files. Example: find / -name lilo.conf
Shows what is currently in a text file. Example: cat /proc/cpuinfo
Searches for strings. Example: grep "model name" /proc/cpuinfo Add the option '-i' if you don't want your search to be case-insensitive
You can control using arrow keys what is displayed in a text file. Example: less /etc/lilo.conf
Manual pages for commands. Example: man bash
Searches a whatis type database. Example: apropos ftp
Shows the first match of a program in your path. Example: which bash
Shows man pages, binaries, etc of a program. Example: whereis bash
Determines the file type. Example: file /usr/bin/bash
Displays the kernel ring buffer information
Configures the IP routing (used for setting the default gateway, etc.).
Network interface configuration tool (used to bring the NIC up and down and set the IP).
Secure SHell, allows you to login to remote machines.
A simple script to start X-Windows
This is for configuring wireless cards
Edits permissions on a file or directory (see Permissions and Umasks)
A tool to help you configure a network card on Slackware
Shows the free space on your partitions. Example: df -h
Calculates disk usage. Example: du -hc
Uncompresses .bz2 files. Example: bunzip2 file.bz2
Sorts data. A very useful option is '-f', which makes the sort case-insensitive (i.e. AaBbCc rather than ABCabc). Another useful option is '-n', which sorts by numbers. Try du | sort and then du | sort -n to see the difference.


You can mix commands to do certain things.

 dmesg | grep hd

That will search dmesg and try to find the string "hd". Now piping is extremely useful. Another example of a pipe:

 dmesg | less

Now this command you can see the dmesg fully and is easier to read.


This will save the dmesg information in your home directory in the file log.txt

 dmesg > ~/log.txt

You can also redirect only the stdout by using '1>' or only the stderr by using '2>'.

For instance, if you want to run a command that gives a lot of junk as output, and you just want to see any errors, you can redirect the output to the null device (/dev/null):

 mplayer /path/to/movie.avi 1> /dev/null

Section on piping moved to Piping. --sinope