|
#
|
Super User
|
|
$
|
normal user
|
|
date
|
display current date and time
|
|
cal
|
display current month calendar
|
|
df
|
displays disk usages
|
|
free
|
display memory usage
|
|
cd
|
change the current diretcory
|
|
ls
|
list the directory
|
|
file
|
Determine file type
|
|
less
|
view file contents
|
|
cp
|
copy the files
|
|
mv
|
move the files from one folder to other
|
|
mkdir
|
creates a directory
|
|
rm
|
remove files and directories
|
|
ln
|
create Hard and symbolic link
|
|
i
|
interactive
|
same in mv
|
|
a
|
copy files and directories of all attributes, ownership and permission
|
-
|
|
r
|
recursively copies directories and contents
|
same in mv
|
|
u
|
copy the files that don't exists
|
same in mv
|
|
v
|
verbose, informative message
|
same in mv
|
|
echo $(ls)
|
|
|
ls -l $(which cp)
|
new method
|
|
ls -l
which cp |
back tick, old method
|
|
ps
|
reports snap shot of current process
|
|
top
|
diskplays task
|
|
jobs
|
list active jobs
|
|
bg
|
place a job in the background
|
|
fg
|
place a job in the foreground
|
|
kill
|
send a signal to process
|
|
killall
|
kill process by name
|
|
ps aux
|
BSD style ouptut
|
|
fg %1
|
jobs
|
|
kill -1 13456
|
kill process id 13456
|
|
ps -eo pid,comm,cmd,start,etime
|
to get process elapsed time
|
|
cmin
|
match attributes/files/dir modified, n minutes
|
|
cnewer
|
match file/dir whose content or attribute were last modified n*24 ago
|
|
ctime n
|
match file or direct whose content or attribute were modified n*24 hrs ago
|
|
empty
|
match empty files and directories
|
|
group name
|
match files or direc belonging to group name
|
|
iname
|
pattern like the iname test but case insensitive
|
|
inum n
|
match files with inode number
|
|
mmin n
|
match files or dir whose content were modified n minutes ago
|
|
mtime n
|
match files or dir whose content were modified n*24 hours ago
|
|
name pattern
|
match files and dir with specified wildcard pattern
|
|
nouser
|
match files and dir that don't belong to valid user
|
|
nogroup
|
match files and dir that don't belong to valid group
|
|
perm mode
|
match files and directories set to specified mode
|
|
samefile name
|
matches files that share the same inode number as file name
|
|
size n
|
match file size of n
|
|
type c
|
match file type of c
|
|
user
|
match file and directories belong to user
|
|
and
|
|
or
|
|
not
|
|
delete
|
|
ls
|
|
print
|
|
quite
|
|
depth
|
to process a directory files before the dir itself
|
|
maxdepth
|
max num of level that find will descend into a directory when performing test and action
|
|
mindepth
|
min num of level that find will descend into a directory when performing test and action
|
|
mount
|
direct find not to traverse directories that mounter on other filesystem
|
|
clear
|
clears the screen
|
|
history
|
stores the history
|
|
script file
|
capture all command execution in a file
|
|
type
|
Indicate how command name is interpreted
|
|
which
|
display which executable program will be executed
|
|
man
|
Display manual page
|
|
apropos
|
Display appropriate command
|
|
info
|
Display command Info entry
|
|
whatis
|
Display brief description of command
|
|
alias
|
create an alias for command
|
|
dmidecode
|
provides valueable inisights into system hardware configuration
|
|
lscpu
|
provides detailed information about cpu
|
|
1
|
User commands
|
|
2
|
Programming interface for system calls
|
|
3
|
Programming interface for C Library
|
|
4
|
Special files such devies nodes and drivers
|
|
5
|
file formats
|
|
6
|
Games and screen savers
|
|
7
|
misc
|
|
8
|
system administrator commands
|
|
cat
|
concatenates files
|
|
sort
|
sort the file
|
|
uniq
|
report or omit repeated lines
|
|
grep
|
print lines matching pattern
|
|
head
|
prints first few lines of file
|
|
tail
|
prints las few lines of file
|
|
tee
|
reads stdin and send output to stdout and file
|
|
wc
|
count number of line, words, and bytes
|
|
ls -l /usr/bin >file
|
default stdout to file
|
|
ls -l /usr/bin 2>file
|
redirects stderr to file
|
|
ls -l /usr/bin > ls-output 2>&1
|
redirects stderr & stdout to file
|
|
ls -l /usr/bin &> ls-output
|
redirects stderr & stdout to file
|
|
ls -l /usr/bin 2> /dev/null
|
/dev/null bitbucket
|
|
|
|
pipelines
|
|
ls -l /usr/bin/ | tee out | sort
|
tee reads stdin and writes to files and stdout
|
|
echo *
|
expands all files in the path
|
|
echo D*
|
expands all files with starting D
|
|
$((expression))
|
Arithematic expression
|
|
echo $(($((5*2))3))
|
75
|
|
ls -l
which cp |
backtick instead of expression
|
|
echo Front-{A,B,C}-Back
|
Front-A-Back, Front-B-Back, Front-C-Back
|
|
echo {Z..A}
|
Z Y X W V U .....A
|
|
mkdir {2009..2011}-0{1..9} {2009..2011}-{10..12}
|
creates a directory for 12 months in 2009 to 2011
|
|
printenv
|
Print part of all of the environment
|
|
set
|
set shell options
|
|
export
|
export environment to subsequently executed programs
|
|
alias
|
create an alias for command
|
|
echo This is a test
|
This is a test; space is stripped
|
|
echo "This is a test"
|
This is a test
|
|
echo '$(echo foo) $((2+2))'
|
$(echo foo) $((2+2))
|
|
echo the total is $500.00
|
$5 is undefined variable so it supress the value, output will be like the total is 00.00
|
|
locate
|
find files by name
|
|
find
|
search for files in a dir
|
|
xargs
|
build and exec cmd lines from stdin
|
|
touch
|
change the file times
|
|
stat
|
display file or filesystem status
|
|
Ping
|
Send ICMP packets
|
|
traceroute
|
Print route packets to a network
|
|
netstat
|
print network connection, routing table, interface stats
|
|
ftp/lftp
|
Internet file transfer program
|
|
wget
|
Non Interactive network downloader
|
|
ssh
|
OpenSSH SSH Client (remote login program)
|
|
scp
|
secure copy
|
|
sftp
|
Secure File transfer program
|
|
gzip
|
Compress or expand files
|
|
bzip2
|
A block sorting file compressor
|
|
tap
|
tape archving utility
|
|
zip
|
Package and compress files
|
|
rsync
|
remote file and dir synchronization
|
|
unzip
|
Unzip the gzip files
|
|
cat -A $FILE
|
To find any CTRL character introduced
|
|
sort file1.txt file2.txt file3.txt > final_sorted_list.txt
|
sort all files once
|
|
ls - l | sort -nr -k 5
|
key field 5th column
|
|
sort --key=1,1 --key=2n distor.txt
|
key field 1,1 sort and second column sort by numeric
|
|
sort foo.txt | uniq -c
|
to find repetition
|
|
cut -f 3 distro.txt
|
cut column 3
|
|
cut -c 7-10
|
cut character 7 - 10
|
|
cut -d ':' -f 1 /etc/password
|
delimiter :
|
|
sort -k 3.7nbr -k 3.1nbr -k 3.4nbr distro.txt
|
3 rd field 7 the character, 3rd field 1 character
|
|
paste file1.txt file2.txt > newfile.txt
|
merge two files
|
|
join file1.txt file2.txt
|
join on common two fields
|
|
cat
|
concatenate files and print stdout
|
|
sort
|
sort lines of text files
|
|
uniq
|
report or omite repeated lines
|
|
cut
|
remove section from each line of files
|
|
paste
|
merge lines of files
|
|
join
|
join lines of two files on a common field
|
|
comm
|
compare two sorted files line by line
|
|
diff
|
compare files
|
|
patch
|
apply a diff file to original
|
|
tr
|
translate
|
|
sed
|
stream editor
|
|
aspel
|
interactive spell checker
|
|
id
|
display user identity
|
|
chmod
|
change's file mode
|
|
umask
|
set the default file permission
|
|
su
|
Run a shell as another user
|
|
sudo
|
Execute command as another user
|
|
chown
|
changes file's owner
|
|
chgrp
|
change file groups owner
|
|
passwd
|
change a user password
|
|
- | rwx | rw- | r--
|
type | owner | group | world
|
|
000
|
---
|
|
001
|
--x
|
|
010
|
-w-
|
|
011
|
-wx
|
|
100
|
r--
|
|
101
|
r-x
|
|
110
|
rw-
|
|
111
|
rwx
|
|
ugo
|
user, group, others
|
|
u+x
|
giving exeute permission for user
|
|
u=rw,o=x
|
giveing user read write and others execute perm
|
|
Debian Style (.dep)
|
Debain, ubuntu, xandros, Linspire
|
|
RedHat style(.rpm)
|
Fedora, CentOS, Redhat Enterprise, OpenSUSE, Mandriva, PCLinuxOS
|
|
debian
|
apt-get install package_name
|
|
redhat
|
yum install package_name
|
|
mount
|
mount a filesystem
|
|
ummount
|
unmount a file system
|
|
fdisk
|
partition table manipulator
|
|
fsck
|
check and repair filesystem
|
|
fdformat
|
format floppy disk
|
|
mkfs
|
create a file system
|
|
dd
|
write a block oriented data directly to a device
|
|
genisoimage
|
create an ISO 9660 image file
|
|
wodim
|
Write data to optical storage device
|
|
md5sum
|
calculate md5sum
|
|
i
|
ignore case
|
|
v
|
invert match
|
|
c
|
print number of matches
|
|
l
|
print the name of each file that contain matches
|
|
L
|
print only the names of files that don't match
|
|
n
|
print match line with the number
|
|
h
|
for multiple output supress the output of filename
|
|
grep -h '.zip' file.list
|
. is any character
|
|
grep -h '^zip' file.list
|
starts with zip
|
|
grep -h 'zip$' file.list
|
ends with zip
|
|
grep -h '^zip$' file.list
|
containing only zip
|
|
grep -h '[^bz]zip' file.list
|
not containing b and z
|
|
grep -h '^[A-Za-z0-9]' file.list
|
file containing any valid names
|
|
?
|
match element zero or one time
|
|
*
|
match an element zero or more times
|
|
+
|
Match an element one or more times
|
|
{}
|
match an element specfic number of times
|
|
diff -c
|
context format
|
|
diff -u
|
unified format
|
|
diff -Naur oldfile newfile > diff_file
|
write the diff to diff file
|
|
patch < diff_file
|
applied to oldfile directly.
|
|
echo "secret text" | tr a-zA-Z n-za-mN-ZA-M
|
frperg grkg | ROT13 Encoding
|
|
echo "frperg grkg" | tr a-zA-Z n-za-mN-ZA-M
|
secret text | ROT13 Decoding
|
|
Backup of superblock
|
dumpe2fs /dev/sdX | grep -i superblock
|
|
Restore of superblock
|
fsck -b 32768 /dev/sdX
|
|
dumps ext2/ext3/ext4 filesystem info including inode locations
|
dumpe2fs /dev/sdX
|
|
interactive tool to inspect inodes
|
debugfs /dev/sdX
|
|
shows inode number and metadata
|
stat filename
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.