You are on page 1of 81

Introduction about Linux

What is Linux ?
A fully-networked 32/64-Bit Unix-like Operating System
Multi-user, Multitasking, Multiprocessor
Has the X Windows GUI
Coexists with other Operating Systems
Runs on multiple platforms
Includes the Source Code
Where did it come from?

 Linux Torvalds created it


with assistance from programmers around the world
first posted on Internet in 1991
 Linux 1.0 in 1994; 2.2 in 1999
 Today used on 7-10 million computers
with 1000’s of programmers working to enhance it
How do you get it?
 Download it from the Internet
 From a “Distribution” (e.g.RedHat)
 Linux kernel
 X Windows system and GUI
 Web, e-mail, FTP servers
 Installation & configuration support
 3rd party apps
 Hardware support
Distribution Concept
Free Distributions
 Redhat
 Fedora and Ubuntu
 Gentoo
 Slackware
 Suse
Red Hat Enterprise Linux [RHEL 6]

 Commercial Distribution
 Enterprise-targeted operating system
 Focused on mature open source technology
 12-18 month release cycle
 Versions available started from 4.1, 5.0 now 6.0
 Support available up to 24 x 7 coverage plans
 Supports many processor architectures
Intel x86-compatible, Intel Itanium 2, AMD64, IBM PowerPC on
eserver iSeries and eServer pSeries and IBM Mainframe on
eServer zSeries and S/390
Conventions for Naming the Disks
and Partitions
 Linux uses a very different naming scheme that provides far more
information than that used by MSDOS or Microsoft Windows
 /dev/xxyN
 The dev refers to the devices directory. The devices directory is where
all information about devices is stored
 The xx refers to the type of hard disk. The xx is replaced by hd for an
Integrated Drive Electronics (IDE) hard disk and by sd for a Small
Computer Systems Interface (SCSI) hard disk

IDE Hard Disk = /dev/hd

SCSI Hard Disk = /dev/sd


/dev/xxyN

Primary Master = /dev/haa


Primary Slave = /dev/hdb
Secondary Master = /dev/hdc
Secondary Slave = /dev/hdd

The y is replaced by a letter representing each disk. For example, a


would be the first disk and b the second
/dev/xxyN

• The N is replaced by a number for each partition on a drive. For


example, 1 would be the first partition and 2 the second

P r im a r y p a r t it io n E x t e n d e d p a r t i t i o n ( /d e v / h d a 2 )

/d e v /h d a 1 /d e v /h d a 5 /d e v/h d a 6

1 s t lo g ic a l p a r t it io n 2 n d lo g i c a l p a r t i t i o n

P r i m a r y m a s t e r I D E h a r d d i s k ( /d e v / h d a )
P r im a r y p a r t it io n E x t e n d e d p a r t i t i o n ( d/ e v / h d a 2 )

/d e v /h d a 1 /d e v /h d a 5 /d e v /h d a 6

1 s t lo g ic a l p a r t it io n 2 n d lo g ic a l p a r t it io n

P r i m a r y m a s t e r I D E h a r d d i s k ( /d e v / h d a )

 Primary partitions are represented by the numbers 1, 2, 3, and 4.


Logical partitions start with 5.
 /dev/hda1 is the device file for the first primary partition on the

first EIDE disk


 /dev/hdb5 is the first logical partition on the second EIDE disk
What is SWAP Partition ?

Swap partitions are used to support virtual memory. In other words,


data is written to a swap partition when there is not enough RAM to
store the data your system is processing.
Size of SWAP ?
 At least 256 MB
 Twice the amount of RAM on your machine
 Swap should equal 2x physical RAM for up to 2 GB of physical
RAM, and then 1x physical RAM for any amount above 2 GB, but
never less than 32 MB.
 SWAP can also used after the installation
 Red Hat Enterprise Linux supports up to 32 swap files
The File System Hierarchy

 In the Linux operating system, every file,


