Sie sind auf Seite 1von 33

Red Hat Linux

Enterprise 5

Trainer - Mohammed Usman Sharief

Unix - AT & T, Bell


labs
HP Unix - HP
AIX Unix - IBM
Solaris 10 SUN

Free or open source code -LINUX

Flavours of Linux
SuSe

Caldera

Mandrake Fedora
RedHat - most popular

OS
Kernel Core of the operating system
Interacts with hardware
Shell - bash shell ;
command mode user interface
X windows system - GUI

Run levels:
different modes in which the OS can be booted
Init 0 shutdown
Init 1 single user mode
Init 2 multi user
Init 3 multi user with networking
Init 4 un used
Init 5 multi user with networking
and GUI ( X windows system)
Init 6 restart

Understanding devices in Linux


/dev/hda h for ide device
/dev/sda s for sata device
hda
hdb
hdc
hdd

a
-b
-c
-d

for primary master


for primary slave
for secondary mster
for secondary slave

Numbering of the partitions


Primary /dev/hda1
/dev/hda2
/dev/hda3
Extended /dev/hda4
Logical /dev/hda5
/dev/hda6
/dev/hda7
and so on.

Partitions required to install


the RedHat Linux Enterprise 5
/boot 100MB
/ 5GB or greater
/swap 2 times of RAM
/home

/dev/hda1
/dev/hda2
/dev/hda3

home directory for users /dev/hda5

Root refers to
/ slash or root directory that contains the OS
Root also refers to root user (administrator)
$ normal user prompt
# root user prompt

Basic commands
ls

ls-l

cp

date

time

mv

vi filename
useradd

mkdir

rm

touch filename

userdel

more filename

su (for root)
df h

man
rmdir

df -T

cd

ls-l>abc

pwd

rm r

gedit filename

passwd username

less filename

su username
hostname

clear

cat filename

head filename
tail filename

who whoami

fdisk -l ifconfig -a

Working with HDD


1. fdisk for partitioning
fdisk /dev/hda
2. mkfs for formating
creating the file system (ext2 or ext3)
mkfs

/dev/hda5

3. mounting : to make it accessible under the /


mount /dev/hda5
/apps
Any partition or drive that needs to be accessible
Has to be mounted under the / . So create a folder under /
For this partition or drive and mount it under that folder.

/etc directory
contains configuration files

/etc/inittab to change the run levels during boot

/etc/fstab

for mounting partitions during boot

HDD partitions
Fdisk

/dev/hda
Mkfs /dev/hda5

(ext 2)

Mkfs.ext3 /dev/hda5
Mkfs t ext3 /dev/hda5

e2label

/dev/hda5 /data
Mkdir /data
Mount /dev/hda5 /data
Vi /etc/fstab

LABEL=/data
or
/dev/hda5
Blkid
Blkid /dev/hda5

/data
/data

ext3
ext3

defaults
defaults

1 2
1 2

Boot Process
After Power on , POST , CMOS Setup, boot seq HDD,
MBR;GRUB .
/boot contains boot loader, kernel and init
Boot loader GRUB
Kernel and drivers
Process first process is Init
/etc/rc.d/rc.sysinit
/etc/inittab
/etc/rc.d/rc5.d/files
K for kill scripts and s for start scripts
all files are linked to /init.d

Volumes
fdisk l
fdisk /dev/sda
n
st cyl
end cyl: 100MB
t
part no 10
code; 8e
w
reboot

fdisk l

create 11 th partition

fdisk /dev/sda
n
st cyl
end cyl: 100MB
w
reboot

pvcreate /dev/sda11
/dev/sda12
/dev/sda13
pvdisplay
vgcreate pool1 dev/sda11 /dev/sda12 /dev/sda13
vgdisplay
lvcreate pool1
L 150
-n data
lvcreate
pool1
L 150
-n apps
lvdisplay
we need to format, mount and put entry in vi/etc/fstab
df -h

pvcreate /dev/sda6
pvdisplay
vgcreate
vgdisplay

pool1

lvcreate pool1
lvcreate
pool1
lvdisplay
mkfs
mkfs

t ext3
t ext3

/dev/sda7

/dev/sda8

/dev/sda6 /dev/sda7 /dev/sda8


L 152
L 148

-n data
-n apps

/dev/pool1/data
/dev/pool1/apps

