Archive for the ‘ Getting Started ’ Category

Linux Installation Guide

Hardware: redhat.com/HCL (information about redhat supported hardware)

http://www.xfree86.org (to check graphics compatibility e.g. VGA card, monitor)

http://www.redhat.com/support/errata   /bug-fixes

Redhat supported architechre

* RHEL supports the following cpu architechures

.intel’s x86 arch.

. interl’s Itanium ,,

. AMD64

. IBM’s s/390, i-series, p-series & z-series arch.

* RHEL supports SMP (symmentric multi-processors)

– Linux supports upto 32 processors

– but Intel’s arch. limitations uptp 8 processors

www.rhn.com (official supports site for ws,es and as )

Redhat Installation:

.Methods:

1.         CD-ROM based installation

2.         Network-based ,, (FTP,HTTP & NFS)

3.         Kickstart     ,,

Min. H/W requirement

1. Memory – >=128MB (256 mb recommended)

2. Processor – Pentium Class

3. Hard Disk space – depends uptp the no. of packgaes to be installed) (RHEL3-WS)  5 gb for full installation and 3 gb for general installation)

when bootable cd started:

boot:   1.         linux mediacheck

2.         press ENTER for graphical installation (GUI)

3.         linux text – for text based installation (use tab key for cursor               jump, spacebar for selection/deselection

4.         Language selection – default ok

5.         keyboard selection – default ok

6.         mouse selection       – select properly

Disk Partition

Two types of i/o controllers

. IDE and SCSI

1. Primary master (/dev/hda)

2. ,,        ,,   (/dev/hdb)

3. Secondary master (/dev/hdc)

4. ,,        slave  (dev/hdd)

. SCSI Disk

1. first scsi disk (/dev/sda)

2. second scsi disk (/dev/sdb)

Types of partitions:

1. Primary partition   (upto 4 primary partition including extended as one of                                                the primary partition)

2. Logical partition   It resides inside the partition start from 5 and can be                                        extend uptp 65 in IDE and 15 upto in scsi)

Note: use #fdisk -l for list of partition

Types of creating partition

1. auto partition

2. disk-druid

in auto partition

/boot -100mb

swap – 2XRAM

/ – Remaining all free (non formatted or unpartition) space.

Disk Druid

————

min. recommended partition

/boot

/

swap

Full fledged partitioning scheme (for server recommended)

——————————–

/boot -100mb

/home -5000 (depends on  users volume)