directory, and device is one part of a grand
hierarchy.
 The topmost member of this hierarchy is the root
directory, and it is denoted by the symbol /
The Top Level Directories
Directory Description

/bin Contain programs available to all users


/usr/bin
/sbin Contain programs meant to be used by system administrators
/usr/sbin
/var/log Contain the log files made by various applications. The log files are
invaluable in keeping track of applications’ activities and errors
/home Contains all the personal directories of the users of the system

/boot Contains the files needed by the operating system to load itself into memory

/etc Contains the system configuration files used by various applications

/media Contains the mount points for any removable devices in the system (such as
CD-ROMs, floppy disks, and the usbdisk drives).
/proc Contains the system state information. The information in the files of this
directory is maintained directly by the operating system kernel
Installation of Red Hat Enterprise Linux

Types of Installations
 Fresh Installation ( New )
 Upgradation

Modes of Installations
 GUI Based ( Graphical Installation )
 CLI Based ( Text Based Installation )
Sources of Installation

 CD-ROM
 Hard Disk
 Network

 NFS Server

 FTP Server

 HTTP Server
Steps to install RHEL
 Boot your computer from bootable media
 Start Installation
 Language, Keyboard and mouse selection
 Media selection if applicable
 Disk Partitioning
 Bootloader configuration
 Network and firewall configuration
 Authentication Setup
 Package Selection
 X server configuration
Boot Menu
Type linux ask method when you see the boot
Choose a language and select OK.
Select a keyboard and select OK.
Set up an NFS installation method and select OK.
Configure TCP/IP
Welcome Red Hat Enterprise Linux 6
Choose to customize the configuration
Choose your partition
Select a device
Configure your connection to the network
Set the time zone
Set ROOT Password
Select the Necessary Packages
Installation Start Process
Create user
Login Prompt
Virtual Consoles

 Multiple non-GUI logins are possible through the use of virtual


consoles
 There are by default 6 available virtual consoles
 Available through CTRL+ALT+F[1-6] (here F is for Function
Key)
 If X is running, it is available as CTRL+ALT+F7
SysV Run-levels
 Run-level defines which services to start

◦ service scripts reside in /etc/init.d

◦ Each run-level has a corresponding directory:


 /etc/rcX.d

◦ Symbolic links in the run-level directories call the init.d scripts


with a START or STOP argument
Run-Level continued
 Can also switch to different run levels

◦ On boot

◦ By calling init x (where x= desired run-level)


 Show current and previous run-levels

◦ runlevel
 7 run-levels defined: (0-6)
 /etc/inittab

id : x : initdefault
Run-Levels

 0 - Halt(Do not set initdefault to this)


 1 - Single-user mode (only the root user can be logged on.Used to perform
maintainance)
 2 - Multi-user , without NFS networking
 3 - Full multi-user mode. (Include networking)
 4 - Unused
 5 - X11 (Includes networking)
 6 - Reboot (Do not set initdefault to this)
System Shutdown
 Shutting down the system

◦ shutdown -h now

◦ halt

◦ poweroff

◦ init 0
System Reboot
 Rebooting the system

 shutdown -r

 reboot

 init 6
 Important files covered
 /etc/inittab
 /etc/init.d
 /etc/rc.local
 /etc/rc.sysinit
 Important commands covered
 init
 shutdown
 reboot
 halt
 poweroff
 chkconfig
 ntsysv
Linux Shell Commands
User Administration

Objectives
 Create/modify/delete user accounts
 Create/modify/delete group accounts
 Modifying file ownership and permissions
 Understanding “special” permissions
 Configuring a users shell environment
The User Account Database -
/etc/passwd
 Contains account information used at login and by other programs

 One account per line with seven colon-delimited fields

 Should have permissions rw-r--r—

 bcroft : x : 502 : 504 : Bryan Croft : /home/bcroft : /bin/bash


Adding a New User Account
 Most common method is via:

◦ useradd username
 You can perform the necessary steps manually

