The below are the Linux commands which are used frequently in Teradata Projects(real-time)
(Followed by regular class of VINAYTECH)
Directory operations
mkdir vinaytech --creating directory
ch vinaytech --changing directory (connecting to the directory)
pwd --
rmdir vinaytech --removing directory
cd.. --going to previous directory
cd..\.. -- two directories back
cd --going to root directory
clear -- clearing the scrren
CAT
Creating filesA) By using TOUCH command (for ZERO BYTE FILE creation)
B) By using CAT command
C) By using VI EDITOR
Cat Command:
To create/append/modify content in the file.
Examples:
Crating:
Cat > tdclass
EID ENAME ELOC
1 X HYD
2 Y MUM
3 Z USA
Ctrl + d
To view the file
Cat tdclass
Copying file
cp tdclass tdclass1
Remove file
rm tdclass1
Moving file
Mv tdclass1 tdclass2
Concatenate and displaying data
Cat tdclass1 tdclass2
Concatenate and redirect to other file
Cat tdclass1 tdclass2 > tdclass3
WC
Wc -->Word count
Real time:
For Reconciliation and Unit testing
While performing ETL operations on files
Wc -l <Filename> -->Count no of lines
Wc -c <Filename> -->Number of characters in a file
Wc -w <Filename> -->Number of words
To see words and Lines at a time
wc -wl
Piping Operator (||)--> Redirects the information.
wc lc tdclass || tee filestats
In this situation lines and characters info redirected to
filestats file.
Tee : Display and Redirect
Real Time:
Most frequently used command at the time of
executing utilities in Unix prompt / script
wc lc tdclass || tee filestats
In the above example result displayed and redirected.
It is a special editor for working/ modifying / substituting
etc..operations on the files data.
Mostly we use SED and Option s for Substitution.
Examples:
sed 's/HYD/Hyderabad/' tdclass
sed 's/HYD/Hyderabad/3g' tdclass -->3rd line to all
occurances
sed 's/HYD/Hyderabad/g' tdclass -->All occurances replaced
sed -n '$=' tdclass-->Counts lines in a file
sed 's/HYD/Hyderabad/g' tdclass > Tdresult
--> Result redirection
etc...
Most powerful command for processing rows and columns in a file
Awk supports
A) Conditional Operators
B) Blocks
C) Loops
D) String functions
E) Associative Arrays
Some people using awk command for automating(SCHDULING)the applications in Unix environment inside the scripts.
AWK 'BEGIN {start_action} {action} END {end_action}' <filename>
Examples:
awk '{print 1$}' tdclass -->first column it returns
awk '{print 1$,3$}' tdclass -->first 3 columns it returns(1-3 columns)
Real time:
For Reconciliation and Unit testing
While performing ETL operations on files
Wc -l <Filename> -->Count no of lines
Wc -c <Filename> -->Number of characters in a file
Wc -w <Filename> -->Number of words
To see words and Lines at a time
wc -wl
Piping Operator (||)--> Redirects the information.
wc lc tdclass || tee filestats
In this situation lines and characters info redirected to
filestats file.
TEE
Tee : Display and Redirect
Real Time:
Most frequently used command at the time of
executing utilities in Unix prompt / script
wc lc tdclass || tee filestats
In the above example result displayed and redirected.
SED
SED : (Stream Editor)It is a special editor for working/ modifying / substituting
etc..operations on the files data.
Mostly we use SED and Option s for Substitution.
Examples:
sed 's/HYD/Hyderabad/' tdclass
sed 's/HYD/Hyderabad/3g' tdclass -->3rd line to all
occurances
sed 's/HYD/Hyderabad/g' tdclass -->All occurances replaced
sed -n '$=' tdclass-->Counts lines in a file
sed 's/HYD/Hyderabad/g' tdclass > Tdresult
--> Result redirection
etc...
AWK
AWK -->Most powerful command for processing rows and columns in a file
Awk supports
A) Conditional Operators
B) Blocks
C) Loops
D) String functions
E) Associative Arrays
Some people using awk command for automating(SCHDULING)the applications in Unix environment inside the scripts.
AWK 'BEGIN {start_action} {action} END {end_action}' <filename>
Examples:
awk '{print 1$}' tdclass -->first column it returns
awk '{print 1$,3$}' tdclass -->first 3 columns it returns(1-3 columns)
GREP
GREP-->GLOBALLY SEARCH A REGULAR EXPRESSION AND PATTERN
Useful for identifying a partial / full string in the file.
Syn: Grep <text> <filename>
Ex: Grep vinay tdclass
Grep "td class" tdclass --> Two words validation
Grep vinay tdclass tdclass1 -->multi file verification
Grep vinay * --> All files verification
CHMOD
CHMOD : Changing Mode
Useful for assigning and removing privileges / permissions
Users Group Owners
r w x r w x r w x
Octal notation : r --> 4 w-->2 x-->1
Examples:
chmod u+w tdclass --> Users write access
chmod o+x tdclass--> Owners execute access
chmod 000 tdclass--> No access to owners ,groups and users
chmod 724 tdclass->Users Full access,Group write,Owners read
chmod 777 tdclass-->Full privileges to Users,Owners and Group
HEAD
HEAD-->DISPLAY FIRST LINES OF THE FILE
SYN : Head -n <Filename>
EX: Head -2 tdclass
TAIL
TAIL-->DISPLAY LAST LINE OF A FILE
SYN: Tail -n <Filename>
EX: Tail -2 tdclass
REAL TIME: To see header and Footer information embedded
in the data
To eliminate header and footer while loading
the data etc..
CREATING HIDDEN FILE
Cat > .tdclass
PS
PS COMMAND:(PROCESS STATUS COMMAND)
REAL TIME :
a) To identify processes running
b) To kill / abort /terminate /halt process
etc...
Process is nothing but an instance of the Executing Program
There are two important terminologies:
a) PID (Process ID) b) PPID (Parent Process ID)
KILL
KILL command: Kills the process
Syn: Kill [-Signal] processid
Ex: a) Kill 237
b) Kill =15 237
Signal : Helps the system to implement the option to the
process id
0-> Null Signal
2-->Hangup
3-->Quit
15-->Terminate
VI EDITOR
VI EDITOR:(VIRTUAL INTERPRITER / INTERFACE)
Syn:
VI <filename> <Enter Key>
By pressing Escape with the below characters enter the data
A or a
I or i
O or o
To goto the next / previous characters use the below
L H J K
TO GOTO 3 LINES BACK WE USE 3K / 3H / 3I
W->ONE WORD FORWARD
2W->TWO WORDS FORWARD
P->ONE WORD PREVIOUS
2P->TWO WORDS PREVIOUS
$-->END KEY
^ OR Q --> Home Key
H--> Beginning of the Page
M->Middle of the Page
L->End of the page
x->deleting character
CTRL + D -->DELETING LINE
CTRL + W --> DELETING WORD
CTRL DD->CUT
CTRL P-->PASTE
: W <FILENAME> // W FOR SAVING
: q! //Quitting
: wq! //Save and Quit
: set nu // assigns line numbers
:set nonu //removing line numbers
:3 //going to third line
NOTE: FOR MORE DETAILED COMMANDS REFER TO THE SOFTCOPY DOCUMENT
GIVEN AT VINAYTECH HOUSE INSTITUTE.
I cannot thank you enough for the blog.Thanks Again. Keep writing.
ReplyDeletepython training
angular js training