Sunteți pe pagina 1din 220

RHCE

RHCE ~

Red Hat Certified Engineer

Administration I - Essential Book


Author :
Momen Hany

Copyright March 2012 ,


2012 Engineer Momen Hany Mohamed
RHCE

F
N P
L

Welcome in

RH033 - Red Hat Linux Essentials

Copyright March 2012 ,


Engineer Momen Hany Mohamed
RHCE

F
Contents N P
L
Copyright
Unit1:History For UNIX & LINUX
Unit2:Linux Environment
Unit3:Using The System
Unit4:Working with Files and Directories
Unit5:File and Directory Permissions
Unit6:Linux Documentation & Help RH033 - Red Hat Linux Essentials
Unit7:Tour Through Linux
Unit8:Editing Files
Unit9:Shell Basics
Unit10:Working with Processes
Unit11:Linux Utilities
Unit12:Shell Scripting
Unit13:Linux GUI
Unit14:Basic System Configuration Tool
Certification Information

By Eng Momen Hany Copyright March 2012 ,


Engineer Momen Hany Mohamed
Copyright
F
The contents of this book are copyright March 2012 , N P
Engineer Momen Hany Mohamed. L
Does not allow the amendment in this book , A free copy
of any one.
The Instructors also have the right to be assisted
in this book in their own explanations and labs.
Been used to create this book with Eng.M-Hany
Experience , IBM, red hat and general books.

Contact book owner : -


Mobil: (Egypt) +2 011 437 395 45
Email: IT.momenhany@hotmail.com
http://www.facebook.com/MomenHanyFP

By Eng Momen Hany Copyright March 2012 ,


Engineer Momen Hany Mohamed
RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit1:
History For UNIX & LINUX

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o What is O.S ?

o What is Kernel ?

o UNIX History ?

o LINUX History ?

o What about Red Hat ?

o Linux Distributions .

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Operation System N P
L

An operating system is a program designed to run other


programs on a computer. A computers operating system is its
most important program. It is considered the backbone of a
computer, managing both software and hardware resources.

Hardwar O.S

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Kernel N P
L

kernel is the central core of operating system.


it does not interact with user , rather it interact with shell as well as with
hardware devices.

http://www.kernel.org/

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
UNIX History N P
L
Year Event
1957 Bell Labs found they needed an operating system for their computer center
that at the time was running various batch jobs. The BESYS operating
system was created at Bell Labs to deal with these needs.
1965 Bell Labs was adopting third generation computer equipment and decided
to join forces with General Electric and MIT to create Multics (Multiplexed
Information and Computing Service).
1969 Withdrawn Ken Thompson and Dennis Ritchie needed to rewrite an
operating system in order to play space travel on another smaller machine,
The result was a system that a punning colleague called UNICS (UNiplexed
Information and Computing Service)
1969 Summer 1969 Unix was developed.
1969 Linus Torvalds is born.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
UNIX History N P
L
Year Event
1971 First edition of Unix released 11/03/1971. The first edition of the "Unix
PROGRAMMER'S MANUAL [by] K. Thompson [and] D. M. Richard Stallman.
It includes over 60 commands like: b (compile B program); boot (reboot
system); cat (concatenate files); chdir (change working directory); chmod
(change access mode); chown (change owner); cp (copy file); ls (list
directory contents); mv (move or rename file); roff (run off text); wc (get
word count); who(who is one the system). The main thing missing was
pipes. (GNU Project)
1972-1975 Second to Sixth edition of Unix released.
1977 1BSD released late 1977.
1978 -1980 2-4BSD released mid.
1985 Eighth edition of Unix released February 1985.
---- More SGI-Ultrix-HP-UX-Ninth-Sun-IBM For IAX-NetBSD -..

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
LINUX History N P
L
Year Event
1991 Linux is introduced by Linus Torvalds, a student in Finland.
That was Developed Linus to Support (Multi Tasking ) woooooo.
-- It was licensed under GNU General Public License(GPL), thus ensuring
that the source codes will be free for all to copy, study and to change.
Students and computer programmers grabbed it.
1994 Red Hat Linux is introduced.
----- Red Hat , Caldera, and some other companies gained substantial amount of
response from the users worldwide. While these were commercial ventures,
dedicated computer programmers created their very own volunteer-based
distribution, the famed Debian. With the new Graphical User
Interfaces (like X-window System, KDE, GNOME)the Linux
distributions became very popular.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Red Hat N P
L

Best Company in the world introduced Linux Red Hat and Fedora O.S Dist.

That has Support and Training for Red hat products .

http://www.redhat.com/about/company/history.html

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Famous Dist.
Linux Distributions N
F
P
L

http://distrowatch.com/

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit2:
Linux Enveronment

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L
o Linux 4 User & Linux 4 Servers .

o File Structure .

o Shell Prompt .

o Disk & Partitioning .

o Install Red Hat Enterprise 6 .


*Master Boot Record (MBR)+Dual Boot.
o Window System Desktop .

o Virtual Consoles and Graphic Console .

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Client & Server Environments N
F
P
L
Linux
Distributions
are OSs based on the Linux kernel.

Red Hat Enterprise Linux

Stable, thoroughly tested software.


Professional support services.
Centralized management tools for large networks.
The Fedora Project

More, newer applications.


Community supported (no official Red Hat support).
For personal systems.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


File Structure N
F
P
/ L

root home usr dev mnt etc var boot bin sbin opt
Admin System Other Variable User Third
Home Executable Mount Files Executable Party App
Directory Files Devices Files

Special Service Boot Files Admin


User
Files For Config MBR only
Home
Directory Devices Files Executable
Files

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Shell N
F
P
Shell Name Ash Bourne Bash (Bourne Korn C-shell T-shell Zsh L
Again)

Author Kenneth Brian Eric Gisin William Joy Paul Falstad


