Linux
It is a free ware operating system. It was first developed by Linux Torvalds in 1990’s. Linux is a multiuser, multi tasking and multi programming operating system. Linux is a fast growing operating system, it is popular among Windows users, who want to try something that gives them more speed, more power and more control. People use it for web servers, file servers and work stations, instead of traditional UNIX venders as well as Windows NT. The Linux Kernal was originally designed by Linux Torvalds at the University of Helsinki in Finland. Linux operating system is free software. Anyone can down load the source from the Internet or buy it on it on a low cost CD ROM. Linux cannot be technically referred to as a new version of UNIX, while at the same time Linux offers all the common programming interfaces of standard UNIX. GNU Linux and Unix Workstations or Nodes may be ‘Intelligent Terminal’ or ‘Dumb Terminal’ but Windows NT will work in ‘intelligent terminal’ only.
Intelligent Terminal: - These systems have CPU and Hard disk and all processing work will be at this system.
Dumb Terminal: - These systems have no CPU but it may contains a Hard disk. All process of these systems are at the server only.
Linux Features
1. Multi user, Multi tasking and multi programming : - Multi user means more than one user can work with the Linux operating system loaded in a machine. We can perform more than one task at a time in Linux system. So it is multi tasking operating system. And also execute more than one program simultaneously.
2. Powerful : - Linux is a powerful operating system.
3. Piping and Redirection : - In Linux piping and redirection is also possible. Piping means the output of one command will be the input of another command .While redirection means the output of one command is stored into a file.
4. Security : - Linux operating system provides good level of security. (1) System Security: - For system security Linux users are divided into two i.e., Super User and Ordinary Users. Super user is the owner of the systems or he is the person who looks after the Linux system. He have full permission is his system. While at the same time, ordinary users are those who work in those systems. They have restriction in the system. Every user has their own ‘login name’ and password. ‘Root’ is the login name of super user, but the login name of ordinary users will be different. Every one can select their own password. The only way to get into a Linux system is by giving a ‘login name’ and ‘password’. (2) File permission: - To access a file, permission of its owner is necessary. File permission is divided into three; they are (a) Read permission, (b) Write permission and (c) Execute permission. (3) Encrypted data files.
5. Kernel & Shell: - Shell is a program that acts as a buffer between you and the operating system. Its role as a command accepter and interpreter. These shell support large number of command features like, ability to direct input and output, manipulate groups of files with a command and also be support simple programming. Linux is a multi user operating system so there is more than one user and shell. It is a ‘GNU’ tool.
Kernel is the core of Linux system which is a set of functionality for doing basic functions and file management. Kernal consists of a set of file routines each of which is capable to doing a particular task.
System software for managing file system and memory etc. will interact with the hardware using functions implemented in the Kernal. This function is called System Calls.
Only Kernel can directly access hardware. Shell connect user with the Kernal. No user can direct access with Kernel and no shell have direct access with hardware. Users will give instructions to shell with the help of commands or utilities. Then shell connects with Kernel and Kernel with hardware. The main advantage of all these setup is that when the operating system to be rewritten for a processor. Only the Kernal have to be rewritten in specific assembly language instruction. The rest of the operating system can be loaded in any of the high level language like ‘C’.
6. Background processing: - Linux support background processing which allows a user to initiate a task and proceed to other activities. For example system can be starting a file and printing a report on behalf of a user at the same time then the user can edit the document. This process helps user to be more effective in using system and in accomplishing more work in a given period of time.
7. File system: - File system of Linux operating system is “ext 2”.it is a tree structural file system.
Linux - ext2, ext3,
UNIX - inode,
Dos - fat16,
Windows98 - fat32,
Windows NT - NTFS.
8. C, C++ programming: - In Linux we can do C and C++ programming.
9. Software tools : - Linux include plenty of utility program used for different function.75% of these tools is included under GNU project. All these tools are more power full and these help to accomplish many tasks without writing many programs. It provides security, identity and priority for each user. Too many editors also in Linux like vi, emacs, mcedit, etc.
10. Communication: - The user belongs to the system can communicate with each other. For this Linux provides many useful commands. These commands not only help to communicate with the user even he or she is not logged in the system. Also access internet through Linux operating system, if the system have internet connection.
11. X-Windows :- Linux is a GUI software ie graphical user interface operating system.”GNOME” and KDE are two GUI tools in Linux OS.
12. Good documentation :- In Linux everything is documented properly, it is very useful for the users in Linux.
Limitations
1. Not user friendly :- Linux is not user friendly as windows. Commands in Linux is not very easy for the average users to follow.
Different directions in Linux root directory:
/ à This is the root directory in Linux. This is similar to ‘(c:)’ in windows.
This directory so many sub-Directory files, they are:
/bin & /sbin à This directory contain user command and essential system commands, this getting up the Linux system.
/boot à This directory contain Kernel files, map files, boot loaders, m chain loaders etc.
/dev à It contain device files.
/etc à All configuration files are in this directory.
/home à This is the user directory. All users directory is in this. Users files are in their own directions.
/lib à
/mnt à
/proc à
/root à Directory of super user ‘root’. His personal files are the condence.
/tmp à
/usr à Directory contain ‘man’ files that is half files, hedder files of ‘C’ , Games and other directory files for special purposes.
/var à Pre-defined or pre-determined or set function some man files, etc.
To load ‘Linux’ operating system and login to a Linux.
· Type ‘Lux’ at ‘LILO BOOT :’
· Now, Linux OS will Boot
· Give the user name is Login Name.
· Give Password.
use small letters only.
Shell Commands.
Linux commands are not the same as standard Unix ones. They are better because most of them are provided by the Free Soft ware Foundation (FSF). GNU means “GNU’s not Unix” – the first word of the phrase doesn’t stand for anything. Programmers on the GNU project have managed to create new versions of Standard Unix tools that have more features, run faster and more efficiently. At the same time, some people wrote tools specifically for Linux to deal special issues that only Lunix supports.
All commands are interpreted by the shell. The shell is simply a program that accepts commands from the user and executes them. Different shells sometimes use slightly different syntax to mean the same thing.
$ clear à To clear the screen. [Press Ctrl + L].
$ date à Display current system date and time.
Mon Dec 29 7:50:45 IST 1997.
$ date +%T à Display the time format.
$ date +%H à Display the Hour part of time format.
$ date +%M à Display the Minute part of time format.
$ date +%S à Display the Second part of time.
$ date +%D à Display the date part
$ date +%d à Display the date
$ date +%m à Display the month in numerically.
$ date +%y à Display the year, Example 00 (for 2000).
$ date +%Y à Display the year, Example 2000.
$ date +%h à Display the month, Example Jan, May, etc.
$ date +%B à Display the month in full Example June, July.
$ date +%a à Display the weekday Example Mon, Tue.
$ date +%A à Display the weekday in full Example Monday.
$ date +“AAA %T” à Display a message and time
$ date +“%D AAA %Y” à Display the options with a message.
$ date +“%n AAAA %t %D” à Display message and options. %n --- for insert new line, %t --- forget a tab space.
NOTE :-
(a) ‘é’ arrow Key à To display or to get last commands given.
This is a history option that provides all the previous commands. For this, in each user area Linux maintain a history file that contains all the commands that he tried. Use ‘é’ & ‘ê’ arrow keys to scroll previous commands.
(b) ‘Shift + Pageup’ à To display the previous screens. Use ‘Shift + Pageup’ and ‘Shift + Pagedown’ for screen scrolling. You will get only last 14 screens.
$ cal à Display the calendar of the current month.
$ cal -y à Display the whole calendar of the current year.
$ cal 7 1990 à Display the calendar of the July 1990.
$ cal 2 2020 à Display the calendar of December 2020.
$ cal 2020 à Display the calendar of 2020[whole month].
$ cal –j à Display the calendar of current month in ‘365 day format’.
$ cal –jy à Display the calendar of whole year but in ‘365 day format’.
More à This command is for ‘page-wise’ display of the specified command. ‘More’ command any be used with all function. If the output of any command is long, then using ‘more’ you will get page wise display of output.
Ex: $ cal –y | more
Less à Less is similar to ‘more’ command but it allows backward and forward movement of output. ‘q’ to quit.
Ex: $ cal –y | less
$ uname à Display the name of operating system
$ uname -v à Display the version of the operating system.
$ uname –n à Display the node name of the system
$ uname -a à Display the full details about the operating system.
$ logout à To exit or to quit from a login
$ exit à To exit or to quit from a login (Ctrl+d)
Press ‘Ctrl+Alt+del’ à To shut down and restart a linux system.
Different files in Linux :-
Ordinary file à ASCII text file created using cat, vi, or any other editors.
Directory files à Files used to store ordinary files, sub- directory files, etc. Files created using “MKDIR” command.
Device files à Files which represents peripheral devices.
Linked file or symbolic link file à These are link files of “ASCII” text files.
Directory file commands :-
$ pwd à Display the present working directory and path.
$ ls à Display the contents of the current directory file
$ ls –p à Display the files and directories separately.
$ dir à Similar to ‘ls’.
$ mkdir à To create a new directory file in current directory
>>> mkdir <directory name>
$ cd à To change directory or to open a sub-directory.
>>> cd <directory name>
$ cd .. à To close current directory i.e., change to parent directory
$ cd\ à Close all other directory and change to home directory.
$ rmdir à To remove the empty directory.
>>> rmdir <directory name>
$ rm –r <directory name> à To remove the directory which is not empty
Ordinary file commands :-
$ cat > (file name) à to create a new file.
$ cat (file name) à display the contents of an existing file.
$ paste (file name) à display the contents of an existing file.
cat >> <filename> à to append contents to an existing file.
cat –b <filename> à display the contents with line number.
cat –e <filename) à mark line end with ‘$’ sign.
cat –t (file name) à mark tab space with the orgin “I”
paste –s(file name) à display the contents horizontally
tee (file no create a file (new file)
tee –a (file name) à To append data to an existing file.
Display the condence of multiple files:
Cat <1st file name> <2nd file name> <3rd file name>……… -> Display the condence of all the files in the specified order. That is first ‘<1st file>’ ‘s condence then second, then third, like that
Hello Boys
Hello Girls -> AAA
Sorry Boys
Sorry Girls-> AAA
hello world
Season Boys -> AAA 2
Paste <1st file> <2nd file> <3rd file> => Display the condence of multiple files using ‘paste’ function difference is, it will merge lines of files.
Examples paste AAA AAA1 AAA2
AAA AAA1 AAA2
Hello Boys Sorry Boys Hello world
Hello Girls Sorry Girls hello madam
Paste –s <1st file> <2nd file> <3rd File> => This will display as below . (-s serial )
Example paste –s AAA AAA1 AAA2
Hello Boys Hello Girls => AAA
Sorry Boys Sorry Girls => AAA 1
Power India hello madam => AAA 2
Paste –d “ delimiter” <1st file> <2nd file> <3rd file> => While merging the lines of files we can separate file using any delimiter.
Example paste –d “|” AAA AAA1 AAA2
AAA AAA1 AAA 2
Hello Boys | Sorry Boys | hello world
Hello Girls | Sorry Girls | hello madam
MV=> This command used to rename a file
Example MV<current name> <new file name>
CP => This command used to copy a file from one directory to another.
Examples CP <source file> <Target position>
RM => To delete files.
Examples RM <file name> => To delete a particular file.
RM l* => Delete those files which starting character of the file name is ‘l’
WC => To display the number of lines, words and character in the specified file
Examples WC <file name>
WC –l <file name> => Display number of lines in the specified file.
WC –w <file name> => Display number of words in the specified file.
WC –C <file name> => Display number of character in the spepcified file.
Head => This command will display the first 10 lines of the specified file.
Head <file name>
Head –n <file name> => Display the specified number of lines of the file
Example Lead -5 <file name> => Display first five lines.
Tail => This command will display the last 10 lines of the specified file.
Tail <file name>
Tail –n <file name> => Display the last ‘n’ lines of the specified file.
Tail -5 <file name> => Display the condence of a file from the nth line to the end.
Tail +15 <file name> => Display from 15th line to the end of the file.
Cut => This command is to cut the character or fields from a file.
Cut –c n <file name> => Cut and display the nth character of all the lines form the specified file.
Example cut –c 5 <file name> => Cut and display 5th character of all the line.
Cut –c 15 <file name> => cut and display 15th character of all the line.
Cut –c 5, 15, 21 <file name> => Cut and display 5th 15th and 21st character of all the line of the specified file.
Cut –c 5-15 <file name> => In this case, cut and display character from 5th to 15th of all the lines.
Cut –c 5- <file name> => cut and display all the character from 5th to the end of all the line.
Cut –c -15 <file name> => Cut and display from first character to the 15th character of all the lines.
Cut –d “delimiter”
Cut –f <file name>
Example Cut-f 2, AAA
Cut-f 2, 1 AAA
Cut-F <Field No> -d ‘delimiter’ <file name>
Example cut-f 2-d “|” <file name>
Slit => using the command you can split one file to different pieces. This is to spliting a file.
Split –n <file name> <new> => split the specified file into pieces, which carring ‘n’ number of lines.
Example split-10 <file name> <file name> :- In this case file ‘AMERICA’ will split into small pieces which carring ‘10’ lines and store to the file ‘AAA’. But to display the condence of the file ‘AAA’ add suffix aa, ab, ac, ad, etc. with the file name ‘AAA’.
That is AAA aa
AAA ab
AAA ac
Rev => Reverse the chapters of all lines in a file
Example rev <file name>
Tac=> Reverse lines in a file
Example tac <file name> => Display file condence from bottom to top.
Sort => This function is used to sort data in a file. This will sort in ascending order.
Example sort <file name>
Sort –r <file name> => This function is to sort data in decending or reverse order.
Grep => Global Regular Expression printer. This utility program that search a file or more than one file for lines lines which contain strings of a certain pattern.
Option
-v -> Display all lines except those containing pattern.
-c -> Count the line which containing pattern.
-n -> Print line which contain the pattern with line number.
ð grep “pattern” <file name>
Piping => Piping means the output of one command will be the input of another
Command. To use to commands at at a time, we will use piping function. ‘|’ (pipe) sign is the operator for this function.
Example Cat AAA | More => cat and more are two function, but we use both at a time and place ‘|’ sign between two. The output will be page wise display of file ‘AAA’.
Rs | more => Dis[lay the current directory condence in page wise.
Ls –l | tee <file name> => This command will display the output on the screen and store the output to the specified file.
Redirection => Redirection means the output of one command is stored into a file.
Example 1s > AAA => This command is used to store the output of 1s-1 Long list of current directory condence into a file called ‘AAA’
Sort AAA> AAA>2 => This is to store the output of sort AAA that is sort the condecne of file AAA and store into the file ‘AAA2’.
Cat AAA AAA1 > AAA 3 => This command will store the output of Cat AAA AAA that is condence of both files will store to a ne file ‘AAA3’.
Cat AAA AAA1>> AAA => This will append the condencxe to the file ‘AAA3’.
Using Hyfen ‘-‘ with cat.
Mc => Midnight command in ‘LINUX”. This command helps to change directory, list directory condence, file condence using essay commands in ‘mc’. This command help us to edit on existing file. This is very useful to a user. Command in ‘mc’ is namely using function Keys. At the Bottom of the screen all functions and clearly specified that is
F1->
‘mcedit’ Editior
This is the editor of mc command or midnight command. Editors are those utilities or programs self us or user to create a new file, open existing for editing or for reading, etc.
Example mcedit <file name>
Help in Linux
Man => This command self the user to get detail information about a command. This is the most commonly using self utility in Linux.
Example man <command>
Man ls => To get the man page of ‘ls’ command.
Man sort => to get the man page of ‘sort’ command.
--help => this will provide a brief help about the specified command.
Which => this command helps to find the path of any command.
Example which <command>
Which ls :- Display the path at command ‘ls’. That is ‘/bin/ls
‘Vi’ Editor
This is the modified form of ‘Vi’ editor in Unix. Unix ‘Vi’ editor is not user friendly but Linux ‘Vi’ Editor is more good. ‘Vi’ contain two modes that is ‘command mode’ and ‘Insert mode’ or ‘Text mode’. At ‘command mode’ user can use some internal command of ‘Vi’. These commands are only characters. Insert mode is to store data into a file.
‘Ese’ key -> to change to command mode.
‘Insert’ key -> to change to command insert mode.
‘a’, ‘I’ -> also to change to insert mode.
‘Vi’ Editor
$Vi <file name> - To create a file. But we give this command we get a sheet, in it we are in the ‘command mode’ – this is to give commands. Press ‘Esc’ or ‘c’ to go to the ‘text mode’ - It is to type a text. Then we can type the contents of the file.
2 Modeß-------- Command mode
Text mode Esc or i
Commands.
Note:- When we give command, go to the ‘command mode’ from ‘Text mode’ using ‘Esc’
K - This is to move cursor up that is
J - This is to move cursor down that is
H - This is to move cursor left that is
L - This is to move cursor right that is
A - This is to insert text after the cursor
I - This is to insert text before the cursor
O - This is to insert line above the current line.
Q - This is to insert line below the current line.
X - This is to delete a character.
X - This is to delete a character before the cursor.
Dw - This is to delete a word
Dd - This is to delete a line.
D - Delete a line from the cursor to the end.
Shift + a - Delete a line from add text after the last character of the line.
2 dd – This to delete two line.
Alt + a –
Cut & Paste
Cut the line using the command ‘dd’ then move the using ‘h’ or ‘k’ or ‘l’ or ‘j’ then for paste ‘p’ – it is to paste above the current line, (cursor position)
‘P’ – It is to paste before the current line.
Copy & Paste
Copy using ‘yy’ – It is to get a copy of the line. Then go to place where it paste then paste using the command ‘p’ or ‘p’ - To paste.
P - This is to paste above the current line.
P - This is to paste before the current line.
YY - This is get a copy of the line.
Save & Quit from the Vi Edition (:wq or :q!)
1. Come to the ‘command mode’
2. Then give ‘:’ (colun), so the system automatically reach at the bottom of the screen.
3. Then give ‘wq’ for save and quit., for save only give ‘w’.
Note:- First give the ‘:’
W - To save the ‘vi’ Editor.
Q - To come out from the ‘vi’ Editor or quit ‘vi’ Editor.
Q! - Quit from the directory using ‘vi’ Editor, or for quit we give ‘:wq’. When it don’t work, that time use this.
Job Pausing or job staffing.
Use, “ctrl Z’ => to stop the current working ‘job’. (Temperarly stop)
Fg => to restore the stopped job or paused job.
Jobs => List all the paused jobs or finding job.
Fg <Job No.> => to restore a particular job.
Example fg4 => Restore the job no.4.
Ps => list all working process and their ‘PID’ No. That is process Identification Number.
Kill -9 <PID> => to kill a particular process or to stop a paused job permanently.
Communication commands.
Communication commands.
1. Write:- Write <login>
Message, then ctrl+ D.
Example $ write Cuo2
Hello, RAND
Ctrl+D
When we give the command ‘write’ login will be used by any one. That is to addressed login will be worked that is second person or whom the message goes (Cuo2, in example) he should be currently logged in or work in the system.
2. Mail
Mail <login name>
Message, then Ctrl + D
Example $ Mail Cuo2
Hello, RAND
Ctrl + D
Difference from the mail command and write command is :- for the ‘write’ command to work the second person should be currently logged in, but for ‘mail’ command it is not necessary that the second person should be logged in.
How in ‘mail’ command is sent the message?
If the second person is currently logged in he will get the message ‘you have mail’; otherwise the mail will be stored in the directory /user/mail. Then when ever he open it he get a message that ‘you have mail’. For seeing the message.
To see the mail message
Give $ Mail, Enter then we can see the mail message. Then come back to the ‘$’ give ‘q’ then enter.
$ wall à to send message to all working user (super user command).
User Details.
Who am I => This will display
Who am I = >
USERS
- Owner (u) – The person who create a file, he is the owner of that file.
- Group (g) – Group of person in which the owner belongs to.
- Others (o) – Users of UNIX O.S. Other than the group owners.
File In UNIX
- Ordinary files – ASCII files created using editors like cat, Vi etc.
- Directory files – Files created using MKDIR.
- Device file – Files which represent peripheral devices.
File permission.
- Read (r) – To read the contents.
- Write (w) – To modify the contents.
- Execute (x) – The contents of the file can be executed.
$ ls – l – (-l= long listing) This command will list the all detail about files and directory.
It display as follows:
-rw-r—r-- 1 cu01 group 35 Dec 13 7:05 a
-rw-r—r-- 1 Cu01 group 15 Dec 15 8:45 f1
-rw –r—r-- 1 Cu01 group 40 Dec 16 10:20 LCC
drw –r—r-- 1 Cu01 group 20 Dec 16 10:30 d1
Column 1-Type of file, that is ordinary file or directory. If ordinary file ‘_’,directory ‘d’
Column 2,3,4 – Permission for the owner ‘r’- read, ‘w’- write, ‘x’ – execute, but ‘-‘ is not permission.
Column 5,6,7 – Permission for the group owners
Column 8,9,10 – others
Column 11 – No of link to the file that is one file have more the one name.
Column 12 – Owner name.
Column 13 – Group owner.
Column 14 – Size of the file.
Column 15, 16, 17, - month, date and time of creation of file.
Column 18 – Name of file or name of directory.
Ch mod – To change the permission of a file.
$ c h m o d <user> <operation> <permission > <file name>
u assign (+) r
g w
o Remove (-) x
Example :- $ Ch mod u + x f1 – It is give permission to ‘u’ that is owner to execute the file ‘f1’.
Example :- $ chmod g + w f3 – It is give permission to ‘g’ that ios group owners to write the file ‘f3’
Example $ chmod o-r f5 – It is remove the permission to ‘o’ that is others to read the file ‘f5’
4 ls – l (file name) – It is for the long list of any particular file. Thr name we give its lone list will only display.
Example :- $ ls –l f1 – We can see the long list of ‘f1’ file.
Chmod – To change the permission of a file.
$ chmod ugo + x A1
$ chmod a+x A2
$ ch mod +x A3 This the to give permission to all for execute the file A1,A2,A3.
$Sh (file name) – Execute the file without giving permission.
Octal Notation.
IN the permission is given as number, every
permission have the value
Read’s value is 4,
write’s value is 2 and execute’s value
is 1. We want to give permission of all that is to read, write and
execute we give the total of that three that is
4+2+! Is ‘7’ we want any one, that is write and
execute we give ‘3’ that is 2+1. Permission to Read
and
Write we give ‘6’ that 4+2. If permission to Any
one that is Read only we give’4’.
Example :- $ ch mod 777 f1
$ ch mod 764 f2
$ch mod 000 f1 – It is to remove all permission for all from the file ‘f1’.
4 ch mod 700 f7 - This is to give permission to the owner for all that is read, write and execute. But at the same time remove all permissions of the group and other.