Click here for Unix session 1
To go to Session 1 click here
To go to Session 2 click here
To go to Session 3 click here
To go to UNIX basic commands click here
Online sample UNIX TERMINAL click here
To go to Session 1 click here
To go to Session 2 click here
To go to Session 3 click here
To go to UNIX basic commands click here
Online sample UNIX TERMINAL click here
Visual editor
Helps in
Inserting and deleting text
Replacing text
Moving around a file
Finding and substituting string
Cutting and pasting text
Reading and writing to other text
While working in vi editor the content of the current file is stored in buffer and we work on that only atlast we may save the changes or quit without saving
Vi editor mode
Command mode – in this what ever been typed is interpreted as command only cant insert data into file
Insert mode – to enter into insert mode press ‘I’ in this mode what ever u type is included as text into file to exit from this mode press escape
Ex command mode – this allows us to give commands the end of the editor we these types of command and these command starts with :
Starting vi deitor
Vi filename – creates a new file
View filename – view file in read only mode
Exiting vi editor
:w – write the buffer to disk
:w filename – write the buffer in the given filename
:wq - write the buffer to disk and quit
:zz - write the buffer to disk and quit
:q! – quit without writing edit buffer to disk.
To insert text vi editor
a – append text after cursor
A – append text at the end of line
i – insert before cursor
I – insert text beginning of line
o – open a blank line after the current line for the text input
O - open a blank line before the current line for the text input
Deleting text
x- delete charac at cursor
dh- delete char before cursor
nx-delete n char at cursor
dw- delete next word
db- delete previous word
dnw- delete n words from cursor
dnb- delete n words before cursor
d0- delete to beginning of line
d$- delete to end of line
D- delete to end of line
dd- delete current line
d(- delete beginning of sentence
d)- delete to end of sentence
d{- delete to beginning of paragragh
d}- delete to end of paragragh
ndd- delete to lines(starts at the current line)
copy lines
yy- copy 1 line to buffer
nyy- copy n lines ro buffer
P- out the contents in buffer aft current line
p- put the contents in buffer before current line
cut and paste
ndd – cuts/deletes n lines and places it in buffer
P- out the contents in buffer aft current line
p- put the contents in buffer before current line
Find and replace
/str – search forward for str
?str – search backward for str
N – repeat the previous search in reverse direction
n- find the next occurrence of current string
:s/old/new find and replace first occurrence in current line
:s/old/new/g find and replace all occurrence in current line
%s/old/new/g find and replace of all occurrence in current file
%s/old/new/gc find and replace of all occurrence in current file with y/n option prompt before every replace.
Setting options
:Set ai – set auto indent
:Set noai– set off auto indent
:set nu- set line number on
:set nonu- set off line number
:set scroll=n set the number of lines to be scrolled
:set sw=n set width to n;
:set wm= set wrapmargin to n .
Unix access and permissions
Unix is a multi user system. Each file and directory In unix can be used by many users.
Permissions for file or folder are
r – read
w- write
x- execute
permissions are controlled at three level
u- user
g- group
o-others
ls –l displays file/folder permission
drwxrwxrwx in this d denotes directory, rwx denotes (read,write,execute) permission for user , rwx denotes (read,write,execute) permission for group, , rwx denotes (read,write,execute) permission for owner
chmod command
used to change the permission of a file or folder
chmod a+r jc.txt adds read permission to all users
chmod o-r jc.txt removes/revokes read permission for others
chmod og+rx jaya.txt adds read and execute permissions for group and others
chmod +w * add write permission to all files for users.
Permissions by numerical or octal
File access permissions can also be given using numerical or octal values
Permission and values:
r- 4(read only)
w-2
x-1
0 – no permission
1 – execute
2 – write only
3 – write and execute (1+2)
4 – read only
5 – read and execute (4+1)
6- read and write(4+2)
7 – read,write and execute(4+2+1)
E.g chmod 777 jayachandran.txt
The above example gives read,write and execute permission to all (owner,user,others)
Process
Instance of an executing a program is called process.
A program called SCHEDULER runs in the memory and decides which process should get the CPU
Process ID
In unix every process has a unique id called process id.
Command ps:
Ps – shows list of process running with its id time and command
optiions
-a process of all users
-u username process of a particular user
-t tty –process of a particular terminal
-f full listing of information
-e listing of the system process (Daemons)
Kill command
Kill – command is used to send a signal to a process mostly this will be kill signal.
Syntax
Kill [signal] pid
Signal
STOP
CONT
-l
SHELL
When ever you log in you are placed in a shell, shell works as an interpreter , every command we enter is passed to operating system.
To determine your shell
Echo $SHELL
Types of shell
Bourne shell
C shell
Korn shell
Tc shell
Bourne again shell
Communication in UNIX
Write – two way communication with any person who is currently logged on.
write – username
mesg – controls the messages sent by other users
mesg n – prevents others user to write to your terminal.
mesg y – allows other users to write to your terminal
mail – to send mail to user you can send mail even if that user is not logged in.
mail username
subject: <subject of mail>
<text>
<ctrl+d to exit from mail >
to do this you need mailx in your system
Hello Jaya,
ReplyDeletecan u please help me to do with small and simple programs with the help of above commands...
Thanks for your informative commands. Keep Rocking :) :) :)
ReplyDelete