Almquist Fox/Chet
Ramey

Binary ash sh Bash ksh csh tcsh zsh


Default
$ $ $ % %
Prompt

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Disk & Partitioning N
F
P
L

Primary v.s Extended

Linux File System

Partition Leased

SWAP Partition

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Installation N
F
P
L
Install Linux O.S Red Hat & Fedora :-

Go To Lab

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Window System N
F
P
L

Two desktop environments provided by Red Hat:

GNOME: the default desktop environment.


KDE: an alternate desktop environment.

Note:-
A typical Linux system will run six virtual
consoles and one graphical console

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Virtual Consoles and Graphic N
F
P
Console L

Switch among virtual consoles by typing: Ctrl-Alt-F[1-6]


Access the graphical console by typing: Ctrl-Alt-F7

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit3:
Using The System

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L
o Log in and out of the system.

o State the structure of Linux commands.

o Execute basic Linux commands.

o Change your password.

o Use the command history.

o Use the keyboard and mouse effectively.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Log in and out of the system N
F
P
L

Linux is Multi-user and Multitasking

Linux is a multi-user, multitasking operating system


Multiple users can run multiple tasks simultaneously, independent
of each other.

Always need to "log in" before using the system


Identify yourself with username, password

Multiple ways to log in to the system


Console: Directly attached keyboard, mouse, monitor
Serial terminal
Network connection

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Log in and out of the system N
F
P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Log in and out of the system N
F
P
L

Switching between virtual consoles and the graphical


environment
A typical Linux system will run six virtual
consoles and one graphical console
Server systems often have only virtual consoles
Desktops and workstations typically have both
Switch among virtual consoles by typing:
Ctrl-Alt-F[1-6]
Access the graphical console by typing Ctrl-
Alt-F7

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


State the structure of Linux commands N
F
P
L

Command Prompt

Examples:
[user@host ~]$
[root@host ~]#

