Common Commands
Jump to navigation
Jump to search
Here is a list of common commands and some descriptions:
cd
- 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/
- Options: -R - Removes all files and subdirectories (very dangerous). Example:
rmdir directory
- Removes an Empty Directory. Example:
rmdir /home/bill/emptydir
mount
- 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
- Example:
ls options optional_directory_path (if no directory path is given, the current directory is listed)
- Lists files and directories. Example:
ls
- Options:
- -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
- -a - Lists ALL files and directories, even hidden ones. Example:
- Options:
gunzip filename
- Uncompresses gzip'd files. Example:
gunzip somefile.tar.gz
tar options filename
- Extracts files from .tar files.
- Options
- -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
- -xvf - extract file.tar
- Options
mc
- Console File manager
pico
- 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.
find
- Program to find files. Example:
find / -name lilo.conf
cat
- Shows what is currently in a text file. Example:
cat /proc/cpuinfo
grep
- Searches for strings. Example:
grep "model name" /proc/cpuinfo
Add the option '-i' if you don't want your search to be case-insensitive
less
- You can control using arrow keys what is displayed in a text file. Example:
less /etc/lilo.conf
man
- Manual pages for commands. Example:
man bash
apropos
- Searches a whatis type database. Example:
apropos ftp
which
- Shows the first match of a program in your path. Example:
which bash
whereis
- Shows man pages, binaries, etc of a program. Example:
whereis bash
file
- Determines the file type. Example:
file /usr/bin/bash
dmesg
- Displays the kernel ring buffer information
route
- Configures the IP routing (used for setting the default gateway, etc.).
ifconfig
- Network interface configuration tool (used to bring the NIC up and down and set the IP).
ssh
- Secure SHell, allows you to login to remote machines.
startx
- A simple script to start X-Windows
iwconfig
- This is for configuring wireless cards
chmod
- Edits permissions on a file or directory (see Permissions and Umasks)
netconfig
- A tool to help you configure a network card on Slackware
df
- Shows the free space on your partitions. Example:
df -h
du
- Calculates disk usage. Example:
du -hc
bunzip2
- Uncompresses .bz2 files. Example:
bunzip2 file.bz2
sort
- 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 thendu | sort -n
to see the difference.
Piping
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.
Redirection:
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