Public domain
logout
or
exit
reboot
or
shutdown -r now
-r reboot after shutdown
poweroff
or
shutdown -h now
-h poweroff after shutdown
passwd
clear
You can use <ctrl+l> instead.
ls -lha
-l long-listing
-h human-readable
-a show hidden-entries
pwd
cd <dirName>
return to home directory
cd
change to previous dir (recall)
cd -
change to parent dir
cd ..
tree
file <filename>
mkdir <newDir>
-p for making parent directories as needed.
cp <source> <destination>
-v for verbose
-r for recursively copy sub-directories
ln <target> <linksName>
-s for symbolic links
-f remove existing destination files
-n treat destination that is a symlink to a directory as if it were a normal file
rm <files>
-f force
-r recursively remove sub-directories
cat <file>
more <file>
less <file>
head <file>
tail <file>
-f output appended data as the file grows
-n
mv <source> <destination>
split -b 700m -d --verbose HugeFile PartPrefix
-d use numeric suffixes
-b put SIZE bytes per output file (k,m)
cat PartPrefix* > HugeFile
diff -ruN linux-2.6.18.origin/ linux-2.6.18/ > kernel-2.6.18.patch
-r Recursively compare any subdirectories found.
-u Output 3 lines of unified context.
-N Treat absent files as empty.
gzip kernel-2.6.18.patch
cp kernel-2.6.18.patch.gz linux-2.6.18/
cd linux-2.6.18/
zcat kernel-2.6.18.patch.gz | patch -p1
chmod <mode> <file>
mode : u+x,g-r,o-r+wx
u user
g group
o other
r read
w write
x exec
+ add
- del
chmod <octalMode> <file>
octalMode: 755
nnn
|||
||+-> other
|+--> group
+---> user
rwx
|||
||+-> 1
|+--> 2
+---> 4
755
|||
||+-> 4+1 -> other: r,x
|+--> 4+1 -> group: r,x
+---> 4+2+1 -> user : r,w,x
-R recursive
chown <owner:group> <file>
-R recursive
Shows the full path of (shell) commands.
which <programname>
Locate the binary, source, and manual page files for a command.
whereis <filename>
Indicate how <name> would be interpreted if used as a command name.
type <name>
-t alias, function, builtin, file, keyword.
-a show all executables
Search for files in a directory hierarchy
find <path> -name <pattern>
-iname case-insensitive name
Searching a database instead of entire filesystem
updatedb
slocate <searchString>
Searching the contents of files
grep eth1 /etc/*
-r recursively search sub-directories.
-i case-insensitive search.
-v select non-matching lines.
Searching the contents of files with regex (Regular Expression).
egrep -v '^#|^ *$' /usr/local/squid/etc/squid.conf
^# Lines which begins with #
| Or
^ *$ Empty lines.
compress
tar zcvf comp.tar.gz ./dir
tar jcvf comp.tar.bz2 ./dir
tar Jcvf comp.tar.xz ./dir
decompress
tar zxvf comp.tar.gz
tar jxvf comp.tar.bz2
tar Jxvf comp.tar.xz
-z : filter the archive through gzip
-c : create a new archive
-v : verbosely list files processed
-f : use archive file
-x : extract files from an archive
-j : filter the archive through bzip2
-J : filter the archive through xz-utils
Display processes
ps -A
-A Select all processes
ps auxw
a only yourself
u display user-oriented format
x must have a tty
w wide output
ps -ef
-e Select all processes
-f full-format listing
look a process id (PID)
pgrep <name>
kill processes by PID
kill -<signal> <pid>
-TERM terminate
-KILL kill
-HUP hangup
kill processes by name
killall <name>
display the manual pages
man [n] <name>
n section number :
Section 1 user commands
Section 2 system calls
Section 3 C library calls
Section 4 devices
Section 5 file formats and protocols
Section 6 games
Section 7 conventions, macro packages, etc.
Section 8 system administration
display info documents
info <name>
create whatis database
makewhatis
search whatis database
whatis <keyword>
search whatis database
apropos <string>
documents, HOWTOs, mini-HOWTOs
ls /usr/doc/
mount <device> <dir>
--bind remount a subtree somewhere else
-o loop mount loop device
un-mount file system
umount <dir>
eject removable media
eject [name]
watch -n 1 -d "df -h"
-n specify an interval
-d highlight the differences
traceroute -In 192.9.9.3
-n : Print hop addresses numerically.
-I : Use ICMP ECHO instead of UDP datagrams.
MIB files location
ls /usr/share/snmp/mibs
show everything
snmpwalk -v 1 -c public 192.168.1.1
memory list
snmpwalk -v 1 -c public 192.168.1.1 hrStorageDescr
process list
snmpwalk -v 1 -c public 192.168.1.1 hrSWRunName
interface name list
snmpwalk -v 1 -c public 192.168.1.1 ifDescr
interface MAC list
snmpwalk -v 1 -c public 192.168.1.1 ifPhysAddress
report filesystem disk space usage
df -hT
-h print sizes in human readable format
-T print filesystem type
estimate file space usage
du -hscS
-h print sizes in human readable format
-s display only a total for each argument
-S do not include size of subdirectories
-c produce a grand total
du -ha
-a write counts for all files, not just directories
BY: Pejman Moghadam
TAG: bash, commandline
DATE: 2007-09-27 11:05:10