$
#
The dollar ($) usually means: "logged in as regular user"
The hash (#) usually means: "logged in as root"

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


State the structure of Linux commands N
F
P
L

Linux Command Syntax

$ command option(s) argument(s)

$ ls just command
$ ls -l command and option
$ ls /dev command and argument
$ ls -l /dev command, option and argument
$ ls I I node , index number of file

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


State the structure of Linux commands N
F
P
L
Command Format Examples

RIGHT WRONG
1. Separation 1. Separation
$ mail -f personal $ mail - f personal
$ who -u $ who-u
2. Order 2. Order
$ mail -s test root $ mail test root -s
$ who -u $ -u who
3. Multiple options 3. Multiple options
$ who -m -u $ who -m-u
$ who mu $ who -m u

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L
passwd: Change your password
mkpasswd: Generate a random password
date, cal: Find out today's date and displays a calendar
who, finger: Find out who else is active on the system
clear: Clear the screen
echo: Write a message to your own screen
write: Write a message to other screens
wall: Write a message to all screens
talk: Talk to other users on the system
mesg: Switch on/off reception of write, wall and talk messages

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L

The date Command


__________________
date shows the current date and time

$ date
Fri Jun 6 11:15:10 CET 2003

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L

The cal Command


________________
cal shows a calendar
Synopsis: cal [Month] [Year]
$ cal 6 2003

June 2003
Su Mo Tu We Th Fr Sa
1234567
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
$

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L

Who Is on the System


_____________________
who shows who is logged onto the system
$ who
root tty1 Mar 5 11:10
User1 tty2 Mar 5 11:04
$ who am i
host!User1 tty2 Mar 5 11:04
But:
$ whoami
user1

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L
Finding Information about Users
_____________________________
The finger command shows info about other users
Synopsis: finger [user][@host]
$ finger
Login Name Tty Idle Login Time
User1 Tux (1) 2 Mar 5 11:04
root root *1 7 Mar 5 11:10
$ finger User1
Login: User1 Name: Tux (1)
Directory: /home/User1 Shell: /bin/bash
On since Fri Mar 5 11:04 (CET) on tty2
No mail.
No plan.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L
The clear, echo, write, and wall Commands
_______________________________________
The clear command clears your screen
$ clear
The echo command writes messages to your own screen
$ echo Who wants to go to lunch?
Who wants to go to lunch?
Use write to display a text message on a user's terminal
$ write user2
Message
<ctrl-d>
Use wall to place a message on all logged in user's displays
$ wall
I'm back
<ctrl-d>

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L

Talk with Another User


_____________________
If Ahmed wants to talk with Momen, Ahmed enters:
$ talk Momen
If Momen also wants to talk with Ahmed, Momen enters:
$ talk Ahmed

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L
The mesg Command
The mesg command controls whether other users can send
messages to you with the write, wall or talk command or through
output redirection.
User User1 at user1:
$ mesg n
User User1 at User2:
$ write User1
User1 write: User1 has disabled messages on User1

$ mesg y

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L

<backspace>, <ctrl-h> Corrects mistakes


<ctrl-c> Terminates the current
command and returns to the shell

<ctrl-d> End of transmission


<ctrl-s> Temporarily stops output to the
screen
<ctrl-q> Resumes output
Erase last word
<ctrl-w> Erase the entire line
<ctrl-u> Command or filename
<tab> completion

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Execute basic Linux commands N
F
P
L

<arrow up> Previous command


<arrow down> Next command
<arrow left> One character to the left
One character to the right
<arrow right>
Look at the output of previous
<shift page-up> commands

<shift page-down> Look at the output of later


commands; eventually gets youback
to the command prompt
<Ctrl-R>
Search for a command in
thecommand history

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Change your password N
F
P
L

To change your password using GNOME,


navigate to System->Preferences->About Me
and then click Password.
To change your password from a terminal:passwd

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use the command history N
F
P
L

Command History
_______________
Command history also can be viewed with history command
$ history 5

99 clear
999 wc .bash_profile
1000 wc .bash_profile
1001 wc .bash_profile
1000 history

$ !! Run last command


$ !-3 Run last 3 command

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use the keyboard and mouse effectively N
F
P
L

Go To Lab

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit4:
Working with Files and Directories

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Describe the different file types

o Describe file and pathnames

o Create, delete, copy, move and list directories

o Create, delete, copy and move files

o View the content of both text and binary files

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the different file types N
F
P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the different file types N
F
P
L

Linux Filenames
_______________
Should be descriptive of the content
Should use only alphanumeric characters:UPPERCASE, lowercase,
number, @, _
Should not include embedded blanks
Should not contain shell metacharacters:* ? > < / ; & ! [ ] | \ ' " ( ){}
Should not begin with + or - sign
Are case-sensitive
Filenames starting with a . are hidden
The maximum number of characters for a filename is 255

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe file and pathnames N
F
P
L
Absolute and Relative Pathnames
______________________________
Absolute pathnames
Begin with a forward slash /
Complete "road map" to file location
Can be used anytime you wish to specify a file name
Relative pathnames
Do not begin with a slash
Specify location relative to your current working directory
Can be used as a shorter way to specify a file name

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe file and pathnames N
F
P
L

Current Working Directory


_______________________
Each shell and system process has a
current
working
directory (cwd)
pwd
Displays the absolute path to the shell's cwd

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy, move and list F
N P
directories L

Change Current Directory


_________________________
With the cd (change directory) command:
$ cd dir_name
$ cd doc (relative)
$ cd /home/user1/doc (full& absolute)
$ cd ~user1/doc (home)
$ cd (Go to your home directory)
$ cd .. (Go one directory up)
$ cd - (Go to previous directory)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy, move and list F
N P
directories L

Listing Directory Contents


Lists the contents of the current directory or a specified
directory
Usage:
ls [options] [files_or_dirs]
Example:
ls -a (include hidden files)
ls -l (display extra information)
ls -R (recurse through directories)
ls -ld (directory and symlink information)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy, move and list F
N P
directories L

Working with Multiple Directories


_____________________________
Create and remove multiple directories simultaneously with the p flag

$ mkdir -p dir1/dir2/dir3
$ rmdir -p dir1/dir2/dir3

$ rmdir doc test


rmdir: doc: Directory not
$
directory must be empty!

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy and move N
F
P
files L

The touch Command


__________________
The touch command creates an empty file, or updates the
modification time of an existing file.
$ ls -l
-rw-rw-r-- 1 tux1 penguins 512 Feb 24 11:10 docs
$ touch docs
$ ls -l
-rw-rw-r-- 1 tux1 penguins 512 Mar 5 15:37 docs
$ touch new
$ ls -l
-rw-rw-r-- 1 tux1 penguins 512 Mar 5 15:37 docs
-rw-rw-r-- 1 tux1 penguins 0 Mar 5 15:37 new

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy and move N
F
P
files L

Remove File or Directory


__________________
$ rm dir
$ rm p /dir1/dir2/dir3 Remove more Director's
$ rm p dir1/dir2/dir3
$ rm f dir1/dir2/dir3 Force Remove Dir If Empty or no
$ rm p file1/dir4/file7/dir7

$ rmdir r dir2 Remove Dire and sub Director's and Files


$ mkdir -p dir1/dir2/dir3
$ rmdir -p dir1/dir2/dir3

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy and move N
F
P
files and Directorys L

Copying Files and Directory's


__________________________
The cp command copies files and directorys :

cp source[s] [target]

$ cp r dir1 /home/user1/myfiles
$ cp r .dir1 /home/user1/myfiles/momendir Copy Hidden Dir with new name

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy and move N
F
P
files and Directorys L

Moving Files and Directory's


_________________________
The mv command move files and directorys:
. mv <source> <Destination>

$ mv file1 /home/user1
$ mv file1 dir1 /home/user1 Move multi files and Dir
$ mv dir11 /home/user1/dir12 Move Dir with new name
_____________________________________________________
Hide File or Directorys
____________________

$ mv file1 .file1
$ mv dir4 .dir4

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy and move N
F
P
files L

File Link
________
File Link Type:
Hard Link you can store mirrored file in another location that
has every changed in the master file File Synchronization
Foul tolerance
Sof Link as short cut file
$ ln file1 /home/user1/file1 you can create with different name (Hard Link)

$ ln file1-s /home/user file1 (Soft Link)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create, delete, copy and move N
F
P
files L

Show File Contents


_______________

$ cat File2
--------------------------------------------------------------------------------
File Details
_________

$ wc file1 show n of line , carachters , words

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


View the content of both text and binary files F
N P
L
Displaying Files Page by Page
__________________________
With the more or less commands:

$ less File1

$ more File1

Displaying Binary Files


___________________
With the od command

$ od File1 Display File as Binary


$ od -c File1 Display File as Decimal
$ od h File1 Display File as Hexadecimal

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Splitting File F
N P
L

Splitting Files
___________
You can split a file into a smaller files with the split command
split -b <Bytes> file [prefix]

$ Split b 1024 File1 Filexs Split File1 to more Files each spitted File is <1024>

Join Smaller Files into Large File


____________________________

$ cat filexsa filexsb filexsc >output file name

Or

$ cat filexs* >output file name

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit5:
File and Directory Permissions

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Explain the Linux security model

o List the permissions required to perform several common


commands

o Change permissions using symbolic and octal notation

o Describe how default permissions are calculated

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the Linux F
N P
security model L

Access Level
Permission

User & Owner Group Other

-rw-r--r-- 1 user2 sales 171 Jun 4 10:23 file2


drwxr-xr-x 2 user1 hr 512 Jun 7 11:13 mydir
Owner
Link Size Modification Name
Counter
File Permi Time
Group
Type -ssion

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the Linux F
N P
security model L

Permissions Notation r read


___________________
rwx rwx rwx w write
User group other x execute
regular files:
r file is readable
w file is writeable
x file is executable ( if in an executable format )
directories:
r contents of directory can be listed (ls)
w contents can be modified (add/delete files)
x change into directory is possible (cd)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


List the permissions required to perform F
N P
several common commands L

$ ls l
-rw-r--r-- 1 user2 sales 171 Jun 4 10:23 file2
drwxr-xr-x 2 user1 hr 512 Jun 7 11:13 mydir

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Change permissions using symbolic and F
N P
octal notation L

Assign Permission

Numeric & Octal


Symbolic Method
Method

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Change permissions using symbolic and F
N P
octal notation L
U = User & Owner
+ add permission G = Group
- Remove Permission O = Other
A = All <u+g+o>
Assign Permission by Symbolic Method:-
__________________________________

$ chmod ugo+rwx file1 Full control 4 user group and other


$ chmod a+rwx dir1 Full control 4 user group and other
$ chmod o-wx dir2 Deny permission write and execute to other

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Change permissions using symbolic and F
N P
octal notation L

R 22 =4
User group other W 21 =2
rwx rwx rwx X 20 =1
- 0 =0
421 421 42 1 ---------------------
------ ------- ------- 7
7 7 7 =Full Control 4 (U+G+O)

Example:-

$ chmod 764 file1

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe how default permissions are F
N P
calculated L

Any New File


Or Directory
Crated by
default
Has default
permission from
System.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe how default permissions are F
N P
calculated L

Dir : 777 - 022 = 755 ( rwx rw- rw-)

Example:-

I need when create any new Directory the default permission is { rw- r r--} (644)

Net permission Full permission = umask


644 - 777 = 133

? UMASK is 133

$ umask 133

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe how default permissions are F
N P
calculated L

Change UMASK using Symbolic Method:


______________________________________

$ umask u=rwx,g=rw,o=r Set umask by symbolic

$ umask S Show Symbolic umask 4 all users

Note:
If Machine Restarted the umask change to default (022,002)

$ cat /etc/bashrc edit umask in this file by root 4 force umask


constant on all users

umask 022

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit6:
Linux Documentation & Help

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Describe the use of man

o Describe the use of info

o Describe the use of whatis

o Describe the use of help

o Describe the documentation Location

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the use of man F
N P
The man Command L
_________________
With the man command you can read the manual page of
commands.
Manual pages are stored in /usr/share/man

The manual page consists of:


Name The name of the command and a one-line description
Synopsis The syntax of the command
Description Explanation of how the command works and what it does
Options An explanation of the options
Files The files used by the command
Bugs Known bugs and errors
See also Other commands related to this one

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the use of man F
N P
$ man finger L

NAME
finger - user information lookup program
SYNOPSIS
finger [-lmsp] [user ...] [user@host]
DESCRIPTION
The finger command displays information
about the system users.
Options are:
-s Finger displays the user's login name,: :

The -k option of the man command or the apropos command


prints
out a description of all entries which match the given keyword

$ man k print

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the use of man F
N P
L
Manual pages are divided in 9 sections:
_________________________________
1. User commands
2. System calls
3. Libc calls
4. Devices
5. File formats and protocols
6. Games
7. Conventions, macro packages and so forth
8. System administration
9. Kernel
Certain subjects appear in multiple sections
To select correct section, add section number:
man 1 passwd (about the passwd command)
man 5 passwd (about the passwd file)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the use of man F
N P
L

$ man a passwd Show command Section page by page

$ man w passwd Command File Path

$ man k list search about <list> in entire manual

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the use of Info F
N P
L
The info Command
______________________
Sometimes a replacement for manual pages
Widely used by the GNU project
Information for info is stored in /usr/share/info
Some info commands:
space next screen of text $ info pwd
del or bs previous screen of text
n next node
p previous node
q quit info
/ or s search about word

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the use of help F
N P
L

The --help Option


________________
Another way of getting help about a command
Help is built in the command itself (if supported)

$ who --help
Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]
-h, --heading print line of column headings
-m only hostname and user
associated with stdin
-q, --count all login names and number of
users logged in
--help display this help and exit
--version output version information and exit

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the use of whatis F
N P
L

