



















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




















































































In eighties, many organizations like IBM, HP and dozen other companies started creating their own UNIX. It results in a mess of UNIX dialects. Then in 1983, Richard Stallman developed GNU project with the goal to make it freely available UNIX like operating system and to be used by everyone. But his project failed in gaining popularity. Many other UNIX like operating system came into existence but none of them was able to gain popularity.
In 1991, Linus Torvalds a student at the University Of Helsinki, Finland, thought to have a freely available academic version of UNIX started writing its own code. Later this project became the Linux kernel. He wrote this program especially for his own PC as he wanted to use UNIX 386 Intel computer but couldn't afford it. He did it on MINIX using GNU C compiler. GNU C compiler is still the main choice to compile Linux code but other compilers are also used like Intel C compiler. He started it just for fun but ended up with such a large project. Firstly, he wanted to name it as 'Freax' but later it became 'Linux'. He published the Linux kernel under his own license and was restricted to use as commercially. Linux uses most of its tools from GNU software and are under GNU copyright. In 1992, he released the kernel under GNU General Public License.
Today, supercomputers, smart phones, desktop, web servers, tablet, laptops and home appliances like washing machines, DVD players, routers, modems, cars, refrigerators, etc. use Linux OS.
The Source Code of Linux is freely available to its Users.
The Source Code of UNIX is not available for the general public. Linux primarily uses Graphical User Interface with an optional Command Line Interface. UNIX primarily uses Command Line Interface. Linux OS is portable and can be executed in different Hard Drives. UNIX is not portable.
Linux is very flexible and can be installed on most of the Home-Based and Servers.
UNIX has a rigid requirement of the Hardware. Hence, cannot be installed on every other machine. Different Versions of Linux are: Ubuntu, Debian, OpenSuse, RedHat, Solaris, etc.
Different Versions of UNIX are: AIS, HP-UX, BSD, Iris, etc. Linux Installation is economical and doesn’t require much specific and high-end hardware.
UNIX Installation is comparatively costlier as it requires more specific hardware circuitry. The File systems supported by Linux are as follows: xfs, ramfs, nfs, vfat, cramfsm ext3, ext4, ext2, ext1, ufs, autofs, devpts, ntfs
The File systems supported by UNIX are as follows: zfs, js, hfx, gps, xfs, gps, xfs, vxfs. Linux is development by an active Linux Community worldwide. UNIX is developed by AT&T Developers
Architecture of Linux:
Linux architecture consist of inner most Hardware layer, kernel, shell, and outer application layer, as shown in fig 1.1. Each layer has different functionalities and different uses.
Fig 1.1 Architecture of Linux System
Application Layer: - Users interact with the system through varies applications such as office, games, etc. These applications run in outer layer of architecture.
Shell: - Shell provides environment to run any application. It provides interface to the user to interact with hardware. We can say that it converts higher level language to lower level language.
Kernel: - Kernel is the program which actually communicates with the hardware. Combining shell and kernel forms Operating System.
Hardware: - All the hardware components such as motherboard, CPU, hard disk, etc. are comes under this layer.
#reboot OR #init 6 To restart the system
#power off OR #init 0 To power off system.
#shutdown It shutdown system after 1 min
#shutdown - h 10 It shutdown system after 10 min and broadcast message to all users.
#shutdown - c It cancels shutdown timer and broadcast message to all users.
#shutdown now OR shutdown - h It immediately shutdown system.
#logout OR exit OR ctrl + d Logout from currently logged in user.
#hostname OR hostname - s Shows machine name
#hostnamectl Show detailed information about system
#uname -a It displays operating system kernel name.
#uname -r It display all information regarding system,
#free -h It display RAM information in human readable form
#lsusb It lists all available USB devices.
#lspci It list all PCI devices
#lscpu It list processor information.
#dmidecod e It display all hardware information.(root)
**#man ** Show manual of mentioned command
**#info ** Same as that of man command
**#whatis ** Display one line description of manual page. (#mandb command should use to update database manuals.)
# --help Show short description of manual page. – help is option thus, some command may not support this option.
**#which ** To know path of command file.
dd Delete current line dd Delete n no. of lines from current line dw Delete current word dw Delete n no. of words from current word yy Copy current line yy Copy n no. of lines from current line yw Copy current word yw Copy n no. of words from current word cc Cut current line and enter in insert mode cc Cut n no. of lines and enter in insert mode cw Cut current word and enter in insert mode cw Cut n no. of words from current word and enter in insert mode p Paste s Remove current character and enter in insert mode S Remove current line and enter in insert mode u Undo Ctrl+r Redo H Move cursor to the top of screen M Move cursor to the middle of screen L Move cursor to the bottom of screen G Move cursor at the end of file gg Move cursor at the beginning gg Move cursor at nth^ line / Search particular word/string/character n Show next search result N Show previous search result
i insert text at current cursor position I insert text at start of the current line a insert text just right of the current character A insert text at end of the current line o insert new line below the current line O insert new line above the current line r it replaces single character R replace multiple characters
Ex-mode, special executing mode, :q quit without saving :q! quit without saving forcefully :w save and stay in file :wq or :x save and quit :wq! save and quit forcefully :set nu set line numbers : Jump to nth^ line :set nonu remove line numbers :/ Highlight word/string/character :nohl Remove highlight :%s///g Find and replace old word with new word :! Execute any command on terminal without leaving editor
Visual Mode, this mode is used for selection.
File Operations:
we can use for read operation,
cat – cat command is used to get data of file as output on the terminal. Reading out large file leads to navigate in terminal, which require separate scrolling device (mouse). So, cat command is very useful in reading smaller files with few lines of data in command line. Example,
more – more command provides line by line navigation and page by page navigation in downward direction but, upward scrolling not possible. Example,
less – less command allow navigation keys for scrolling up and down. Thus, it is more useful command than any other four command. Example,
head – head command show few lines from top of the file. If head command is used without any option, it will show top ten lines by default. – n is used to give count of lines to be shown. Example,
tail – tail command show few lines from bottom of file. If tail command is used without any option, it will show bottom ten lines by default. – n is used to give count of lines to be shown. Examples,
be shown in ascending order. Options, -r to show output in reverse order -k to show output of arranged by sorting nth^ column. Example,
[root@server0 /]# tail /root/anaconda-ks.cfg [root@server0 /]# tail – n 4 /root/anaconda-ks.cfg
[root@server0 /]# cat /root/anaconda-ks.cfg
[root@server0 /]# more /root/anaconda-ks.cfg
[root@server0 /]# less /root/anaconda-ks.cfg
[root@server0 /]# head /root/anaconda-ks.cfg [root@server0 /]# head – n 5 /root/anaconda-ks.cfg
[root@server0 /]# sort file1.txt [root@server0 /]# sort – r file1.txt
copy contents of one file to another. If destination file is not exist in given location then automatically new file will be generated. Syntax, _#cp Example,
Redirectors with cat command:- Example, Display content of existing file,
Create a new file and provide writing into it.
Overwrite content of existing file.
Add content in existing file, (Append)
View content of files,
Copy content of one file to another file
Append content of one file to another file,
File content merging,
[root@server0 ~]# echo “Hello World” > ~/abc.txt [root@server0 ~]# cat ~/abc.txt Hello World [root@server0 ~]# echo “I am Shubham” >> ~/abc.txt [root@server0 ~]# cat ~/abc.txt Hello World I am Shubham
[root@server0 ~]# cat /root/anaconda-ks.cfg
[root@server0 ~]# cat > /root/Desktop/flower.txt Lotus, rose, tulip, lily. - Press [ctrl+d] to save file [root@server0 ~]# cat /root/Desktop/flower.txt Lotus, rose, tulip, lily.
[root@server0 ~]# cat > /root/Desktop/flower.txt Hello World! [root@server0 ~]# cat /root/Desktop/flower.txt Hello World!
[root@server0 ~]# cat >> /root/Desktop/flower.txt I am Shubham [root@server0 ~]# cat /root/Desktop/flower.txt Hello World! I am Shubham
[root@server0 ~]# cat /etc/redhat-release display OS name and Version [root@server0 ~]# cat /proc/meminfo display ram information [root@server0 ~]# cat /proc/cpuinfo display processor information
[root@server0 ~]# cat /etc/redhat-release > /osname.txt
[root@server0 ~]# cat /proc/meminfo >> /osname.txt
[root@server0 ~]# cat /flower.txt /number.txt /alpha.txt > /newfile.txt
Semicolon (;) – Executes two or more commands in same command line argument. Example,
Pipe (|) – It matches first command output to the second command and execute it. Example,
[root@server0 ~]# touch /abc.txt ; mkdir /mydir ; cp – r /mnt /media
[root@server0 ~]# dmidecode | less [root@server0 ~]# ls / | wc
/sys System information.
/proc Processes information. This directory also stores RAM and CPU related information.
/boot It stores boot loader program and all other boot related files.
/dev /dev directory stores device information and their block files.
A user is a person who utilizes a computer or network service. Linux is said to be secure because one user cannot access files of other user without its permission. There are three types of user,
1. Super user: Super users are those users who has all privileges of Linux system. On all Linux systems, by default there is the user root, also known as the super user. This account is used for managing Linux. Root, for instance, can create other user accounts on the system. For some tasks, root privileges are required. Some examples are installing software, managing users, and creating partitions on disk devices. 2. System user: System accounts are used by the services in Linux system. These accounts or users generally created when services are installed in system. 3. Standard user: local user accounts or standard user accounts are for the people who need to work on a system and who need limited access to the resources on that system. These user accounts typically have a password that is used for authenticating the user to the system.
Adding New User,
Adding new local user means creating user account. User can be added by root user or using root user’s privileges. Whenever new user has been added, some files get affected. These files holds user accounts related information. Also whenever new user is created, by default, its home directory and mail account also has been generated. New users are created using some skeleton files located in /etc/skel directory. These files are hidden and copied into home directory of new user.
/etc/passwd: It store user profile related information,
/etc/shadow: It stores user password policies,
/etc/group: It store group information,
/etc/gshadow: Stores group password and member’s list,
[root@ip- 172 - 31 - 19 - 5 ~]# useradd shubham
[root@ip- 172 - 31 - 19 - 5 ~]# tail - 1 /etc/passwd shubham:x:1002:1002::/home/shubham/:/bin/bash
[root@ip- 172 - 31 - 19 - 5 ~]# tail - 1 /etc/shadow shubham:!!:18206:0:99999:7:::
[root@ip- 172 - 31 - 19 - 5 ~]# tail - 1 /etc/group shubham:x:1002:
[root@ip- 172 - 31 - 19 - 5 ~]# tail - 1 /etc/gshadow shubham:!::