You are on page 1of 2

who

cal
cal -y
cal [year]
cal -3

pwd - Print Working Directory

cd - Change Directory

ls - List Files or Directory

cd /usr/bin/gems/ruby

cd /root

touch file1.txt
touch file2.c
touch file3.txt
touch file.txt
touch file10.txt

ls -l
ls -lt
ls -ltr
ls -la

Wild Card Character - *, ?


----------------------------------------------------

vi <FileName>

Insert - i
Escape - Esc

Save File - :wq!, :x


Quit without saving - :q!

i - insert before cursor


a-append after cursor
I- insert start of line
A-append at the end of line
dd- delete a line
ndd - delete n lines
dw - delete a word
D-delete line from cursor
yy-yank/copy 1 line
p - print yanked line
nyy-yank/copy n lines
r-replace a character
x-delete a character
~-change case of a character

wc <filename>

cp <filename1> <filename2>
mv <filename1> <filename2>
rm <filename>
mkdir dirname
rmdir dirname
rm -r dirname

chown - Change user - chown <username> filename


chgrp - Change Group - chgrp <grpname> filename

u - user
g- group
o- others

r-read - 4
w-write -2
x-execute -1

chmod <permission> file name

cat file1 file2 > file3 - New File got created

cat file4 >> file3 - Append to existing file

cat file5 file5 >> file3 - Append to existing File

grep <pattern> <filename>

-i - ignore case
-c - Count no. of lines
-o - Display pattern
-n - Display line number
-v - inverting the pattern match
^pattern - Search of lines having pattern as starting point
pattern$ - Search of lines having pattern as end point

sort <filename>
sort -n <filename> - Numeric sort
sort -r <filename> - reverse sorting
sort -kn <filename> - sort based on field n
sort -t"d" -kn - sort based on field "n" and delimiter is "d"

:set nu

:%s/search/replace/g

ls -ltr | tr -s ' ' | cut -d" " -f5

You might also like