Mastering Essential Linux Commands for Devops.

1) cat
a) create the new file
#cat > redhat
this is the root file
press Ctrl + d to save the file
to chk the file
#ls or [#ll

](linkedin.com/feed/hashtag/?keywords=ll&..) to read the file
#cat redhat
c) to append the file
#cat >> redhat
this is created on wednesday
press Ctrl + d to save file
to chk the result
#cat redhat

2) touch
a) to create single file
# touch File1
to chk
#ls
b) to create multiple files #touch File1 File2 File3 File4
to chk
#ls
another method
#touch Delhi{1..8}
#touch Delhi{a..d}
to chk
# ls

3) vi
Command mode
key Task(function)
dd delete a line
ndd to delete multiple line(n=number of lines)
ex 2dd to delete 2 line
yy copy a single line
nyy to copy multiple lines(n=number of lines)
ex3yy to copy 3 line
p to paste
u to undo
ctrl r to redo
G to go to last line
/(word to find) to search a word

Extended mode
Key Task(function)
:q to quit without saving
:q! to quit forcefully without saving
:w to write(save)
:wq to save and quit
:wq! to save and quit forcefully
:se nu to set line numbers
:se nonu to remove line numbers
:1,$s/old name/new name to replace the word name

creation of directory(folder)
a) single directory(folder)
#mkdir Dir1
to chk
#ls or #ll
b) multiple dirctories (folders)
#mkdir Dir1 Dir2 Dir3 Dir4
to chk
#ls
another method
#mkdir india{1..9}
#mkdir india{a..e}
to chk
#ls
c) parental directory
#mkdir -p a/b/c/d/e
to ch[k

#](linkedin.com/feed/hashtag/?keywords=pwd&..)ls -R a

to enter into c directory
#cd a/b/c
to chk
#pwd
to go next directory
#cd d
to move two steps backward
#cd ../..
to come out from directory to user home directory
#cd
to go to last working directory
#cd -
to come out
#cd

COPY
a) copy file(old file) into file(new file)
#cp -rv redhat(source) centos(destination)
to chk
#ls
#cat redhat(to read the file)
#cat centos
b) copy file into directory
#cp -rv redhat(filename) zoom(directoryname)
to chk
#cd zoom(to enter into directory)
#ls (to chk the filename)
#cat redhat(to read the file)
#cd (to come out from directory)
another method
#ls zoom( to chk filename inside directory)
#cat zoom/redhat( to read the file which is inside the directory)

c) copy file (old) into another file(exiting file) without overwrite
#cat > unix
this is unix file
to save the file
press Ctrl d
#cp -rv redhat (old file) unix(existing file)
#cat redhat >> unix
to chk result
#cat unix

RENAMING
a)file
#mv redhat(old name) bluehat(new name)
to chk #ls
b) directory
#mv zoom(old name) moon(new name)
to chk
#ls

REMOVING(DELETING)
a) file
#rm bluehat
give y(yes)
to chk
#ls
b) directory
#rm -r moon
give y
to chk
#ls
to remove both files and directories without confirmation
#rm -rf hy* in* mcse linux
to chk
#ls