Types of Users
1. Root User : User ID (UID) and Group ID (GID) are same and it is ‘0’
2. System Users : UID and GID are in between 1 to 499 (deamons or processes)
3. Normal Users : UID and GID are in between 500 to 60,000
//All the above said values are by default//
We can grab this information in the file /etc/passwd
To create user for example
# userad sasi
# passwd sasi

Above table defines the permissions for a user on normal file or directory file as per umask (detailed explanation in RH 133) value
i.e. 644 for a file and 755 for a directory
6 – read+write, 5 – read+execute and 4 – read only and 1 - execute
So 644 => owner have read and write, Group have read and Others also have read permissions.
To change the permissions, we have 2 types
Symbolic and Numeric
Symbolic: -
r – read u – owner of the file
w – write g – group
e – execute o – others
a – combination of u, g and o
‘+ ‘- to add permission
‘- ‘- to remove permission
‘=’ – to assign permission
# chmod //command to change the permission for file and directory//
Example: -
# chmod u-w+x, g+w, o+x
The above command will remove write and add execute permissions for owner and
add write permissions to group and add execute permissions to others.
And # chmod a-r
And # chmod a = -
Numeric: -
r – 4 Numbers 1 to 7
w – 2 x – 1, w – 2, wx – 3, r – 4, rx – 5, rw – 6, rwx - 7
e - 1
Ex: - # chmod 777
For a file: -
Default permissions of root user – 644
Default permissions of normal user – 664
For a directory: -
Default permissions of root user – 755
Default permissions of normal user – 775
# chown //is the command to change the user permissions for a file or directory//
Ex: - # chown Sasi file5 //now user Sasi is the owner of the file – file5//
To check the same # ls –l Sasi
# chgrp Sasi file6 //to change the user Sasi as a group for the specified file6//
# chown root:root file7 //to change owner and group at a time//
Standard Input and Output PIPES
0 – input device specifier - Keyboard
1 - output device specifier – Monitor
2 – error redirection
If we press something on the key board, then 0 will be append and then confirms that something coming from keyboard //input – askey to binary and binary to askey//
Ø Input redirection (Symbol ‘<’) Ex: - # cat <>’)
Ex: - # ls –l > file10 //to display the output of ‘ls –l’ command in a new file – file10//
Ø Error redirection
If we know that the command is wrong and gives the error, and we would like to append the
output in a file then do
# call 2> file11
Also if the output is right or wrong, in both the cases we can append the output in a file as
# call &> file12
PIPES
Output of the first command will be the input for the second command
Ex: - # ls –l wc
# cat file13 sort –n
# cat file14 sort uniq //uniq is the command to delete duplicate words//