◦ edit /etc/passwd and /etc/group

◦ create and populate home directory

◦ change permissions and ownership

◦ set account password


Modifying / Deleting Accounts
 To change fields in a user’s /etc/passwd entry you can:

 Edit the file by hand

 Use usermod [options] username

 To remove a user either:

 Manually remove the user from /etc/passwd, /etc/shadow,


/etc/group

 Use userdel [-r] username


Group Administration
 Entries added to /etc/group

 groupadd groupname

 groupmod -n newname oldname

 groupdel groupname
Switching Accounts
 Syntax

 su [-] [user]

 Allows the user to temporarily become another user


 The “-” option makes the new shell a login shell
File Ownership
 Every file has both user and group “ownership”
 A newly created file will be owned by:
 the user who creates it
-rw-r--r-- 1 joshua joshua 272629 Sep 29 11:20 project
(user) (group)
 the current primary group of that user
 SGID directories may change this behavior
-rw-r--r-- 1 joshua webstaff 272629 Sep 29 11:20 project
SGID Executables
 Normally processes started by a user run under the user and group
security context of that user.
 SGID bits set on an executable file cause it to run under the user
and/or group security context of the file’s owner and/or group.
 Consider the file /etc/shadow that stores user’s encrypted
passwords:
-rw------- 1 root root 805 Sep 29 11:29 /etc/shadow
The file is owner by root, who has exclusive read and write access.
Users may still change their passwords with the passwd command,
because the passwd command has its SUID bit set, and is owned by
root:

-r-s--x--x 1 root root 13536 Jul 12 05:56 /usr/bin/passwd

 SUID and SGID bits are set using the chmod command:
 chmod u+s <filename> (SUID)
 chmod g+s <filename> (SGID)
The Sticky Bit
 Normally if a user has write permissions to a directory, they can delete
any file in that directory regardless of the file’s permissions or
ownership
 With sticky bit set on a directory, only the owner of the file can delete
the file

Note that the sticky bit on /tmp is set by default, as can


be seen a “t” in the file permissions:
drwxrwxrwt 13 root root 4096 Sep 29 12:42 /tmp

 To set sticky bit on a directory, use the chmod command:


# chmod o + t /home/share
User Environment
 /etc/skel : This directory is the default template for user’s home
directory. If you would like to customize your user’s environment you
can modify this directory.
 /etc/profile : executed every time a user logs into the system. It will
set environment variables for the user. This is the first script executed
at login.
 /etc/profile.d : Contains initialization scripts specific to software
packages installed by RPM. These scripts are called by /etc/profile.
 The /etc/bashrc script is used system-wide functions and aliases. It
allows system administrator to set aliases for every user, such as c for
clear or h for history.
 Important files covered :
 /etc/passwd
 /etc/group
 /etc/skel
 /etc/profile
 /etc/bashrc
 Important commands covered:
 useradd, usermod, userdel
 groupadd, groupmod, groupdel
 chage
 chown, chgrp, chmod
 umask
 su
RPM Package Manager
 RPM enables software packages to be installed, updated, removed,
queried, built and validated
 RPM checks for required disk space and dependencies when
installing a package
 RPM package file names are of the format
package-version-build.architecture.rpm
( xfm-1.3.2-13.i386.rpm )
 RPM Package Installation
rpm -ivh xfm-1.3.2-13.i386.rpm
 RPM Package Upgrade
rpm -Uvh xfm-1.3.2-16.i386.rpm
This will uninstall any older version of the xfm package and install
the newer package file whose name is given on the command line.
 RPM Package Removal
rpm -e xfm
An installed package can be removed from the system with the -e
switch to rpm. The package name , not a package file name, is
passed as an argument.
RPM Options
 -V : Verify package integrity
 --force : Force package installation
Can be used to install a package even if it (or newer version) is
already installed.
 --nodeps: Ignore dependencies
Can be used to skip the checking of dependencies when installing or
removing a package.
 When doing RPM package installs, updates, and removals from the