The whatis Option


________________
Another way of getting help about a command

$ whatis pwd

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the documentation F
N P
Location L

Usually stored in
/usr/share/doc/<programname>

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit7:
Tour Through Linux

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Describe the structure of the filesystem

o Mount and unmount Devices

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/bin, /lib, /sbin


____________
/bin contains executables for every user
/sbin contains system administration executables
/lib contains libraries
Should always be available
At system boot
In single user mode
When booting from rescue disk

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/Boot
_____
The /boot directory contains the kernel images, some other things
related to these images
and the files needed for the bootloader (LILO or GRUB).

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/dev
____
Contains special files that represent hardware devices
Block special device, for example, a hard disk
Character special device, for example, mouse and
keyboard

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/etc
___
Contains system-wide configuration files
Some subsystems have multiple files and therefore use a separate directory
/etc/X11 contains X Window System configuration
/etc/skel contains default user configuration files
/etc/sysconfig contains system configuration

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/home
_____

Home directories of users

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/mnt
____

Mount points for other filesystems

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/proc
_____
Virtual filesystem
Represents kernel and process information

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/root
____
Home directory of the root user

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/tmp
____

Temporary storage space for programs, users


Usually automatic cleanup mechanism active

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/usr
___
UNIX System Resources
Contains all programs, libraries and so on which are not
essential for system boot and emergency operations
/usr/local intended for programs not in the distribution
Locally developed
Locally compiled

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/var
____
Files of variable size
Logfiles
Lockfiles
Directories with variable content
Mail
Scheduling
Printing
Temporary storage space, longer than /tmp

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

