Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 79

Linux System and

Network Administration

Presented by:
Getaneh T.

gdfdgdfdh
fhfjdfhjgfh
gfgjdfhgjd
hffkkfjgkfj
1
Background on Linux
Version of UNIX
Linus Torvalds – Creator of Linux
Open Source Operating System
Free Software
Source Code Available

2
Where is Linux Used?

 75% of respondents were already using


Linux and another 14% were evaluating it
 43% of all web sites use Linux servers
running the Apache Web server

3
How is Linux Used?

 Personal Workstation
 File and Print Server
 Internet Service Provider
 Three-tier Client/Server

4
Using Linux on Personal Computers

 Linux kernel for free


 Kernel is central component
 Kernel can be customized to user’s needs

5
Linux Distributions

 Corel Linux
 Debian Linux
 OpenLinux (Caldera)
 Red Hat
 Slackware
 SuSE
 TurboLinux

6
Configuring Linux System

1. Selecting a language
2. Choosing automatic or manual partitioning
3. Type of software to install
4. Choosing which drive to boot from

7
Configuring Linux (continued)

5. Adjusting the time settings


6. Configuring the hardware aspect of the
system
7. Creating the root password (for the
Administrator), and user accounts
8. Hardware configuration

8
Why Use Linux?

 Costs less
 Stable
 Reliable
 Extremely powerful

9
LINUX VS WINDOWS
 Financial Differences
 Technical Differences
 End-User Differences

10
Financial Differences

11
Linux vs. Windows

COST
LINUX WINDOWS
Online Downloads Free Not Available
Retail Price, CD $50 $300

12
 Cost for Businesses
 Companies have to spend millions for licenses for
ever individual windows computer
 For Linux companies don’t have to spend
anything

13
Technical Differences

14
Linux vs. Windows
 Keeping up to date
By Upgrading
Linux upgrades faster than Windows
 Compatibility
Linux is Backward Compatible unlike
Windows

15
Linux vs. Windows

Features Provided
 Both support Dynamic Caching
 Both have Multi-user Support

16
Linux vs. Windows
• Application Differences
 No commercial word processor for Linux,
which matches the quality for Windows

17
End-User Differences

18
• Proprietary vs. Open Source
 Windows is a Proprietary Technology
Applications will only work on Windows
 Linux – Open Source

19
Linux

 Complete information needed for download


 Technical help – Available on Internet (user
must be comfortable with UNIX system)
 Windows word processor is better than Linux

20
Linux vs. Windows

In The Commercial Arena


 Head to head competition
 Used side by side as servers
 Both handled daily workload for several small
business operations
 Linux with hardware disadvantage supported
a community of users 3 times size of NT’s

21
In The Commercial Arena
 System Administration – Most significant
difference
 Linux – tougher environment
 Linux requires learning multi-user issues built
into Unix-file permissions
 windows – easier environment
 windows requires less effort to get a starter
server up and running
 But in windows you have to solve multi-user
issues for each and every subsystem

22
In The Commercial Arena

 windows – graphical interfaces, wizards and


easy-to-grasp metaphors
 But as server chores become more customized,
windows cannot handle it
 Linux – textual interface (with X-Window)
 But for complex jobs, Linux gives a powerful set
of tools

23
In The Commercial Arena

 windows – easy for non-programmer


 Linux – programmer-based culture

24
Conclusion

“When is it best to use Linux and when should


some other operating system be preferred?”
 It all depends on the user

25
Booting and Shuting Down

26
Bootstrapping (simplified version)
BIOS Boot Loader Kernel Initialization

init

Runs scripts from Spawns Spawns


/etc/rc[0-6].d/ getty processes Xdm/gdm processes

login login
27
BIOS
 Basic Input/Output System
 Contains information about the machine’s
configuration. Eg. IDE controller, NIC
 PC knows which device to boot from via BIOS
 PC tries to run code from the MBR, ie. 1st 512 bytes,
of the disk
 MBR tells the PC to load the boot loader from
certain disk partition
 The boot loader loads the kernel

28
Boot Loaders – LILO(LInux Loader)
 Traditional and stable
 /etc/lilo.conf
 boot=/dev/hda

 root=/dev/hda1

 timeout=5

 image=/boot/vmlinuz-2.6.20

 label=Linux
 read-only
 other=/dev/hdb1

 label=Windows
 table=/dev/hdb
 To install it
 $ lilo

 lilo must be run after every reconfiguration

29
Boot Loaders – LILO (cont)

 At LILO prompt
 LILO: linux init=/sbin/init
 LILO: linux init=/bin/bash
 LILO: linux root=/dev/hda5
 LILO: linux single