command line, it is useful to use the -v and -h options together. This
provides you with a progress report as the operation is carried out
Removing Packages with RPM

 Use -e (or --erase) parameter to remove an installed


package
rpm -e somepkg
 Note: Version number not necessary
Network Configuration

Address Resolution Protocol


 ARP

 Maps ethernet MAC addresses to IP addresses

 The ARP process normally works without user intervention

 arp -a
Interface Configuration Files
 ifcfg-xxx

 Located in:

 /etc/sysconfig/network-scripts/

 Configuration method

 static

 dhcp

 bootp
Static IP address configuration
Device=eth0

IPADDR=xxx.xxx.xxx.xxx

NETMASK=xxx.xxx.xxx.xxx

BOOTPROTO=static

ONBOOT=yes
DHCP Configuration file
Device=eth0

BOOTPROTO=dhcp

ONBOOT=yes
The BIND DNS Server
Installation and configuration of
Domain Name System (DNS)
Configuration Files:

/var/named/chroot/etc/named.conf

/var/named/chroot/var/named/f.zone

/var/named/chroot/var/named/r.zone

Type: System V-managed

Daemon: /usr/sbin/named

Ports: 53(named) 953(rndc)


Installation
  bind* in the DNS
You may install caching* and
server as shown below
Configuration
 After installation of bind* Caching* on the DNS server.
 Go to the configuration file and follow the steps shown below:
Open named.rfc1912.zones file.
Copy content line no.21 to 31 of named.rfc1912.zones to named.conf
This is how f.zone and r.zone would look like after modifications.Here
we have set “example.com” as the domain name.
This is how r.zone and f.zone would look like after modifications.
Here we have set “example.com” as the domain name.
Start services permanently
Now you may try ping all hosts.
Postfix (Mail Server)
Objectives:-
 you should be able to:
Understand electronic mail operation
Use the alternatives system to select a mail server
Perform basic configuration of a mail server
Configure Procmail
Configure Dovecot for encrypted and unencrypted
protocols
Debug email services
 
Service Profile: Postfix
 
Type: System V-managed service
Package: postfix
Daemons: /usr/libexec/postfix/master and others
Script: /etc/init.d/postfix
Port: 25 (smtp)
Configuration: /etc/postfix/main.cf and others
Related: procmail
Send Mail Locally And Globally
example.com

DNS
ISP
POP or IMAP

Gmail
MX Record server
MDA MDA

Gmail client
Sourabh

Happy Souarbh
Configure Mail Server

Firstly install package

Yum install Postfix* -y

Open the configuration file

Vim /etc/postfix/main.cf
Change the line No. 76
My host name = desktop12.example.com
Change the line No. 83
Host name = example.com
Change the line No. 99
My origin = example.com
Change the line No. 113
Remove comment
Send mail to globally
Change the line No. 264
Remove the comment from the line and enter your
network address.
192.168.0.0/24, 127.0.0.0/8
After all these entry save and exit from the file and
restart the deamon of the mail server (postfix)
Service postfix restart
Chkconfig postfix on
Send Mail To Existing User
Mail -v sourabh@desktop12.example.com
Subject:- mail
How are you
. (.is use to send the mail)

To check mail


Vim /var/spool/mail/sourabh
Subject:- mail
How are you
Mail aliases
Open the configuration file
Vim /etc/aliases
Go to the end of the line
Hr: sourabh, happy
Wq!
New aliases ( to save the aliases entry)
Restart the services permanently
Service postfix restart chkconfig postfix on
Send mail
Mail –v hr@desktop12.example.com
Subject:- important mail
Today meeting at 11:00 Am at conference hall
.
To check mail
Vim /var/spool/mail/happy
Subject:- important mail
Today meeting at 11:00 Am at conference hall
To check mail
Vim /var/spool/mail/sourabh
Subject:- important mail
Today meeting at 11:00 Am at conference hall
Thank you

You might also like