/lost+found
__________
Exists in every filesystem
Place where lost+found files are stored after a crash recovery by fsck.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Describe the structure of the F
N P
filesystem L

Other Directories in /
____________________

/opt: used for some software from external providers


Separate filesystem advisable
Whatever you create yourself.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Mount and unmount Devices F
N P
L

The mount Command


____________________
The mount command mounts a filesystem
Makes it part of the unified filesystem structure
mount [-t type] [-o opts] device mountpnt

$ mount /dev/hda5 /usr

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Mount and unmount Devices F
N P
L

The umount Command


_____________________
The umount command unmounts a filesystem
Takes it out of the unified filesystem structure
Filesystem should not be busy
umount {device|mountpnt}

$ umount /dev/hda5
- OR -
$ umount /usr

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Mount and unmount Devices F
N P
L

The /etc/fstab File


_________________
/etc/fstab lists all known filesystems on the system

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit8:
Editing Files

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Determine the type of file using file

o Edit text files with vi

o Discuss other text file editors such as kedit

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Determine the type of file using file F
N P
L

Editing Files
__________
Use file command to determine the content of a file
To edit text files, use an editor
Non-text files can only be changed using the application
that created them, or with a hex editor
But most configuration files under Linux are text files

$ file /etc/passwd

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L

The vi text editor


______________
Default editor in all UNIX operating systems
Usually the only editor available in emergencies
Relatively hard to learn, but really powerful
As a Linux user, you should be able to use vi for basic editing tasks
-But it's OK if you prefer another editor for daily work
vi in Linux is usually vim (vi improved):
Syntax highlighting
Arrow keys, Del, BS work in insert mode
Multi level undo
Mouse support

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L

vi Modes
vi knows three modes of operation
Command mode (for simple, one-letter commands)
Edit mode (insert text)
ex mode (for complicated commands)
Can easily change between modes

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L

$ vi myfile.txt

Cursor Movement in Command Mode


_________________________________

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L

Editing Text in Command Mode


____________________________
To delete a single character under cursor x
To delete a single character left of cursor X
To replace a single character r
Undo the last change u
To repeat last command .
To join two lines together J

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L
Switching to Edit Mode
____________________
To insert text at begin of line I
To insert text before cursor i
To append text after cursor a
To append text at end of line A
To go back to command mode <ESC>

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L

Searching for mhany


___________________
To search for a pattern (in command mode): /<mhany>

Replacing Patterns
_________________
Advanced search and replace can be done in ex mode:
To replace old with new: :1,$s /old/new/g

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L
Cut, Copy and Paste
___________________
To cut a whole line into buffer: dd
To copy a whole line into buffer: yy
To paste contents of buffers here: p
To cut, copy multiple lines, proceed command by number: 3dd, 8yy

Exiting vi__
To save and exit in command mode ZZ
To save in ex mode :w
To forcefully save file in ex mode :w!
To quit without saving in ex mode :q
To forcefully exit in ex mode :q!
To save and exit in ex mode (recommended) :wq
To save and exit in ex mode, shorter :x

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Edit text files with vi N
F
P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L
Other Editors
___________
A typical Linux distribution comes with a large number of editors.
Examples:
Text mode editors
pico (really simple)
Original vi
emacs (even more powerful and complicated than vi)
Graphical mode editors
kedit, kwrite
gedit
Hex editors allow you to change non-text files if you know the
internal structure
khexedit

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit9:
Shell Basics

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Explain the function of the shell


o Discuss metacharacters and reserved words
o Use wildcards to access files with similar names
o Use redirection and pipes
o Use command substitution
o Work with shell variables
o Use aliases
o Create Scripts

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the function of the shell N
F
P
L

The Shell
The "shell" is the user interface to Linux

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Discuss metacharacters and F
N P
reserved words L

Metacharacters and Reserved Words


Metacharacters are characters that the shell interprets as having a
special meaning.
Reserved words are words that the shell interprets as special
commands.
Examples:
<>|;!?*[]$\"'`~(){}
Examples:
case do done elif else esac fi for function if in select then
until while

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use wildcards to access files F
N P
with similar names L

$ echo *[1-5] get all file that have no 1 to 5


test1 test2

$ echo [!t]* get all files exception have (t)


Myfile

$ echo ?[!y]*[2-5] non have (y) but have 2 to 5


test2 test1

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use redirection and pipes F
N P
L

File Descriptors
Every program has a number of file
descriptors associated with it
Three descriptors are assigned by the shell
when the program starts (STDIN,
STDOUT and STDERR)
Other descriptors are assigned by the
program when it opens files

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use redirection and pipes F
N P
L

Input Redirection

STDIN redirected from file:

$ cat < file1


Hi
Welcome
Etc

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use redirection and pipes F
N P
L

Output Redirection

$ ls > fileb

$ cat > new_filex


Save this line
<Ctrl-D>

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use redirection and pipes F
N P
L

Error Redirection

$ ls-l 2> errorfile

$ cat errorfile
Ls-l command not found
----------------------------------------------------------------
Redirect and append errors to a file:

$ cat-a 2>> errorfile

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use redirection and pipes F
N P
L

Pipes
A sequence of two or more commands separated by a
vertical bar (|) is called a pipe or pipeline

$ ls l | wc -l

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use redirection and pipes F
N P
L

Common Filters
expand, unexpand: Change tabs to spaces and vice versa
sed: Allows string substitutions
awk: Pattern scanning and processing
fmt: Insert line wraps so text looks pretty
tac: Display lines in reverse order
tr: Substitute characters
grep: Only displays lines that match a pattern
nl: Number lines
pr: Format for printer
sort: Sort the lines in the file