/usr  – space depends upon the no. of package tobe installed (for full instalati       on -RHEL3.0-ws>=4100MB

/var – 500mb

/tmp – 200mb

/    – /bin /sbin /dev/ etc/lib 2GB

swap – 2XRAM

Graphical User Interfaces in Linux

GNOME/KDE/X-window system

—————————

– X-window system

. It is the main GUI component of linux.

. It is based on client/server Architechure.

. Applications are called x-clients & display is called x-server.

. x-cleints communicates with x-server using x-protocol.

. x window system was developed by Athena project of MIT; now handled by

xc-consortium.

. It is plateform independent.

. It should not be pluralized.

GNOME (global network object model environment)

. It is default & consistent desktop environment.

. It has been developed using GTK toolkit.

KDE (K Desktop environment)

. It is also consistent desktop environment of Redhat Linux.

. It has been developed using QT-toolkit.

Window Managers

—————–

– Metacity  – GNOME window manager

KWM – KDE

-Display Manager (GUI login screen)

#runlevel

N 5 (current runlevel)

1= single user mode

3- only text-based terminals (f1-f6) are available

5 – both text-based terminals ( f1-f6) & GUI (f7) are available

to switch level

—————-

#init <runlevel> to switch into the specified runlevel

eg. #init 5

To add runlevel at system startup

open

# vi /etc/inittab

change

id:5:initdwefault:

change 5 into 3 or desired

to logout from GUI mode

press ALT+CTRL+<backspace>

GDM= GNOME display manager

XDM= xfree86  ,,       ,,

to change display manager

—————————

#vi /etc/sysconfig/desktop

DESKTOP=”GNOME”

remove above desktop=”gnome” line and add following

DISPLAYMANAGER=”GNOME”

OR

“KDE”

OR

“XDM”

-Desktop switching load

14 June 05 RHCE Preparation Course

GNOME/KDE/X-windows system (Contd..)

GNU Applications

* GUI Terminals

#gnome-terminal – gnome terminal

#konsole – KDE

#xterm – XFree86

* GUI Editors

#gedit – GNOME Editor

#kwrite – KDE

#gvim – GUI version of vi

#xemacs – ,, ,, ,, emacs

* Web Browsers

#mozilla – standard web browser

#konqueror – KDE ,, ,, ,,

#nautilus – Web browser/file manager

* Email Clients

#Mozilla Mail – Standard email client

#kmail – KDE ,, ,, ,,

#evolution – Gnome ,, ,,

* Office Applications

#office.org Office suit

#oowriter – word processing application

#oocalc – Calculator

#ooimpress – Presentation software etc…..

* Some more GNOME applications

#gnumeric – Spread sheet

#mrproject – Project management software

#gnomemeeting – Video conferencing software

Introduction to Shell Scripting

Bash Shell scripting

———————

-What is a shell script?

. Shell script is a normal text file that contains commands to perform some specific tasks.

.Shell scripting is extensively used in system administration to automate routine task like creating backup, scanning disks etc.

.Shell scripts are also used to create simple applications.

Creating a Shell script

————————

before using this , use this command

#echo “Testing shell script”

# (hash is used to give comments in script0

#! (hash and exclamation is called she-bang) is used to specify interpreter’s path

Bash Shell scripting (contd…)

Options

1.         String operator

str1 [option] str2

= True if string is equal to string 2

! true if string1 is not equal to string2

-z Str – true if the string size is equal to zero

-n Str – true if the string size is not equal to zero

2.         Numeric operators

Num1 [option] num2

-eq – true if num1=num2

-ne – true if ,,   not = to

-lt – ,,   ,,  ,,  < ,,

-le – ,,  ,,   ,,  <= ,,

-gt – ,, ,,   ,,   > ,,

-ge – ,,  ..   ,, >= ,,

3. Logical operators

-a logical AND

-o ,,      OR

!  ,,      NOT

4 File operators

-e file – true if tjhe file exists

-f file  – ,,  ,,   ,,  ,, is a normal file

-d file ,,  ,,      if it is a dir

-h file ,,   ,,      ,,,   ,, symbolic link

-r file  ,,   ,,   ,,    ,,, if the file is readable

-w file true writable

-x file ,,         ,,   executable

-O file true if the file is effectivly owened by user owener of the file

-G file true if the file is effectivly owened by group owner of the file

Linux Shell Basics

The bash shell:

Sh:      Bourne shell, developed by Steven Bourne in AT & T lab.

-A traditional unix shell.

Csh: C shell, C programming language was used.Developed by Bill Joy

(many features such as:

-command line complition

-command line editing

-History of command for each user is mantained.

Ksh: Korn shell developed by David Korn at AT & T lab.

Bash shell: The Bourne again shell is the Linux standard command line interpreter.

It was developed by GNU project and has Captured all the good features of ‘sh’ and Korn Shell.

– for more help #man bash

to see the current shell

#echo $SHELL

History for the command for each user.

#history

for history file

# /.bash.history

#!! 9repeats the previous command)

#!n (repeats command which is in line number ‘n’ in history file)

eg.

#!23

#!m (repeats prevous command starting with m)

#!l

#!-N (repeats command executed ‘n’ command back)

eg. #!-23 (repeats command entered 23 command back)

bash use of wild card character:

? Matches a single character

* Matches all characters

[a-z]     Matches in the range a to z

[^a-e]   Doesn’t match in the range a to e

[be]      match in the set b and e

[^be]    doesn’t match in the set n and e

#rm -rf [^a-d]*

bash contined…

#mkdir /var/xyz/test (it could not create test dir if not exist /var/xyz)

#mkdir -p /var/xyz/test (also creates the parent directories)

#mkdir -p /var/hmg/ministry/{home,finance,agr,health,def}/{sec,officer,executives}

#cd ../finance;ls

Command alias

#alias

eg. find /-name grub -and -user root

alis search=’find / -name  grub -and -user root’

Use of quotes:-

‘ Single quote: Treats everything even a special character as ordinary character./

” Double quote: Expands the especial characters.

` Backquote: Command can be executed

Variables

————–

Two types of variables

1.         Local shell bariable: Available to the current shell only

2.         Environment variable: Available to the current shell as well as sub-shlls.

#env – displays env. shell variable only.

@set – displays both local and env. shell variables.

#ps – displays the current running(foreground) process

#/home/.bash_profile- Containms user-specific shell variables

/etc/profile – contains system-wide shell(globally) shell variables.

#export (variable name) – to make the variable env. variable.

eg. export myvar

#set

#env

#echo $myvar

#ps

#bash

#ps

#echo $myvar

Finding Files and Directories

finding files and directories

Find command searches for files and directories as per the defined criteria.

find command also searches inside the sub-dir of specified path.

Syntax:

find [path] <criteria> <action>

path=where to search

Criteria can be:

-name <filename>   [name based search]

-iname <filename> [name based search, but ignorecase]

-perm <perm>                       [permission ,,     ,, ]

-atime -N,+N,N                      [access time ,, ,,]

-mtime -N,+N,N                     [modified  ,,  ,,]

-user <user>             [modified ,,  ,,]

-group <group>                    [group ownership based search]

-size <size>               [size based search eg. 20M,20K or give 20c to treat size as character].

-type                           [type can be f d c b etc]

eg.

#find / -name passwd   (/ is before root) (it searches all the files of passwd inside the /)

#find / -perm 660

#find -mtime 3 (it searches before 3 days file)

Processing the find files:

-exec (doesn’t give interactive message)

-ok       (Interactively)

{}          place holder for found files.

eg.

#find / -name groub.conf -and -user root -ok cp {} /test11 \;   (termination of command)

Slocate/Locate:-

Slocate and locate commands searches for files and directories in the updated database. The files and directories matching the pattern are returned.

-By default system updates the database in every 24 hours (eg. a daily task)

Syntax:

locate/slocate pattern

#slocate httpd.conf (locates httpd.conf from our system)

#slocate hosts.allow

#updatedb (updates the slocate database)

Calculating Default Permissions

Calculating default permission

1. file – Maximum allowed permission at the time of file creation (666)

-umask

Default permission on a file

0022

1st zero is special permission

2nd zero is owner perm.

2. Directory

Max. allowed permission at the time if dir creation (777)

Default permission on a dir.

Questions:

Set the value of umask such that file created after changing umask value have read & write perm. for owner but no permission to group members & others.

Answer:

umask 066

-sets value of umask for the curent session

#umask

#cat>newfile

3rd zero group perm.

Color Codes in Linux

Color codes

———–

White color – Normal text file

Blue                Dir

Green             Executable file (.exe,.com,bat..bash etc)

Cyan              Symbolic link

Yellow                        devie file

Red                 Compressed file or archive file (.gx,.bz2,tar etc)

Magenta                    Picture file (.jpg.bmp.xpm etc)

Location of file

/etc/DIR_COLORS

User Groups and Permissions

– Users

Types: UID

1.         Root user       0

2.         System users            1-499

3.         normal users >500

/etc/passwd – User database

format

Username:x:UID:GID:<comment>:home_dir:shell

X=Encricpted password

(/etc/shadow)

Groups

Types:                        GID

1. Root users group 0

2. System User group          1-499

3. Normal user group          >500

/etc/group database file

Format

Groupname:x.GID:<members_of_the_group>

X=encripted password

(/etc/gshadow)

User Information commands

# whoami (displays login name)

#who

#users

#w

above three commands displays list of currently logged in users

#groups

#id

above two commands displays the list of groups of which the logged in user is

a member

Unit 5 Uses, Groups & Permission (contd…)

* Switching users account

# su – username

eg. # su – sbogati (It asks password for loging user)

* User Categories

Owner -u

Group -g

others-o

all(ugo)-a

Permission types:

Permissions  Symbolic represatation       Numeric value(octual value)

Read                          r                       4

Write                           w                     2

Execute                                 x                      1

No Permission                      –                       0

Permission operators

Options                                  Meaning

——-                           ———

+                                  to add permission

[on existing one]

–                                   to remove pewrmission

(from existing one)

=                                  to absolutly assign permission

(overwriting existing one)

* Effects of permission:

Permission    Effects on a file                    Efects on a dir

1. Read (r)     1. It allows to view the         1. It allows to list the content                                                                         s of a dir

[ls]

2. Write (w)    2. It allows to modify the     2. It allows to create/remove/re                                                                     name files/dirs. inside the

directory

[cat>, mkdir, mv, rm etc.]

3. Execute (x)            3. It allows to execute the file

if it is a program file.         3. It allows to enter into the

dir

[cd]

contents of a file

[vi nano,..]

contents of a file

[cat, vi, less

* Umask

——–

It is a value that determines default permission (ig. permission at the time of

file/dir. creation) on a file or dir.

———-

1. – type

2. d dir

3. l symbolic link

4. b block device file

5. c character device file

Above 9 tpye are called permission string

first 3 are owners permission, sedond 3 are group permission and last 3 are others permissions

Sorting

sorting is the arrangement of data/information in increasing (ascending) or decreasing(descending) pattern.

#sort <options> filename

Options: -r -reverse order

-n -numeric order

-t -as field separator, delimiter

-k position

-u unique sort

#sort /etc/passwd

#sort -r /etc/passwd

#cut -d:-f7 /etc/passwd|sort -u

#sort -t: -K1 /etc/passwd

Uniq: uniq moves the duplication and returns only the unique items.

# cut -d -f7 /etc/passwd|uniq -c (also counts number of counts for the item)

Introduction to string processing

Introduction to string Processing

Head/Tail

Head and tail command are used to view the first and last few lines of a file respectively.

By default these commands generate 10 numbers of lines.

# head /etc/passwd (shows first 10 lines)

# tail /etc/passwd (shows last 10 lines)

One very handful command to monitor log messages

#tail -f /var/log/messages  (this is used to see the online activities)

wc: Word count

This command is used to count number of lines, words or characters in file

Syntax:

wc <option> filename

Options: -l counts number of lines

-w counts number of words

-c counts number of characters

# wc -wlc *

Cut: cut command cut the specified field from the file of known formats or to cut first few characters

#cut <option> <filename>

Options:  d -delimiter or field separator

-f{number} -field number

-c -to cut the characters

#cut -d: -f1 /etc/passwd (shows only the first field of /etc/passwd’s contents

#cut -d: -f1-3 /etc/passwd (shows only first second and third fields of /etc/pas                                    swd contents)

#cut -c1-10 /etc/passwd (shows first 10 characters of file’s line)