0% found this document useful (0 votes)
110 views35 pages

Introduction To Linux: Hinditron Infosystems Pvt. LTD

Linux is an open-source operating system based on the Unix kernel. It has a kernel called Linux which provides services like process control and memory management. The shell is the interface between the user and kernel which interprets commands. Linux distributions bundle the Linux kernel with software from various vendors to create complete operating systems. The document provides an overview of Linux including its history and development, basic commands, file system hierarchy, and user and process administration.

Uploaded by

Pradeep Salve
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views35 pages

Introduction To Linux: Hinditron Infosystems Pvt. LTD

Linux is an open-source operating system based on the Unix kernel. It has a kernel called Linux which provides services like process control and memory management. The shell is the interface between the user and kernel which interprets commands. Linux distributions bundle the Linux kernel with software from various vendors to create complete operating systems. The document provides an overview of Linux including its history and development, basic commands, file system hierarchy, and user and process administration.

Uploaded by

Pradeep Salve
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 35

INTRODUCTION TO LINUX

HINDITRON INFOSYSTEMS PVT. LTD.


DEFINITION
 Operating System is a collection of programs that
coordinates the operation of computer hardware
& software.
What is Kernel ?
 A set of functions that make up the heart of an OS
 It is used to provide an application interface
between programs and physical devices.
 Services provided by the kernel
– Controls execution of processes.
– Scheduling processes fairly for
execution on the CPU.
– Allocating memory for an executing
process.
What is Shell ?
 Shell is the interface between the user and the
kernel.
 Services provided by the shell
– It interprets all the commands to the kernel
– The kernel after processing the commands
gives back to the shell.
History of Unix
MULTICS PROJECT
 It was started in 1965 on Main frame GE 645 by
the joint effort of
– AT & T Bell Labs
– General Electricals
– Massachusetts Institute of Technology (MIT)
 Multics was written in Assembly Language
 In 1969 Multics project was dropped.
 In 1969, Ken Thompson & Dennis Ritchie at Bell
Labs - AT&T redesigned the Multics and introduced
New OS – UNICS (Uniplexed Information &
computing system)
 It is written in 80 percent of C language and 20
percent assembly language.
 Later on totally rewritten in C language and named
as UNIX (1973 ).
 In 1988, AT&T shocked the UNIX
community by purchasing a percentage of
Sun Microsystems which became a threat
for other vendors.
 So, other vendors quickly formed a
consortium group called OSF and former
formed their group named UI.
History of Linux
 In 1990’s, Linus Torvalds ,a graduate student
form University of Helsinky designed a UNIX like
kernel on 386 Intel machine and gave this to OSF.

 Linux Kernel was bundled with many software's


from various distributors and it gave rise to many
flavors of LINUX.
FILE SYSTEM HIERARCHY
/
• This Directory is called as ‘root’ Directory.
• It is the top of the file system structure.
• All other Directories are mounted under it.
/root
• This is the default home directory of administrator
(i.e., root).
/home
• It contains all users home directories.
/boot
• This Directory contains the Kernel, the core of the
operating system.
• This also contains the files related to booting the
system such as the boot loader and the initial
ramdisk.
/sbin
• It contains administrative commands used by
superuser.
/bin
• This Directory contains command used by the
superuser and the normal users.
/usr
• It contains the programs and applications which are
available for users (similar to program files on
windows)
/var
• It contains variable information , such as logs and
print queues.
/dev
• This Directory contains devices nodes through
which the operating system can access hardware
and software devices on the system.
/etc
• It contains all configuration files.
/proc
• This Directory is a mount point for virtual
information about currently running system
processes.
• This Directory is empty until the proc file system is
mounted.
/tmp
• This Directory contains temporary files used by the
system
/opt
• It contains the third party applications
ex:- Corel Word Perfect, Sun Star Office.
/media
• It contains default mount points of removable
media such as cdrom, floppy disk, pendrive.
/lib
• It contains libraries need by no. of different
applications as well as linux kernel.
BASIC COMMANDS
Print Working Directory
[root@comp1 ~]# pwd

Shows list of files & directories


[root@comp1 ~]# ls <options> <arguments>

Listing of files and directories along with the attributes


[root@comp1 ~]# ls –l or
[root@comp1 ~]# ll

Listing of all files and directories including the hidden


root@comp1 ~]# ls –a

Listing of all files and directories in reverse order


[root@comp1 ~]# ls -r
Listing of files and directories along with the ‘inode’ numbers
[root@comp1 ~]# ls –il

Listing of the attributes of a particular file or directory