$ tr filea

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use redirection and pipes F
N P
L
Split Output
The tee command reads standard input and sends the
data to both standard out and a file.

$ ls | tee ls1.save | wc -l
3
$ cat ls1.save
file1
file2
file3

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use command substitution N
F
P
L

Command Substitution
Command Substitution allows you to use the output of a command
as arguments for another command.

$ echo there are $(cat filea | wc l)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use command substitution N
F
P
L

Command Grouping
Multiple commands can be entered on the same line,
separated by a semicolon (;)

$ echo my date is ; date ; cat filea ; ls

$ date ; pwd

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Work with shell variables N
F
P
L

Shell Variables
Variables are part of the environment of a process A variable has an unique name The
first character must not be a digit
To assign a value to a variable use:
variable=value

$ VAR1=Welcome in Linux
$ echo $VAR1
Welcome in Linux

$ VAR2=50
$ echo $VAR2
50

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Work with shell variables N
F
P
L

$ x=6

$ echo my number is $x
My number is $x

$ echo my number is $x
My number is 6

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Work with shell variables N
F
P
L

Standard Shell Variables


The shell uses several shell variables internally
These variables are always written in uppercase
Example:
$: PID of current shell
PATH: Path which is searched for executables
PS1: Primary shell prompt
PS2: Secondary shell prompt
PWD: Current working directory
HOME: Home directory of user
LANG: Language of user

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Work with shell variables N
F
P
L
Return Codes from Commands
A command returns a value to the parent process. By convention, zero means
success and a non-zero value means an error occurred.
A pipeline returns a single value to its parent
The environment variable ? contains the return code of the previous command.
$ ls
Fiel1 file2 dir1 dir2
$ echo $?
0
$ cat fileab
cat: filea: No such file or directory
$ echo $?
1

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Use aliases N
F
P
L

Aliases
The alias command allows you to set up aliases for often-used commands
Examples:

$ alias ll='ls -l'


$ alias rm='rm -i'
To show all currently defined aliases:
$ alias
To delete an alias:
$ unalias ll
$ ll
bash: ll: command not found

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create Scripts N
F
P
L
$ vi momenscript
>ls
>date
:wq
---------------------------------------------------------------------------------
$ chmod 700 momenscript

$ ls l
momenscript

$ bash momenscript
$ source momenscript
$ sh momenscript
$ . momenscript

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit10:
Working with Processes

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L
o Define a Linux process

o Describe the relationship between parent and child processes

o Explain the purpose of a shell

o Start foreground and background processes

o Explain the concept of signals and use them to terminate


processes
o Manage processes using GUI

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Define a Linux process N P
L

What Is a Process?
A program is an executable file
A process is a program which is being executed
Each process has its own environment:

To see the PID of your current shell process type:


$ echo $$

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Describe the relationship between N P
L
parent and child processes
All processes are started by other processes
Parent/Child relationship
$ ls -l

A process can be terminated because of two reasons:


The process terminates itself when done
The process is terminated by a signal from another process

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Describe the relationship between N P
L
parent and child processes
Monitoring Processes
The ps command displays process status information

ps supports a large number of options - you typically use ps aux:


a all processes attached to a terminal
x all other processes
u provides more columns

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Describe the relationship between N P
L
parent and child processes
Viewing Process Hierarchy
pstree shows process hierarchy

Or

$ top

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Start foreground and N P
L
background processes
Starting
Processes

Foreground Background
Processes Processes

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Start foreground and N P
L
background processes
Foreground Processes
$ find / -name README
Foreground processes are invoked by simply typing a command at
the command line.
Background Processes
$ find / -name README &
Background processes are invoked by putting an "&" at
the end of the command line.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the concept of signals and use F
N P
them to terminate processes L

Job Control in the Bash Shell

<ctrl-z> suspends foreground task


jobs lists background or suspended jobs
fg resume suspended task in the foreground
bg resume suspended task in the background

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the concept of signals and use F
N P
them to terminate processes L

Kill Signals
Several signals can be sent to a process
Using keyboard interrupts (if foreground process) $ kill -9 5698
Using the kill command
Synopsis: kill -signal PID
Using the killall command to kill all named apps
Synopsis: killall -signal application

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the concept of signals and use F
N P
them to terminate processes L

Running Long Processes


The nohup command stops a process from being killed if you
log off the system before it completes, by intercepting and
ignoring the SIGHUP and SIGQUIT (hangup and quit) signals.

$ nohup ls l Run command


$ logout Logout from system
Login login to system

$ cat nohup.out if you need to show last run command result

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the concept of signals and use F
N P
them to terminate processes L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the concept of signals and use F
N P
them to terminate processes L

The nice Command


The nice command is used to start a process with a user
defined priority
nice [-n <value>] <original command>

$ nice n 11 ls l Run (ls l)command with priority <11>

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Explain the concept of signals and use F
N P
them to terminate processes L

The renice Command


The renice command is used to change the priority of a
currently running process
renice <new_priority> <PID>

$ renice 7 6593 Change pritority value 4 PID 6593 to <7>

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Manage processes using N
F
P
GUI L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit11:
Linux Utilities

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Use the find and locate command to search for files


o Use the cut command to list specific columns of a file
o Use the grep command to search text files for patterns
o Use the head and tail commands to view specific lines in a file
o Use the sort command to sort the contents of a file
o Use the type, which and whereis commands to find commands
o Use the file command to find out the content of a file
o Use the join commands to combine files
o Comprise the files

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The find Command N
F
P
L
$ find path expression

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The find Command N
F
P
L
$ find . -name phone Search about phone in current directory
$ find . -name phone print Search and print path
$ find . -name 'b*' -exec ls -i {} \; search any file have (B) and execute as ls -l
$ find . -name b\* -ok rm {} \; search any file have (B) and remove file by file
$ find . -name b\* -exec rm {} \; search any file have (B) and remove all file
$ find . -perm 764 Search by permision 764
$ find . -name 's*' -type f -a -size +2\ Search by size +2 k