30
Boot Loaders – GRUB
 GRand Unified Boot loader
 Read configuration file at boot time
 Understand filesystems and kernel executable formats
 ie. Only need to know the device, disk partition and

kernel filename
 GRUB device (hd0,0) → /dev/hda1 or /dev/sda1
 To install GRUB (for the very first time)
 $ grub-install ‘(hd0,0)’

 Edit /boot/grub/grub.conf

31
Boot Loaders – GRUB (cont)
 /boot/grub/grub.conf
 default=0

 timeout=5

 splashimage=(hd0,0)/boot/grub/splash.xpm.gz

 title CentOS (2.6.18-8.el5)

 root (hd0,0)
 kernel /boot/vmlinuz-2.6.18-8.el5 ro root=LABEL=/
 initrd /boot/initrd-2.6.18-8.el5.img
 title Windows

 rootnoverify (hd1,0)
 chainloader +1

32
Boot Loaders – GRUB (cont)

 At the splash screen


 Hit ‘a’ and type “ single” to boot to single-user
mode
 Hit ‘c’ to enter command-line mode
 To boot other OSes that aren’t in grub.conf
 Display system information
 Press TAB to see possible commands

33
Kernel Initialization
 A program itself
 /vmlinuz or /boot/vmlinuz
 Two-stage loading process
 initrd (init RAM disk)
 A transient root filesystem in RAM before a real root
filesystem is available
 Eg. It is used to install file system modules into the kernel
 The real root filesystem
 Device detection and configuration
 You tell the kernel what to expect
 The kernel probes the H/W itself
 Kernel threads creation
 Eg. init (a user process), kjournald, kswapd

34
Single-user mode
 A manual mode after kernel initialization and before
running startup scripts
 “single” is passed to init, sulogin is run instead
 Most system processes are not running
 Users can’t log in, except root
 / is mounted read-only
 $ mount -o rw,remount /
 Check/repair the disk if there are disk problems
 $ fsck -y /dev/sda1
 Run ‘exit’ to exit single-user mode

35
Startup/Init Scripts

 After Kernel initialization, a process called init


is created with PID 1
 init runs startup scripts (normal shell scripts)
to perform specific tasks, eg.
 Setting the hostname, time zone, etc
 Checking and mouting the disks
 Configuring network interfaces
 Starting up daemons and network services

36
Startup/Init Scripts (cont)
 Startup scripts (rc files) are run based on run levels
 0 the level in which the system is completely shut down
 1 single-user mode
 2 multiuser mode
 3 full multiuser mode
 4 unused
 5 X11
 6 reboot level
 Starts with run level 0 to the default run level (usually 3)
 /etc/inittab tells init what to do at each level
 To find out which run level the system is current in
 $ runlevel

37
Startup/Init Scripts (cont)
 init runs the scripts from /etc/rc.d/rc[0-6].d/
 /etc/rc.d/rc0/K25sshd → /etc/init.d/sshd
 /etc/rc.d/rc3/S55sshd → /etc/init.d/sshd
 Each server/daemon provides a master script
 Stored in /etc/init.d
 Understands the arguments: start, stop, restart
 /etc/init.d/sshd start
 run level 0 → 3
 /etc/rc.d/rc3/S* start
 run level 3 → 0
 /etc/rc.d/rc0/K* stop

38
Startup/Init Scripts (cont)

 Use chkconfig instead. Eg.


 $ chkconfig --add sshd
 $ chkconfig --del sshd
 Before that, need to add/modify
/etc/init.d/sshd
 # chkconfig: 2345 55 25
 sshd should be started/stopped at run level 2, 3, 4 and 5
with the start priority of 55 and the stop priority of 25

39
Reboot & Shutdown

 To reboot
 $ shutdown -r now
 $ reboot
 $ telinit 6
 To halt
 $ shutdown -h now
 $ halt
 $ telinit 0
 $ poweroff

40
Reboot & Shutdown (cont)

 To shutdown gracefully
 $ shutdown -h +15 “Shutdown in 15 mins”

41
Kernel image
 The kernel is the central part in most computer operating
systems because of its task, which is the management of
the system's resources and the communication between
hardware and software components
 Kernel is always store on memory until computer is tern
off
 Kernel image is not an executable kernel, but a
compress kernel image
 zImage size less than 512 KB
 bzImage size greater than 512 KB

42
Task of kernel

 Process management
 Memory management
 Device management
 System call

43
Major functions flow for Linux kernel boot

44
Init process
 The first thing the kernel does is to execute init
program
 Init is the root/parent of all processes executing on
Linux
 The first processes that init starts is a script
/etc/rc.d/rc.sysinit
 Based on the appropriate run-level, scripts are
