Unix
Unix
Contents:
Introduction to UNIX
UNIX Architecture
UNIX Command
The vi editor
Introduction:
UNIX Architecture
UNIX Architecture
UNIX Architecture consists of two parts:
Shell
Kernal
Shell: A Unix shell is a command-line interpreter.
Kernal: A Unix kernel is a computer program that manages
input/output requests from software and translates them
into data processing
UNIX Commands
touch
wc
ls
sort
cat
uniq
cp
cut
mv
grep
rm
head
chmod
tail
pwd
mkdir
rmdir
cd
who
date
df
du
am i
find
man
nohup
ps
kill
sed
SREE NIPUNA SOFTWARE
SOLUTIONS
ls command
Syntax:
ls <option>
ls -l
List all files and directories from current directory
in long format.
ls -a
Display all files including hidden files.
10
ls -la
Using multiple options at a time.
11
touch
Syntax:
touch <filename>
12
cat
Syntax:
cat <filename>
13
cat
Syntax:
14
cat
Syntax:
Creates a file with new file name and open for editing.
Use ctrl+d keys to exit edit mode
Opens an existing file in overriding mode.
Syntax:
Creates a file with new file name and open for editing.
Use ctrl+d keys to exit edit mode
Opens an existing file in appending mode.
15
cp
Syntax:
16
mv
Syntax:
17
rm
rm <option> <filename>
rm command remove files from current directory.
Rm command cant remove directories.
Syntax:
18
wc
wc <option> <filename>
wc command displays number of new lines, words and
Number of bytes from file.
Syntax:
Cont..
19
wc
Cont..
20
wc
21
wc l <filename>
22
sort
sort <filename>
Sort command will sort the data in file based on first
column.
Syntax:
Cont..
23
uniq
uniq <filename>
uniq command remove the duplicates that are sequenti
present in a file.
Syntax:
Cont..
24
uniq
Cont..
25
uniq
Cont..
26
pwd
Syntax:
pwd
27
chmod
chmod command changes the permissions
of a file.
28
chmod
Syntax:
29
30
grep
Syntax: grep <pattern> <file name>
grep command search for a pattern
in a file and print.
31
head
Syntax: head <option> <file name>
head command displays top 10 lines of file.
32
33
34
mkdir
Syntax:
35
rmdir
Syntax:
36
cd
Syntax:
cd <directory name>
37
du
Syntax:
du
38
du -h
Syntax:
du -h
39
df
Syntax:
df
40
df -h
Syntax:
df -h
41
ps
Syntax:
ps
42
ps -ef
Syntax:
ps -ef
43
kill
Syntax:
44
date
Syntax:
date
45
sed
Syntax:
46
sed
Syntax:
47
sed
Syntax:
48
nohup
Syntax:
49
who am i
Syntax:
who am i
50
man
51
find
Syntax:
52
The vi editor
Stands for Visual Editor.
Modes of operation
- Command mode
- Insert mode
- The ex command mode
53
The vi editor
54
The vi editor
55
The vi editor
56
57
Sample script
c
om
en
Following commands
Needs to be executed
58
Output
59
Name.sh
Output:
60
Defining variables
Variable name=variable value
61
Special variables
$0 - filename of the current script.
62
Relational operators
-eq - Equal to
-ne - Not equal to
-gt - Greater than
-lt - less than
-ge - Greater than or equal
to
-le - Less than or equal to
SREE NIPUNA SOFTWARE
SOLUTIONS
63
If.else
if<condition>
<statement>
fi
if<condition
>
<statement
>
Else
<statement
>
fi
If<condition>
<statement>
elif<condition
>
<statement>
Else
<statement>
SREE NIPUNA SOFTWARE
SOLUTIONS
fi
64
If.else
#!/bin/sh
a=10
b=20
if [ $a == $b ]
then
echo "a is equal to
b"
fi
if [ $a != $b ]
then
echo "a is not equal
to b"
SREE NIPUNA SOFTWARE
SOLUTIONS
fi
65
Some Syntaxes
case...esac
while command1;
do
Statement(s)
while command2;
do
Statement(s)
done
Statement(s)
done
SREE NIPUNA SOFTWARE
SOLUTIONS
66
pmcmd Syntax
#!/usr/bin/bash
pmcmd startworkflow
-sv $INT_SVC
-d $INFA_DOMAIN
-u $INFA_USERID
-p $INFA_PWD
-f $INFA_FOLDER
-w $WORKFLOW_NAME
SREE NIPUNA SOFTWARE
SOLUTIONS
67