mkdir /data
mkdir /apps
Vi /etc/fstab
/dev/pool1/data
/dev/pool1/apps

/data
/apps

ext3
ext3

defaults
defaults

12
12

Create partition
Convert to physical volume
vgextend pool1 /dev/sda15
Lvextend L 1000 /dev/pool1/vol1
Previously vol1 was 600
We have added 400
So to extend we have to giv e total 1000
Then umount
Format and mount again

Swap partition
fdisk l
fdisk /dev/sda
n
Start cyl
End cyl
t
Part no
Code : 82
w
partprobe
or
reboot

mkswap /dev/sda8
swapon /dev/sda8
vi /etc/fstab
/dev/sda8 swap swap Defaults 0 0

swapon s
free

Users and groups


Useradd

userdel

groupadd

groupdel

Usermod -G groupname username


(adding users to the group)
Id username

File permissions : chmod


d
File/dir

rwx
user

rwx
group

rwx
others

r w x
4 2 1
chmod 777 filename ( 7 for user, group, others)
chmod 750 filename (rwx for user, rx for group
and none for others)

permissions
# chown username filename
# chown : groupname filename
# chown username : groupname filename

#chgrp groupname folder

Umask -

0022

First mention umask then create the files.


If Umask is 022

folder perm is 755

if umask is 022
file perm should be 755
since no execute (-111) the perm is 644 for
files

execute for folder means to list (ls)

Create directories, users and groups, give passwords to users


add users to the group
give permission for each folder to each group
deny others access to the folders

mkdir sales
mkdir it
Useradd sales1
useradd it1
Passwd sales1
passwd it1
Groupadd sales
groupadd it
Usermod G sales sales1
Usermod G it it1
Chgrp sales /data/sales
chgrp it /data/it
Chmod 770 /data/sales chmod 770 /data/it
Chmod g+s /data/sales chmod g+s /data/it

rpm ivh package


rpm U package
rpm - F package.
rpm e

(uninstall) (without .rpm)

yum install package (online)


Yum upgrade package
Rpm qa
rpm q samba
From CD to /usr/src/redhat

rpm

# bzip2 filename # gzip filename


# bzip2 d filename #gzip d filename
(-d decompress)
mv a .a
(creating hidden file)
ls all
(listing hidden files also)
ln

(copy and link)

mkdir /data1
mkdir /data2
Cd data1, vi ex
ln ex /data2/ex

Networking
ifconfig a Unix OS
Ipconfig/all
MS Windows
Netconfig Novell netware
Ifconfig
ifconfiig
Ifconfig
service

eth0 up
eth0 10.0.0.10
eth0 down
network
restart

vi /etc/sysconfig/network-scripts/ifcfg-eth0
Change the ip
esc :wq
service network restart

Services
Service
Service
Service
Service

network restart
network stop
network start
iptables status

Service autofs status


/etc/sysconfig/autofs
chkconfig autofs on (will tick the service in the
tool system-config-services)

Nis authentication
novell

(similar to ADS of MS or NDS of

nfs sharing (between unix )


samba (sharing between unix and MS pcs)
apache web server

(similar to IIS of MS)

bind dns named server


dhcp - (automatic configuration of ip, dg, dns)
ftp (file upload and download)
telnet

(remote access)

nfs configuration on the Server


rpm ivh

nfs..rpm

service nfs start


vi /etc/exports
/data 10.0.0.0/255.0.0.0(rw,sync,no_root_squash)
exportfs rv
service portmap restart
service nfs restart
Chkconfig nfs on

Client configuration for nfs


vi /etc/fstab
ipaddress : /data /data
computername : /data /data
0
Example: srv1:/home

nfs defaults 0 0
nfs defaults 0

/home nfs defaults 0 0

Vi /etc/hosts
(if servername is used)
ip computername

Basic commands
TAR
tar cvf test.tar test
tar xvf test.tar
c-create

x extract

Attributes : lsattr

f - file

chattr

chattr +i filename (cannot delete or rename)


i-immutable
ls R (list sub directories and files tree )
rm -r (remove all subdirec and files )
rmdir for empty directories
cat /proc/cpuinfo

Piping - grep
Find Locate
Grep name /etc/passwd
Egrep
ps e | more
Egrep : /etc/passwd |more
ls l | more

Troubleshooting
Mount

o remount,rw

Das könnte Ihnen auch gefallen