man [command] | shows man page |
apropos [command] | shows command description (greps the descrip lines for given string) = man -k [command] |
w | find users logged in and their activity |
cal | show simple calendar |
cal 2017 | get full year calendar for 2017 |
cal 10 2005 | shows the month of Oct, 2005 |
ls | lists dir contents |
-s | list total files and no. files in sub dirs |
-sd | lists total no of files only |
-s [dir] | lists contents of [dir] and the no of files in its sub dirs |
-t | list most recently accessed files first |
-R | lists files recursively |
-l | long list files in a dir |
-m | list comma separated |
-x | list by rows |
-r | list in reverse order |
--color=auto --group-directories-first | list dir/files horizontally |
-lh --color=auto --group-directories-first | shows dir/file list with permissions, owner, file size, date modified |
-alhrt | shows dir/file list sorted recently modified first |
-alh | shows dir/file list including hidden |
-d .* --color=auto | shows only hidden files |
-lhd .* --color=auto | |
-Rh | shows files recursively |
cp {file} {newfile} | copies file with new name |
-u | update switch copies only if source file newer than dest file |
mv {file} {dir}/ | moves file to another dir |
mv {file} {newfile} | changes the file's name (moves to new file, deletes old) |
mkdir -p | creates dir with necessary parent dir's |
du | disk usage of all dir below location |
-s | total disk usage only |
-a | include size of all files |
df | disk free space on system |
touch {file} | creates the file, or modifies date-time to current on file |
compress {file} | compresses file to .z |
uncompress {file.z} | uncompresses file.z |
rm -i [file] | interactive remove |
-r [dir] | recursive removal of a dir |
-v [file] | verbose -explains what is being done |
file [file] [dir] | shows what type a file or dir is |
head -10 [file] | view 1st 10 lines of file |
head -5 [file] [file] | show for multiple files |
tail -10 [file] | show last 10 lines of file |
head -50 [file] | tail -10 | shows the lines 41-50 of file (using a pipe) |
cat [file] | displays file content (entire) |
more [file] | displays file content part-by-part |
-cs [file] | -c display clears screen each new page and -s
suppresses blank lines |
more +20 [file] | displays from line 20 |
more +/[text] [file] | displays from certain text in file |
{n}Enter | scroll n lines down |
d | scroll down half a page |
b | scroll back half page |
h | list commands in more program |
< | use this to pass input file to the command |
> | use to send output of command to a file |
>> | use to append output to a file |
wc [file] | shows no. of lines, words, characters in a file |
wc -l | counts only lines... |
[command] | wc -l | now wc counts the lines output from the command
and gives youa number (command e.g. ls, who) |
cat -n [file] | shows file with line numbers |
nl [file] | does the same |
-ba [file] | numbers blank lines |
-s', ' [file] | changes default tab after number to comma and space |
echo boo | writes "boo" to screen |
echo boo >> [file] | appends "boo" to a file |
echo * | list all files in the dir |
echo b* | list all the file in dir beginning with b |
? | single character wildcard (* can be any length of characters) |
ls [a-z]* | lists all file/dir beginning with a letter |
grep [word] [file] | display lines from a file with a certain word or text |
grep 'ho*' [file] | displays lines containing "ho" in any word |
-i | ignores case of search criterea |
-n | numbers the lines that are matched |
-c | count of matching lines |
-l | lists files with matching lines |
sed -i 's/cap/hat/g' [file] | sed substitutes cap with hat in a file (the -i option replaces inline, in the file, without which the changes are printed to standard output, the screen)... |
grep 'cap' [file] | sed -i 's/cap/hat/g' | another method (g tells sed to do every ocurrance) |
sed -i 's/cap/hat/g;s/cat/rat/g' | sed carries out 2 different substitutions, and every instance of each |
- by Dave Taylor. James C. Armstrong, Jr.
This is a useful book to look at if you are new to Linux, or haven't read up properly about the basic functions of the UNIX OS. But its no longer around for free!