locate Command
locate allows you to quickly find a file on the system, based on
simple criteria

$ updatedb
$ locate README

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The Cut Command N
F
P
L

The cut Command


Pull selected columns or fields from one or more files.
Syntax:
cut -f(ields) -d(elimiter) file(s)
cut -c(haracters) file(s)

$ cut f 1,3,4,7,9 d: /etc/passwd


$ cut f 1-18 d /etc/passwd > outputfile
$ cat outputfile

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The grep Command N
F
P
L
The grep Command
Searches one or more files or standard input for lines matching pattern
Simple match or Regular Expression
Syntax
grep [options] pattern [file1 ...]

$ grep root /etc/passwd get number of (root) word in etc/passwd file

Options:

-c root$ get but root must existing in last line


-c root^ get but root must existing in first line

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The grep Command N
F
P
L
The grep Command

$ fgrep Faster cant use Metacharacters (* \ / -)


$ egrep search about more than words in file such as < $
grep test1 ; phone
$ zgrep Search in Compressed file (file.tar.gz or file.bz2)

Note:-
You can search about paragraph in file by paragraph

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The head and tail Command N
F
P
L

The head and tail Commands


The head command can be used to view the first few lines of a file
or files. The command syntax is:
$ head [-lines] file(s)

$ head -4 /etc/passwd Show only first 4 lines in passwd file


---------------------------------------------------------------------------
The tail command displays the last few lines of a file or files. The
command syntax is:
$ tail [{-lines|+lines|}] file(s)

$ tail -4 /etc/passwd Show only last 4 lines in passwd file

$ tail -4 | head -4

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The Sort Command N
F
P
L

The Sort Command


The sort command sorts the lines in the file specified and writes the result to
standard output.

$ sort /etc/passwd Sort file from A-Z


$ sort n /etc/passwd Sort file by number from 1-9
$ sort r /etc/passwd Sort file by reverse viewer

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The type, which and whereis commands N
F
P
L

The type, which and whereis Commands


To find out what the path to a command is, use type

$ type ls date echo


---------------------------------------------------------------------------------------------
To find out where the binary is located, use which

$ which ls date echo


---------------------------------------------------------------------------------------------
To locate the binary, source and manual page files of a command, use whereis

$ whereis ls date echo

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The file Command N
F
P
L

The file Command


With the file command, you can find out what the type of data in the file is.

$ file /etc/passwd

$ file /lib/cpp

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The join command N
F
P
L
The Join Command
The join and paste commands allow you to merge files together.

(1)
$ vi one
A xxx
B xxx
C xxx
:wq
(2)
$ vi two
A yyy
B yyy
C yyy
:wq

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The join commands N
F
P
L
(3)
$ join one two
A xxx yyy
B xxx yyy
C xxx yyy
--------------------------------------------------------------------------------------
Output this value

$ join one two > mergedfile

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Compress The File N
F
P
L
The gzip, gunzip and zcat Commands
To compress or uncompress files use gzip, gunzip or zcat

$ gzip fileneme Compress File

$ gunzip filename Un Compress file

$ zcat file.gz Show compressed file

$ zgrep file.gz

$ zless file.gz

$ zmore file.gz

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit12:
Shell Scripts

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Create a Scripts

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Create Scripts N
F
P
L
$ vi momenscript
>ls
>date
:wq
---------------------------------------------------------------------------------
$ chmod 700 momenscript

$ ls l
momenscript

$ bash momenscript
$ source momenscript
$ sh momenscript
$ . momenscript

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit13:
Linux GUI

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o Components of the X Window System

o The function of the X Server

o The main characteristics of Desktop Environments

o Switch between GNOME and KDE

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Components of the X Window System N
F
P
L

The Linux Graphical User Interface


The "X Window System" is the GUI of Linux
Developed at MIT in 1984
Current standards body: X Consortium Shortname: X ( XI Graphic &
Xfree Graphic)
X uses client-server model with network connections
Highly flexible
Easy exchange of components
Supports networked applications and sessions, independent of
the OS

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The function of the X Server N
F
P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Components of the X Window System N
F
P
L
X Components
An X Server
Controls keyboard, mouse and one or more screens
Controls resolution, refresh rate and color depth
Allows simultaneous access by several clients
Performs basic graphic operations
Forwards keyboard and mouse events to the correct clients
An X Client
Is for instance an application
Receives keyboard and mouse inputs from server
Sends output to be displayed to server
A Window Manager
Is a special X Client
Performs "windows dressing" on other clients
Allows other client windows to be moved, iconified and so forth

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


X N
F
P
L

XFree86 Configuration
XFree86 needs to be configured for your hardware
Keyboard
Mouse
Graphical adapter
Monitor
Things to configure: refresh rate, resolution, color depth
Config file: /etc/X11/XF86Config

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


X N
F
P
L

X Servers in Linux

Most distributions use XFree86 (www.xfree86.org) as their X Server