executed to start various processes to run the system
and make it functional

45
The Linux Init Processes

 The init process is identified by process id "1“


 Init is responsible for starting system processes as defined in the
/etc/inittab file
 Init typically will start multiple instances of "getty" which waits for
console logins which spawn one's user shell process
 Upon shutdown, init controls the sequence and processes for sh
utdown

46
System processes

Process ID Description
0 The Scheduler
1 The init process
2 kflushd
3 kupdate
4 kpiod
5 kswapd
6 mdrecoveryd

47
Inittab file

 The inittab file describes which processes are


started at bootup and during normal operation
 /etc/init.d/boot
 /etc/init.d/rc
 The computer will be booted to the runlevel as
defined by the initdefault directive in the
/etc/inittab file
 id:5:initdefault:

48
Runlevels
 A runlevel is a software configuration of the
system which allows only a selected group of
processes to exist
 The processes spawned by init for each of
these runlevels are defined in the /etc/inittab
file
 Init can be in one of eight runlevels: 0-6

49
Runlevels

Runleve Scripts Director State


l y
(Red Hat/Fedor
a Core)
0 /etc/rc.d/rc0.d/ shutdown/halt system
1 /etc/rc.d/rc1.d/ Single user mode
2 /etc/rc.d/rc2.d/ Multiuser with no network services exported

3 /etc/rc.d/rc3.d/ Default text/console only start. Full multiuser

4 /etc/rc.d/rc4.d/ Reserved for local use. Also X-windows (Slackware/BSD)

5 /etc/rc.d/rc5.d/ XDM X-windows GUI mode (Redhat/System V)


6 /etc/rc.d/rc6.d/ Reboot

s or S Single user/Maintenance mode (Slackware)

M Multiuser mode (Slackware)

50
rc#.d files

 rc#.d files are the scripts for a given run level


that run during boot and shutdown
 The scripts are found in the directory
/etc/rc.d/rc#.d/ where the symbol #
represents the run level

51
init.d

 Deamon is a background process


 init.d is a directory that admin can start/stop i
ndividual demons by changing on it
 /etc/rc.d/init.d/ (Red Hat/Fedora )
 /etc/init.d/ (S.u.s.e.)
 /etc/init.d/ (Debian)

52
Start/stop deamon

 Admin can issuing the command and either


the start, stop, status, restart or reload option
 i.e. to stop the web server:
 cd /etc/rc.d/init.d/
 (or /etc/init.d/ for S.u.s.e. and Debian)
 httpd stop

53
LINUX FILING SYSTEM

Getaneh T.

54
Introduction to Linux

LINUX Structure

55
Introduction to Linux

LINUX File System

56
Introduction to Linux

File System

The Linux file system looks like an inverted tree


structure.
Its structure is hieratical.
You start with the root directory, denoted by /, at
the top and work down through sub-directories
underneath it.

57
Introduction to Linux

File System
Each node is either a file or a directory of files,
where the latter can contain other files and
directories.
You specify a file or directory by its path name,
either the full, or absolute, path name or the one
relative to a location.
The full path name starts with the root, /, and
follows the branches of the file system, each
separated by /, until you reach the desired file,
e.g.:
/home/condron/source/xntp

58
Introduction to Linux

File System
A relative path name specifies the path relative to
another, usually the current working directory that
you are at. Two special directories :
. the current directory
.. the parent of the current directory
So if I'm at /home/frank and wish to specify the path
above in a relative fashion I could use:
../condron/source/xntp
This indicates that I should first go up one directory
level, then come down through the condron directory,
followed by the source directory and then to xntp.

59
Introduction to Linux

Structure of Standard Directories


