-h human readable
-s summary
Examples:
du -sh => total size of current directory human readable
This counts all of the files in the current directory and all children directories:
find . -type f | wc -l
The basic syntax of the find command is:
$ find . -name foo.bar
This will recurssively search starting in the current directory (.), and all subdirectories of the current directory, for the file named <filename>.
To filter out "Permission Denied" messages, use:
$ find . -name foo.bar -print 2>/dev/null
uname -a
permissions are represented by 3 digits
ugo => u=owner, g=group, o=otherw
1=execute, 2=write, 4=read
chmod 664 file => read and write access for the owner and group, read only for all others.
chmod 0 => removes all priveledges for all
chmod -R 755 => recursive, read+write+execute for owner, read+execute for group and others
Generalized Regular Expression Parser
grep string file => finds all occurances of <string> in <file>
-i => ignore case
-w => whole word
-l => list file name only
grep -r 'searchstring' /home => recursive - search all files
find /somedir -name '*.doc' -print | xargs grep 'somestring' /dev/null =>
recursive - specify specific file pattern
To create a compressed tar file: tar -cvf
To uncompress a tar file: tar -xvf
c=compress x=extract z=zip-format v=verbose (optional) f=file (must be last)
Examples: Create:
tar -czvf mystuff.tgz mystuff/
tar -cvzf file.tar.gz inputfile1 inputfile2
Extract: tar -xzvf mystuff.tgz tar -xvzf file.tar.gz
Goto:
: => line mode, operates on current line unless specific line numbers are specified
^ or 0 ==> beginning of line
$ ==> end of line
:0==>beginning of file
G ==> end of file
nG ==> go to line n
:n ==> go to line n
Return ==> first non-blank char
H ==> top line on screen
L ==> last line on screen
M ==> middle of screen
Ctrl+L ==> Redraw screen??
b beginning of previous word
w beginning of next word
e end of current/next word
0 (zero) or ^ beginning of line
$ end of line
( beginning of current/previous sentence
) beginning of next sentence
{ beginning of current/previous paragraph
} end of current paragraph
H top line on screen
M middle line on screen
L bottom line on screen
The search command is /. /hello => search for "hello" n repeats the search in the same direction N repeats the search in the opposite direction :s/search_string/replacement_string => global search and replace :s/search_string/replacement_string/g => global search and replace :s/search_string/replacement_string/gc => global search and replace with confirm
yw yank rest of word
y$ yank rest of line
yy yank entire line
Y yank entire line
p put yanked/deleted text before cursor
P put yanked/deleted text after cursor
A symbolic link, also known as a soft link or symlink, is a special type of file that points to another file or directory.
ln -s {target} {symlink name}
For, to example create a symlink for /home/domain/mydomain:
ln -s /home/domain/mydomain mydomain