Open Source
Supports most video adapters
Other X Servers for Linux are available as well
Metro-X (http://www.metrolink.com)
Xi Graphics (http://www.xig.com)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


The main characteristics of N
F
P
Desktop Environments L

Desktop Environments

Examples:
GNOME (GNU Network Object Model Environment)
KDE (K Desktop Environment)

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Switch between GNOME and KDE N
F
P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


RHCE

F
N P
L

RH033 - Red Hat Linux Essentials

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Unit14:
Basic System Configuration Tool

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
Module Overview N P
L

o List the order of login scripts

o Discuss System Management tools

o Install and uninstall additional software

o Configure a printer

o Configure a Network and sound card

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


List the order of login scripts N
F
P
L

Customizing User Environment

Bash Initialization
/etc/profile Contain system administrator processes
$ HOME/.bash_profile Contain User processes
$ HOME/.bash_login Contain Login User Configuration
$ HOME/.profile
$ HOME/.bash_logout Contain Logout User Configuration
$ HOME/.bash_history Save all Command history.
$ HOME/.bashrc Contain Alias Command

# cat .bash_history

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Discuss System Management tools N
F
P
L

List setup command (TUI Tool)

# setup

List system-config-<tab> command (GUI Tool)

# system-config-<press tab>

GUI System \ Administration

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Install and uninstall additional software N
F
P
L

Adding/Removing Software Using RPM

Use rpm to install or upgrade software packages


Common options:
-i : installing new packages
-U : upgrading existing packages
-e : removing packages
RPM
-h : Shows a progress bar
Red hat Package Management
$ rpm -ihv momenpro.i386.rpm
momenpro ###############....
$ rpm -Uhv momenpro.i386.rpm
momenpro ###############.....
$ rpm -e momenpro

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Install and uninstall additional software N
F
P
L
You can Donwload any RPM pachage using Linux Tools such as , wget :

# wget <download link>


#wget http://www.download.org/rpmpackages/webmin.rpm

30% Webmin.rpm ###############.... 70kbp/s Total Size 16MB

Use rpm Command

# rpm i packagename
# rpm ivh packagename install package with show information and progress
# rpm Uvh Packagename upgradeing with show info and progress
# rpm q packagename Quarry about packagename

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Install and uninstall additional software N
F
P
L

Install tar package and compressed file:


# tar zxf packagename.tar.gz
( z ) for gzip
( x ) for tar package extension
( f ) for file

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


X N
F
P
L

Install and access webmin


To access webmin interface
http://localhost.localdomain:10000

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Configure a printer N
F
P
L

To access Printer Manager Console

http://localhost:631

Add New Printer ?


Add New Class ?
Manage Permission ?
.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Configure a Network and N
F
P
Sound card L

Configure Network Card :


# ifconfig for show ethernet configuration in tur
# neat for show ethernet configuration in GUI
# ifconfig eth0 select and edite in eth0
# system-config-network -()()()()()()-

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Configure a Network and N
F
P
Sound card L

Configure Sound card :

# system-config-soundcard

-GUI System\ Administration \Sound card detection

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Certification Information
F
The Red Hat (http://www.redhat.com) is the distributor of Red Hat Linux, N P
one of the leading commercial Linux distributions. As part of their service L
organization they have developed their own education leading to the Red
Hat Certified Technician and Red
Hat Certified Engineer exams. In contrast to the other Linux exams, the
RHCT and RHCE exams are performance based, which means that the
examinee takes place behind an actual Red Hat Linux system and needs to
demonstrate his/her skills on this system. The practical components of the
RHCT exam takes about 2.5 hours, while the practical components of the
RHCE exam take about five hours.
----------------------------------------------------------------------------------------
Linux Professional Institute (http://www.lpi.org) is an organization run by
volunteers with the sole purpose of implementing a vendor-neutral
certification program for Linux. They are sponsored by a number of Linux-
related companies, among which IBM. The certification tests are delivered
by VUE (Virtual University Enterprises) (http://www.vue.comLPI aims to
implement three levels of certification, of which the first two levels are
currently ready.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Certification Information
F
UnitedLinux (the consortium of Linux distributors SUSE, SCO, N P
TurboLinux and Conectiva, http://www.unitedlinux.com) has announced a L
UnitedLinux certification, which will be an extension of the LPI
certification.
-----------------------------------------------------------------------------------------------
CompTIA (http://www.comptia.org) is the organization that has, in the past,
already developed a number of certifications that are aimed mostly at
helpdesk personnel and hardware engineers. Recently CompTIA introduced
the Linux+ exam, which is aimed at Linux Professionals with 6 months of
experience with Linux. CompTIA tests are also delivered by VUE, and by
Prometric (http://www.prometric.com).

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Certification Information
F
The LX02 (Linux Power User) is the entry course in the IBM/Linux curriculum. Its N P
aim is to teach a Linux novice to install and configure Linux so that he/she is able to L
run Linux on
his/her personal workstation or home system in an environment that is mostly based
on MS-Windows.
The LX03 (Linux System Administration I: Implementation) is the main system
administration course. Its aim is to teach a Linux user the techniques and practices
used in installing, configuring, running and maintaining a Linux-based server.
The LX07 (Linux Network Administration I: TCP/IP and TCP/IP Services) is the
main
network administration course. Its aim is to teach a Linux system administrator how
to configure TCP/IP and various TCP/IP services that run on Linux.
The LX22 (Linux Perl Programming) is the course that covers Perl programming.
The LX23 (Linux Bash Programming) is the course that covers Bash shell
programming and the various programs that are typically used in shell programs,
such as grep, awk and sed.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Certification Information
F
The LX24 (Linux Network Administration II: Network Security and Firewalls) N P
covers the configuration of a full-function firewall under Linux. As such, it also L
covers a number of
security aspects of Linux that are not particularly related to firewalls, but apply to
any networked system.
The LX25 (Linux as a Web server - Apache) is the course which covers Apache,
the most commonly used Web server on Linux and other UNIX platforms.
The LX26 (Linux integration with Windows - Samba) is the course which covers
Samba, the product which emulates a networked Windows NT server to the network.

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


Certification Information
F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

Copyright March 2012 , Engineer Momen Hany Mohamed

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


F
N P
L

By Eng Momen Hany Mobil: 01143739545 ^ Email: IT.momenhany@hotmail.com


White Board

Last Viewed
Copyright March 2012 ,
Engineer Momen Hany Mohamed

S-ar putea să vă placă și