[root@comp1 ~]# ls -ld <directory>

Shows the list of files in Tree structure


[root@comp1 ~]# ls -R <directory>
Creation of Files
By using three methods we can create files
• cat command
• touch command
• vi editor

Displaying & Creating Text Files


[root@comp1 ~]# cat <options> <arguments>

To create a file
[root@comp1 ~]# cat > <filename>

To view the content of a file


[root@comp1 ~]# cat <filename>

To append a file
[root@comp1 ~]# cat >> <filename>

To transfer the contents of file1 & file2 to file3


[root@comp1 ~]# cat <file1> <file2> >> <file3>
To create a file with zero bytes as well as to change the time
stamp of file or directory.
[root@comp1 ~]# touch <filename>

To create multiple files


[root@comp1 ~]# touch <file1> <file2> <file3>

To create a directory
[root@comp1 ~]# mkdir <directory name>

To create multiple directories


[root@comp1 ~]# mkdir <dir1> <dir2> <dir3>

To create nested directories


[root@comp1 ~]# mkdir -p <dir1>/<dir2>/<dir3>
To change the directory
[root@comp1 ~]# cd <path of the directory>

To change directory one level back


[root@comp1 ~]# cd ..

To change directory two levels back


[root@comp1 ~]# cd ../..

To change directory to last working directory


[root@comp1 ~]# cd –

To change directory to home directory


[root@comp1 ~]# cd or
[root@comp1 ~]# cd ~
To remove a file
[root@comp1 ~]# rm <filename>
To remove empty directory
[root@comp1 ~]# rmdir <directory name>
To remove directory recursively and forcefully
[root@comp1 ~]# rm –rf <directory name>
To copy a file
[root@comp1 ~]# cp <source file path> <destination file path>
To copy a directory
[root@comp1 ~]# cp –r <source dir path> <destination dir path>
To move a file/dir to a different location
[root@comp1 ~]# mv <source path> <destination path>
To rename file/dir move at same location
[root@comp1 ~]# mv <old name> <new name>
VI Editor
Editors are used for inserting or deleting text.
• Windows : Notepad
• DOS : Edit
• Linux/Unix
– CLI based : EX , ED , VI
– GUI based : Emacs, Gedit, nedit, nano, pico

There are three modes of operations in VI Editor :


• Insert Mode
• Command Mode
• Execute Mode
How to get into Insert Mode

i - inserts the text at current cursor position


I - inserts the text at beginning of line
a - appends the text after current cursor position
A - appends the text at end of line
o - inserts a line below current cursor position
O - inserts a line above current cursor position
r - replace a single char at current cursor position
At Execute Mode
:q - quit without saving
:q! - quit forcefully without saving
:w - save
:wq - save & quit
:wq! - save & quit forcefully
:x - save & quit
Shift+ZZ - save & quit
:sh - Provides temporary shell
:set number - Setting line numbers
:se nu - Setting line numbers
:set nonumber - Removing line numbers
:se nonu - Removing line numbers
:84 - Press enter goes to line 84
Delete/Copy/Paste/Undo in command mode

dd - Deletes a line
2dd - Deletes 2 lines
yy - Copy a line
2yy - Copies 2 lines
p - After deleting or copying, by pressing ‘p’ the deleted or copied
contents will be pasted below the position of cursor.
u - Undo (can undo 1000 times)
Ctrl+r - Redo
G - Moves cursor to last line of file
5G - Moves cursor to 5th line of file
User & Group Administration
• Unix/Linux is multi user and multi tasking OS
• Redhat Linux uses User Private Group (UPG) Scheme :-
– User always get created with primary group
– One Primary Group per User
• When a user is created in Linux :--
– home directory ( /home/username)
– mail account (/var/spool/mail/username)
– unique UID & GID

Type of Users

- System Users 0 — 499


- Normal Users 500 — 60,000

User and Group AdministrationDatabase Files


• /etc/passwd
• /etc/shadow
• /etc/group
Creating a User
[root@comp1 ~]#useradd <options> <username>
Options :
-u - UID
-g - Primary group name/ GID
-o - Override
-G - Secondary group
-c - Comment
-d - Home directory
-s – Shell

Modifying a User
[root@comp1 ~]#usermod <options> <username>
Options :
-l - Change login name
-L - Lock the account
-U - Unlock the account
Deleting a User
[root@comp1 ~]#userdel <options> <username>
Options :
-r – recursively

Creating a Group
[root@comp1 ~]#groupadd <options> <groupname>
Options :
-g - GID
-o – override