Tee
Tee is the command to display the out of the file on the monitor for 1 time and save the
output in a file.
Ex: - # cat file15 tee file16 sort tee file17 uniq tee file18
Tip: - # echo $? //to display exit states of a command//
Text processing tools
1) cat: - concord nation of 2 or more files
Ex: - # cat file1 file2 file3
2) less: - pager programme *To see the big file as pages
Ex: - # less file1
Use ‘enter’ key to see line after line
Use ‘spacebar’ key to see page after page
Use /keyword – to search particular words in that file page (It will highlight)
Use arrow keys to move also
3) more: - Same like ‘less’ command, but here we cannot use arrow keys
4) head: - By default it displays first 2 lines of a file
Ex: - # head /etc/passwd
Suppose if we want to see according to our requirement, then we can give the
number in the command as follow,
# head 3 /etc/passwd //to display first 3 lines//
5) tail: - opposite to the command ‘head’
By default this command displays the last 10 lines of a file.
# tail /etc/passwd
6) grep: - To search some pattern
Ex: - # grep
# grep root /etc/passwd
# date grep 10
# grep –v root file8 //to display the pattern which is not having the word ‘root’//
# grep –n root /etc/passwd //switch ‘-n’ means number -
- number of lines where the root pattern is matching//
Useful switches here: - ‘-c to count the lines, -cv and –nv are same as the above examples//
7) sort: - for sorting lines of text files
# sort –n //numeric sorting - compare according to string numerical value//
# sort – g //genaral numeric sorting - compare according to general numerical value//
# sort – r //reverse sorting - reverse the result of comparisons//
# sort –nr //numaric and reverse//
8) uniq: - to remove all continiously repeated words
# uniq –u file3 //to filter duplicates//
# uniq –d file4 //to display only duplicate ones//
9) sed: - stream editor – to search some pattern and replace with other
sed is a stream editor. A stream editor is used to perform basic text transformations on an input
stream (a file or input from a pipeline). While in some ways similar to an editor which permits
scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently
more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it
from other types of editors
Ex: - # sed ‘s/kw/kw/’ file2
Suppose we want to replace only in particular line number then do
# sed ‘4s/kw/kw/’ file 3 //4 is line number//
but this will replace only first word in every line. If we want to replace all the words then do
# sed ‘s/kw/kw/8 file 4 //8 means globally//
Suppose if we need multiple replacements then do
# sed –e ‘s/roo/ttt/’ –e ‘s/login/ttt/’ file 5
10) wc: - word count
Ex: - # wc –c file2 //to count characters in a file//
Like the above we have switches –w for words and many more//
11) tr: - translate or delete characters
Ex: - # tr ‘a-z’ ‘A-Z’ < /etc/passwd # tr ‘:’ ‘*’ < /etc/passwd //here only one symbol or character will work// 12) aspell check: - to check the spelling with in file //for perminant changes// Ex: - # aspell check file1
Editors
VI editor
We have multiple mode over here, they are
Command mode, insert mode, execution mode and visual mode
Ex: - # vi file1 //will enter in to command mode//
Then press i, it will come to insertion mode. Then press escape key, it will be in execution mode.
In execution mode we have some commands like
:wq //here : means execution mode//
:w //w means save//
:q //exit the file with out saving//
:wq //save and exit//
:q! //force quit//
:wq! //force save and quit//
Command Mode: -
1. Use arroe keys to move curser up, down, right and left in the file
2. Use H in place of left arrow, K in place of up arrow, L in place of right arrow, J in place of down arrow.
3. Use yy (yank) to copy the line
4. Use dd to delete the line and use P to paste the content
5. Use CC to cut the line
6. Use command: ZZ to Save changes and quit
7. Use U to udo the action
8. Press W to move word by word forward and B for backward
9. Use braces ( to move sentense by sentense backward and ) for forward
10. Use braces { to move paragraph by paragraph backward and } fro forward
11. Use o to open a new line below the curser position
12. Use O (upper case) to open a new line above the curser position
13. Use A (upper case) to go to end of the line
14. Use I (upper case) to go to starting of the line
15. Use G (upper case) to Move cursor to end of file
16. Use combination of all the above keys if necessary like below
Y( and Y).
17. Use ‘set nu’ to set the line numbers and ‘set nonu’ to remove the line numbers
To replace the words in the insertion mode use below for example
:1,4s/root/redhat/g //from 1 to 4 lines replacing the word root with redhat//
us :% if we required to do the change in entire file.
The below table will explain some other functions
h/j/k/l to Move cursor left/down/up/right
spacebar to Move cursor right one space
-/+ to Move cursor down/up in first column
ctrl-d to Scroll down one half of a page
ctrl-u to Scroll up one half of a page
ctrl-f to Scroll forward one page
ctrl-b to Scroll back one page
M (shift-h) to move cursor to middle of page
H to move cursor to top of page
L to move cursor to bottom of page
W to move cursor a word at a time
w5w to move cursor ahead 5 words
B to move cursor back a word at a time
b to move cursor back a word at a time
5b to move cursor back 5 words
e to move cursor to end of word
5e to move cursor ahead to the end of the 5th word
0 (zero) to move cursor to beginning of line
$ to move cursor to end of line
) to move cursor to beginning of next sentence
( to move cursor to beginning of current sentence
G to move cursor to end of file
% to move cursor to the matching bracket.Place cursor on {}[]() and type "%".
'. to move cursor to previously modified line.
'a to move cursor to line mark "a" generated by marking with keystroke "ma"
'A to move cursor to line mark "a" (global between buffers) generated by
marking with keystroke "mA"
]' to move cursor to next lower case mark.
[' to move cursor to previous lower case mark.
Editing commands:
i - Insert at cursor
a - Append after cursor
A - Append at end of line
ESC - Terminate insert mode
u - Undo last change
U - Undo all changes to entire line
o - Open a new line
dd - Delete line
3dd - Delete 3 lines.
D - Delete contents of line after cursor
C - Delete contents of line after cursor and insert new text.
Press esc key to end insertion.
dw - delete word
4dw to delete 4 words
cw to change word
x to delete character at cursor
r to replace character
R to overwrite characters from cursor onward
s to substitute one character under cursor continue to insert
S to substitute entire line and begin to insert at beginning of line
~ to change case of individual character
ctrl-a to increment number under the cursor.
ctrl-x to decrement number under the cursor.
/search_string{CR} to search for search_string
?search_string{CR} to search backwards (up in file) for search_string
/\
n to find next occurrence of search_word
N to find previous occurrence of search_word
. to repeat last command action.
Terminate session:
Use command: ZZSave changes and quit.
Use command line: ":wq"Save (write) changes and quit.
Use command line: ":w"Save (write) changes without quitting.
Use command line: ":q!"Ignore changes and quit. No changes from last write will be saved.
Use command line: ":qa"Quit all files opened.
Interactive Commands:
Marking a line:
Any line can be "Book Marked" for a quick cursor return.
Type the letter "m" and any other letter to identify the line.
This "marked" line can be referenced by the keystroke sequence "'" and the identifying letter.Example: "mt" will mark a line by the identifier "t"."'t" will return the cursor to this line at any time.A block of text may be referred to by its marked lines. i.e.'t,'b
vi line buffers:
To capture lines into the buffer:
Single line: "yy" - yanks a single line (defined by current cursor position) into the buffer
Multiple lines: "y't" - yanks from current cursor position to the line marked "t"
Multiple lines: "3yy" - yank 3 lines. Current line and two lines below it.
Copy from buffer to editing session:
"p" - place contents of buffer after current line defined by current cursor position.
vim: Shift a block of code left or right:
Enter into visual mode by typing the letter "v" at the top (or bottom) of the block of text to be shifted.
Move the cursor to the bottom (or top) of the block of text using "j", "k" or the arrow keys.Tip: Select from the first column of the top line and the last character of the line on the bottom line.Zero ("0") will move the cursor to the first character of a line and "$" will move the cursor to the last character of the line.
Type >> to shift the block to the right.Type <<>
Note: The number of characters shifted is controlled by the "shift width" setting. i.e. 4: ":set sw=4"This can be placed in your $HOME/.vimrc file.
VIM editor or Visual Improved Editor
This is the advanced VI editor, where we can create multiple windows with in the single editor as shown in the below picture.
Ex: - # vim file1
We can split the screen to windows by using the following functions
Press Ctrl+w and say S //for horizontal window//
Ctrl+w and say V // for vertical window//
Say ctrl+ww or ctrl+w and arrow keys to switch between the windows
In each and every window we can use normal and all the VI editor commands and functions.
VIM editor is mainly used by programmers.