in Linux
/ The ancestor of all directories on the system; all
other directories are subdirectories of this
directory, either directly or through other
subdirectories.
/bin Essential tools and other programs (or
binaries).
/dev Files representing the system's various
hardware devices. For example, you use the file
`/dev/cdrom' to access the CD−ROM drive.
/etc Miscellaneous system configuration files,
startup files, etc.

60
Introduction to Linux

Structure of Standard Directories


in Linux
/home The home directories for all of the system's
users.
/lib Essential system library files used by tools in
`/bin'.
/proc Files that give information about current
system processes.
/root The superuser's home directory, whose
username is root. (In the past, the home directory
for the superuser was simply `/'; later, `/root' was
adopted for this purpose to reduce clutter in `/'.)

61
Introduction to Linux
Structure of Standard Directories
in Linux
/sbin Essential system administrator tools, or
system binaries.
/tmp Temporary files.
/usr Subdirectories with files related to user tools
and applications.

62
Introduction to Linux

Directories, Files and Inodes


Every directory and file is listed in its parent
directory.
In the case of the root directory, that parent is itself.
A directory is a file that contains a table listing the
files contained within it, giving file names to the
inode numbers in the list.
The information about all the files and directories is
maintained in INODE TABLE
An Inode (Index Nodes) is an entry in the table
containing information about a file (metadata)
including file permissions, UID, GID, size, time 63
stamp, pointers to files data blocks on the disk etc.
Introduction to Linux
Users, Groups and Access
Permissions
In LINUX, there is a concept of user and an
associated group

The system determines whether or not a user or


group can access a file or program based on the
permissions assigned to them.

Apart from all the users, there is a special user


called Super User or the root which has permission
to access any file and directory

64
Introduction to Linux

Access Permissions
There are three permissions for any file, directory
or application program.

The following lists the symbols used to denote


each, along with a brief description:

r — Indicates that a given category of user can


read a file.

w — Indicates that a given category of user can


write to a file.

x — Indicates that a given category of user can


execute the file.
65
Introduction to Linux

Access Permissions
Each of the three permissions are assigned to
three defined categories of users.
The categories are:

owner — The owner of the file or


application.
group — The group that owns the file or
application.
others — All users with access to the
system.

66
Introduction to Linux

Access Permissions
One can easily view the permissions for a file by
invoking a long format listing using the command
ls -l.

For instance, if the user juan creates an executable


file named test, the output of the command ls -l
test would look like this:

-rwxrwxr-x 1 juan student 0 Sep 26 12:25 test

67
Introduction to Linux

Access Permissions
The permissions for this file are listed are listed at
the start of the line, starting with rwx.

This first set of symbols define owner access.

The next set of rwx symbols define group access

The last set of symbols defining access permitted


for all other users.

68
Introduction to Linux

Access Permissions
This listing indicates that the file is readable,
writable, and executable by the user who owns the
file (user juan) as well as the group owning the file
(which is a group named student).

The file is also world-readable and world-


executable, but not world-writable.

69
Introduction to Linux

Listing the Content of a Directory

ls is used to list the contents of a directory.

If the command ls is written with parameter –l then


the command lists contents of the working
directory with details. Example:

$ ls –l

70
Introduction to Linux

Moving in Directories
cd try_it
Changes the directory to try_it
pwd
Prints present working directory (e.g.
/home/smith/try_it)
cd .. Move to superior directory
pwd : Prints /home/smith
cd /home The absolute path
pwd : Prints /home
cd The system is returned to the user home
directory
pwd : Print /home/smith
71
Introduction to Linux

Make Directory

The command mkdir my_dir

makes new directory my_dir (the path is given


relative) as a subdirectory of the current directory.

72
Introduction to Linux

Remove Directory

The command rmdir your_dir


removes directory your_dir if it is empty.

73
Introduction to Linux

Copy File

The command cp file_1 file_2

copies file_1 to file_2. The both files must be in the


same working directory. If they are in various
directories, the path must be given.

74
Introduction to Linux

Rename and/or Move the File

The command mv file_1 file_2

moves file_1 to file_2

The both files must be in the same working


directory.

If they are in different directories, the path must be


given.

The file_1 is removed from the disk.

75
Introduction to Linux

Remove File
The command rm file_a
removes the file_a from the system
If you use wildcard. For example
rm h*c
you will remove all files beginning with h and
ending with c which are in working directory.
If you write
rm *
you will erase all files from your working directory.
76
Introduction to Linux

Access Permission of File/Directory


The ownership of the file or directory can be changed using
the command
chown <owner> <file/directory name>
The group of the file or directory can be changed using the
command
chgrp <group> <file/directory name>
The permissions of the file can be changed using chmod
command
chmod -R ### <filename or directory>
-R is optional and when used with directories will traverse all
the sub-directories of the target directory changing ALL the
permissions to ###.

77
Introduction to Linux
Access Permission of
File/Directory
The #'s can be:
0 = Nothing
1 = Execute
2 = Write
3 = Execute & Write  (2 + 1)
4 = Read
5 = Execute & Read (4 + 1)
6 = Read & Write (4 + 2)
7 = Execute & Read & Write (4 + 2 + 1)

78
Introduction to Linux

Assignment
Login as guest (password is guest)
Find the present Directory
Write the root directory structure
Write a few commands available in /bin and /sbin directory
Find the guest directory
Write the permissions of guest directory
Create a new Directory test in guest directory
Copy the file /etc/resolv.conf in test directory
Rename the test directory to testing
Delete the testing directory
Change the permissions of guest directory to 700
Change the permissions of /tmp directory to 700

79

You might also like