Modifying a Group
[root@comp1 ~]#groupmod <options> <groupname>
Options :
-g - GID
-o - Override
-n - To change the group name
Deleting a Group
[root@comp1 ~]#groupdel <groupname>

Changing User setting


[root@comp1 ~]#chage <username>

Group setting
[root@comp1 ~]#gpasswd <options> <groupname>
Options :
-a - add a user
-d - Delete a user from group
-M - Creating multiple members
Boot Process
Hardware Boot
• BIOS Initialization
• Performs first POST
• If all H/W connectivity is correct gives a healthy beep.
• Boot Strap Find’s the device from where to boot :-
- Floppy
- CDrom
- Harddisk
Boot Loader
• Boot Loader Initialization – Grub
Kernel
• Kernel initializes the devices
• It mounts the root file system (/)
• It start first process ‘init’ process (/sbin/init)
Init

• Init reads /etc/inittab


• This file contains what programs or services should
be run at different run levels :
init 0 shutdown
init 1 single user mode
init 2 multiuser mode + only text + No support for NFS
init 3 multiuser mode + only text + Full Support for all services
init 4 (unused)
init 5 multiuser mode + text mode+ GUI + Fullsupport for all services
init 6 restart or reboot

Login Screen
To display status of all services
[root@comp1 ~]#chkconfig –list

To display status of particular service


[root@comp1 ~]#chkconfig --list network

To change services at certain Runlevel


[root@comp1 ~]#chkconfig --level 2345 <service> <on/off>

To start / stop any service temporarily


[root@comp1 ~]#service <service name> <start/stop/restart>
Troubleshooting
Recovering Root Password
• Root Password can be recovered in a
specialized troubleshooting mode (i.e. init 1)
• init 1 level provides a shell (i.e. sh) without logging in.

Procedure
• Restart the system
• In the splash screen Select “RedHat Enterprise Linux”
• Press ‘e’
• Select Kernel /vmlinuz-2.6.9-5.EL ro root=LABEL=/rhgb quiet
• Press ‘e’ to edit
• Edit Kernel /vmlinuz-2.6.9-5.EL ro root=LABEL=/rhgb quiet 1
• Press ‘Enter’
• Press ‘b’ to boot with the selected run level
• directly you will get shell prompt to assign the root password
• sh-3.00#passwd root
Assigning Grub Password
[root@comp1~]# grub-md5-crypt >> /boot/grub/grub.conf
[root@comp1~]# vi /boot/grub/grub.conf
Add line in /boot/grub/grub.conf
hidden menu
password --md5 <password>
title Red Hat ------
Recovering Grub Password
• Boot the System in Rescue Mode
# chroot /mnt/sysimage
# vi /boot/grub/grub.conf
Remove line from /boot/grub/grub.conf
hidden menu
password -- md5 <password>
title Red Hat -----
To configure printer
[root@comp1~]# system-config-printer

To configure modem
[root@comp1~]# system-config-network

To view the process


[root@comp1~]# ps –aux

To kill a specific process


[root@comp1~]# kill -9 <process id>

To view CPU usage by all process


[root@comp1~]# top
Networking
What is FQDN ?
• Identifies a host’s name within the DNS namespace hierarchy
• Host name + DNS domain name = FQDN
e.g. mail.hinditron.com

Assigning Hostname - Temporary


[root@comp1 ~]# hostname <system name>

Assigning Hostname - Permanent


[root@comp1 ~]# vi /etc/sysconfig/network

Modify below setting in /etc/sysconfig/network


NETWORKING=yes
HOSTNAME= <system name>
Assigning IP address - Temporary
[root@comp1 ~]# ifconfig eth0 <ipaddr> netmask <netmask>

Assigning IP address - Permanent


[root@comp1 ~]# netconfig
[root@comp1 ~]# service network restart

Assigning Virtual IP address


[root@comp1 ~]# netconfig --device <interface>:<n>
[root@comp1 ~]# service network restart

Graphical tool for assigning IP address


[root@comp1 ~]# neat
OR
[root@comp1 ~]# system-config-network
[root@comp1~]# ethtool
To check whether NIC is detected
[root@comp1 ~]# ethtool <interface>

Enabling Network Interface


[root@comp1 ~]# ifup <interface>

Disabling Network Interface


[root@comp1 ~]# ifdown <interface>

For IP address
[root@comp1 ~]# cd /etc/sysconfig/network-scripts
[root@comp1 ~]# vi ifcfg-eth0

For virtual IP address


[root@comp1 ~]# vi ifcfg-eth0:1
For DNS
[root@comp1 ~]# vi /etc/resolv.conf

You might also like