~ - expands to your home directory (Example: cd ~)
. - expands to the current directory (Example: ls .)
.. - expands to the parent directory (Example: ls ..)
help - bash command-line/scripting help
apropos - use this if you're looking for a command that does <insert task here> (Example: apropos edit)
man - looks up help files for various commands (Example: man grep)
info - opens an emacs-like interface for extensive guides to commands (Example: info make)
whatis - shows a quick overview of the command (Example: whatis ls)
pushd and popd - quick directory traversalcd ~ pushd /usr/share/doc pushd popd
cd - to change to the directory you were just in.
alias - command aliasingalias -p alias changecd="eject; sleep 5; eject -t" changecd
grep - string searching in files grep --help or man grep to see them all)
grep, egrep, rgrep
grep -v apple fruits.txt
egrep '.*berry.*' fruits.txt
rgrep a * (recursive search)
wc - count the number of letters, words, and paragraphs in a file
cat - print out a file's contents
sort - sort a file alphabetically or numerically (Example: sort -r vegetables.txt)
tail - print the last few lines of a file
head - print the first few lines of a file
uniq - remove (sequential) duplicate lines in a file (Example: uniq names.txt) sort names.txt | uniq (see Piping below)
sed - regular expression/scripting tool sed -r -e 's/tomato/squash/' vegetables.txt (replaces all occurrances of "tomato" with "squash")
vim
emacs
nano
ls - list directory contents
find - a tool for recursive directory searching man find or find --help to see them all.
find . -iname '*.log' (will list all files/directories contained in the current directory (".") that match the pattern "*.log" (case-insensitive))
locate - a simple tool for finding files system-wide updatedb (as root) first before you use locate (especially if you're searching for a new file), but many Linux systems automatically run this command on a daily basis.
locate apache
whereis - shows the full directory path to a command you're looking for (Example: whereis bash)
ps - view running processes ps shows the user's processes.
ps -ax
pstree - view running processes in a tree format
killall - kill errant processes (use with caution!) (Example: killall kwrite)
nice - run a process at a different priority level nice if you want a costly program to use up less of your system resources.
nice to boost the priority of a process (see man nice)
nice find / -name '*'
lsof - show which files processes are using (helpful for umounting)
df - show disk usage on all mounted drives (Example: df -h)
du - show disk usage in a specified directory (Example: du . -sh)
mount - mount a device to a directory (see man mount for complete instructions) mount with no arguments to see what devices are mounted.
umount to unmount a drive.
lpstat - show information about printers (Example: lpstat -p)
lpr - print files from the command line (Example: lpr -P laser1 fruits.txt)
lynx - console web browser
bc - math interpreter (Example: echo 5*6/3+23 | bc)
cal - calendar (Example: cal -3)
fortune - random quotes and witty sayings (install by running apt-get install fortune as root) fortune: apt-get install fortunes as root) fortune startrek - "Live long and prosper." -- Spock, "Amok Time", stardate 3372.7
fortune linux - "Why use Windows when you can have air conditioning? Why use Windows, when you can leave through the door?" -- Konrad Blum
scrabble - a text-based scrabble game (installation: apt-get install scrabble)
adventure - a text-based roleplaying game (installation: apt-get install bsdgames)
>, >>, and &> > will truncate any file that you specify before outputting.
>> will append output to a file.
&> will truncate and send both normal and error messages to a file.
> when you mean >>!
sort names.txt > sorted-names.txt
cat vegetables.txt >> fruits.txt
grep &> grep-error.txt
| symbol to pipe output.
sort names.txt | uniq
sort vegetables.txt | egrep '^c' | wc
| I | Attachment | Action | Size | Date | Who | Comment |
|---|---|---|---|---|---|---|
| |
fruits.txt | manage | 0.1 K | 25 Jul 2005 - 14:16 | JeremyStephens | List of fruits |
| |
names.txt | manage | 0.6 K | 25 Jul 2005 - 14:36 | JeremyStephens | List of common names |
| |
vegetables.txt | manage | 0.1 K | 25 Jul 2005 - 14:30 | JeremyStephens | List of vegetables |