I know no one really reads my blog , so here is again another note to myself on commonly used linux commands for the heck of it ! . Hopefully someones finds it useful . Hoping that writing this down refreshes my frail memory
Getting help
[sourcecode language=”bash”]
$ # try –help with the command
$ man <command name>
$ info <command name>
$ apropos <command name>
[/sourcecode]
Listing Directories
[sourcecode language=”bash”]
$ls -a #lists all files
$ls -l #long listing
$ls -t # time
$ls -s # size
$ls -r # reverse
$ ls -ar # combination
[/sourcecode]
Changing Directories
[sourcecode language=”bash”]
$pwd # returns the current directory
$cd <dirname> # change directory to the given directory
[/sourcecode]
Copying files
[sourcecode language=”bash”]
$cp
$cp -r #recursive copy
$cp -i #interactive
[/sourcecode]
Creating/Removing directories
[sourcecode language=”bash”]
$mkdir #Creates
$rmdir #Removes
[/sourcecode]
Displaying file contents
[sourcecode language=”bash”]
$cat <file1> <file2> <file3>
$more <file1> <file2> <file3>
$less <file1> <file2> <file3> # you do more with less !
$head -n <file> # top n lines of the file
$tail -n <file> #bottom n lines of the file
[/sourcecode]
Pattern matching with grep
[sourcecode language=”bash”]
$grep <pattern> <files>
$grep -i <pattern> <files> #case insensitive
[/sourcecode]
Sorting
[sourcecode language=”bash”]
$sort <filename>
$sort -r <filename> #sort in reverse
[/sourcecode]
Sed
[sourcecode language=”bash”]
$# See : http://www.regular-expressions.info/ , sed can be used to parsing text and performing various transformations
$sed ‘s/<pattern>/<pattern to replace> <filename>
$#man sed
[/sourcecode]
Symbolic Links
[sourcecode language=”bash”]
$ln -s <filename> <link name> #soft link , omit -s for hard links
[/sourcecode]
Changing Permissions
[sourcecode language=”bash”]
$chmod <permissions> <files> # permissions – a,b,c = r*4+w*2+x
[/sourcecode]
Switch Users
[sourcecode language=”bash”]
$su (switch user)
[/sourcecode]
Tee send output to 2 devices
[sourcecode language=”bash”]
$tee [a] file
[/sourcecode]
Fill standard output with same thing
[sourcecode language=”bash”]
$yes <string> | <command>
[/sourcecode]
Useful process control commands
[sourcecode language=”bash”]
$jobs
$fg
$bg
$kill <pid>
$ps
[/sourcecode]
Environment Variables
[sourcecode language=”bash”]
$export varname = value
[/sourcecode]
Shortcuts with alias
[sourcecode language=”bash”]
$alias ls=’ls la’
[/sourcecode]
which is the executable
[sourcecode language=”bash”]
$which commandname
[/sourcecode]
Disk utilities
[sourcecode language=”bash”]
$du # disk usage
$df # disk free
[/sourcecode]
Compression utilities
[sourcecode language=”bash”]
$gzip / gunzip
$tar
$bunzip2
$lzma / unlzma
[/sourcecode]
Checking integrity
[sourcecode language=”bash”]
$md5sum
[/sourcecode]
File Comparison
[sourcecode language=”bash”]
$diff
[/sourcecode]
Location of files
[sourcecode language=”bash”]
$find <path> -name <name>
$locate <filename>
[/sourcecode]
Downloading websites offline
[sourcecode language=”bash”]
$wget
[/sourcecode]