Vous êtes sur la page 1sur 50

LINUX BASED NETWORKS

Linux Based Networks


Instructor: Zia-ul-Haq Ch.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 1

LINUX BASED NETWORKS

Todays Agenda
File system Hierarchy Standard
Linux File System
Comparison of MS-DOS & Linux.
DOS to Linux Cheat Sheet.
File Systems
File System Types
Device Driver Names
Partitioning
The mount command
The UNIX File System Design
Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 2

LINUX BASED NETWORKS

Comparison of MS-DOS & Linux


Microsoft

Linux

The directories in an MS-DOS


path are separated by \

In Linux path are separated


by /.

In MS-DOS, file names are


case-insensitive

In Linux they are case


sensitive

The dot in an MS-DOS file


name separates the name part
from the extension.

In Linux a dot is like any


other character in a filename.

In MS-DOS, each file system


resides on its own drive,
designated by d:.
Filesystem Hierarchy Standards & filesystem Structure

In Linux, all file systems are


part of a single hierarchical tree
descending from the root
directory /.
Class Meeting 3

Slide : 3

LINUX BASED NETWORKS

Comparison of MS-DOS & Linux


Microsoft

Linux

In MS-DOS, an executable file In Linux, any file whose


is one with an extension of
execute permission is turned on
.exe, .com, or .bat.
is executable, regardless of its
name.
An MS-DOS, file has only one
name.
Linux file may have several
name, each represented by
In MS-DOS you can set
different link.
attributes to make file read
only, hidden.
In Linux you can set
permissions on a file.
In MS-DOS you are
automatically connected to
In Linux, you must log in and
your system when you turn on
provide a password.
your system.
Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 4

LINUX BASED NETWORKS

DOS to Linux Cheat Sheet


Many Linux commands you type at a shell prompt are
not that different from the commands you would type
either in MS-DOS or in Windows (from the MS-DOS
prompt). In fact, some commands are identical.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 5

LINUX BASED NETWORKS

DOS to Linux Cheat Sheet

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 6

LINUX BASED NETWORKS

File Systems
The file system is a combination of the partitions
and directories that make up your Linux system.

It is important to keep the file system healthy and


organized or you end up spending more time
searching for files and programs than actually
administering the system.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 7

LINUX BASED NETWORKS

File System Types


ufs
UNIX File System, based on BSD Fat Fast File System (default).
hsfs
Depends
on the
ofCDROMs
kernel, and
LINUX
canRock
High Sierra
Fileconfiguration
System, used by
supports
hsfs
support
types
FS (more
than
20). that it does not
Ridgedifferent
extensions.
Veryof
similar
to ufs,
except
support writable media or hard links. (iso9660)
nfs
Network File System, the default distributed file system type
rfs
Remote File Share, AT&Ts RFS product.
product.
ext2 Second Extended
Extended File
File System.
System. Common Linux file system.
proc Process Access File System,
System, allows access to active processes
and their images. This is not a real file system; instead, it's an
interface to the Linux kernel.
msdos
msdos Used
Used to
to access
access MS-DOS
MS-DOS files
files from Linux.
swap swap partitions.
vfat
Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 8

LINUX BASED NETWORKS

Samples of Device Driver Name

Devicedriver
driver
Device
/dev/hda
/dev/hda
/dev/hdb
/dev/hdb
/dev/hdc
/dev/hdc
/dev/hdd
/dev/hdd

Drive
Drive
MasterIDE
IDEdrive,
drive,primary
primaryIDE
IDEbus.
bus.
Master
SlaveIDE
IDEdrive,
drive,primary
primaryIDE
IDEbus.
bus.
Slave
MasterIDE
IDEdrive,
drive,secondary
secondaryIDE
IDEbus.
bus.
Master
SlaveIDE
IDEdrive,
drive,secondary
secondaryIDE
IDEbus.
bus.
Slave

/dev/sda
/dev/sda
/dev/sdb
/dev/sdb
/dev/st0
/dev/st0
/dev/scd0
/dev/scd0

FirstSCSI
SCSIhard
harddrive.
drive.
First
SecondSCSI
SCSIhard
harddrive.
drive.
Second
FirstSCSI
SCSItape
tapedrive.
drive.
First
FirstSCSI
SCSICD-ROM
CD-ROMdrive.
drive.
First

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Linux

Slide : 9

LINUX BASED NETWORKS

Partitioning
For a large hard disk, it's better to split it into
several partitions (fdisk command):
The root partition
/dev/hda1
/dev/hda1
where / resides.
/dev/hda5
/dev/hda5
Contains all the things necessary
/dev/sda2
/dev/sda2
to start the system, (50MB to 100MB)
The swap partition
Used to support virtual memory.
The minimum size is equal to the size of RAM
(or 16MB), while the maximum size is roughly 2
x Physical memory.
Linux can support more than one swap partition
and swap file.
Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 10

LINUX BASED NETWORKS

Mount Points

A mount points is defined as the directory, such as "/" (root),


under which a file system becomes accessible after being
mounted.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 11

LINUX BASED NETWORKS

Understanding mounts
Mount points are directories where one may mount a
second disk partition to a first to make the second appear
as part of the first.
That is, the tree receives a "graft," another branch, at that
point, and the tree thus becomes that much larger.
In fact, this is the only way to add to the existing file
system's Volume, by adding another partition to it.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 12

LINUX BASED NETWORKS

Understanding mounts

This additional partition could just as easily be an NFS


(network file system) mount from another host across the
network, but would obviously only be available when the
network and the remote host were.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 13

LINUX BASED NETWORKSr

Things to remember about mounts


Mount points must necessarily be directory names.
But the directories don't need to be empty.
No directory is truly empty, it contains at a minimum the
"." and "..
If a partition is mounted over an existing directory, the
contents of the existing directory become unavailable.
They can't be seen or used, and the disk space used by
those files is lost. The files in the disk partition mounted
over it replace the original.
Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 14

LINUX BASED NETWORKS

The mount command


Before a file system is accessible to the system, it
must be mounted on a directory.
For example, if you have a file system on a floppy, you
must mount it under a directory, eg flp, in order to
access the files on the floppy.
After mounting the file system, all of the files in the file
system appear in that directory.
After unmounting the file system, the directory (in this
case, /flp) will be empty.

mount -t type device dir


Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 15

LINUX BASED NETWORKS

Hard Drive Overview


As with other operating systems, the Linux kernel plus the
files associated with it are stored on a hard drive, which is
a physical unit.
Within each hard drive are partitions, which function
some what as virtual hard drive.
Inside each partition, you build a file system.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 16

LINUX BASED NETWORKS

Linux File System

Linux uses the second extended (ext2 & etx3) file system

University of Lahore

zahidshafiq@linuxmail.org

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

17
Slide : 17

LINUX BASED NETWORKS

File system Hierarchy Standard


(FHS)

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 18

LINUX BASED NETWORKS

File system Structure


Red Hat is committed to the Filesystem Hierarchy
Standard (FHS), a document that defines the names and
locations of many files and directories.
The complete standard can be viewed at:
http://www.pathname.com/fhs/

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 19

LINUX BASED NETWORKS

The Directory Tree Structure

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 20

LINUX BASED NETWORKS

Overview of the FHS


The /boot Directory
This is where the Kernel is stored and LILO/GRUB gets its
information from, and where module information is stored.
Your best bet is to ignore this directory completely as
for a normal user, it is dangerous to play with

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 21

LINUX BASED NETWORKS

The Root Directory ( / )


The root directory (/) of a Linux system is the directory that
contains all other directories and files.
Other directories may be separately mounted and thus may
or may not be present at system startup.
Therefore, the file system that contains the root directory
must contain all files necessary to operate the system in
single-user mode.
The root directory also contains all files needed to shut
down and recover or repair the system.
Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 22

LINUX BASED NETWORKS

The Root Directory (cont.)


The following directories are essential and must be part of
the root file system:
/bin, which contains binary files used by the system
administrator and other users
/dev, which contains device files
/etc, which contains host-specific configuration data
/lib, which contains system libraries
/sbin, which contains binary files used by the system
administrator

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 23

LINUX BASED NETWORKS

The Root Directory (cont.)

However, Linux systems typically include several other


directories, which may be used as mounting points for nonroot file systems

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 24

LINUX BASED NETWORKS

The /dev Directory


The /dev directory contains file system entries which
represent devices that are attached to the system. These
files are essential for the system to function properly.
Device File

Device

Console
cua*
fd*
hd*
lp*
md*
null
ramdisk
sd*
sr*
st*
tpqic*,ntpqic*
rft*,nrft*
tty
ttys*
vc*
zero

System console
Deprecatedoriginally referred to a serial port
Floppy drive
IDE hard disk or CD-ROM
Parallel port
RAID array
Null output device
RAM disk
SCSI hard disk
SCSI CD-ROM
SCSI tape
QIC tape
Terminal or pseudoterminal
Serial port
Contents of a tty device, such as a virtual console
Alt binary Os input device tty Serial port Contents of a tty

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 25

LINUX BASED NETWORKS

The /etc Directory

The /etc directory is reserved for configuration files that


are local to your machine.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 26

LINUX BASED NETWORKSr

Important Files in /etc


F ile
C o n te n ts
a d jtim e
T im e s y n c h ro n iz a tio n d a ta
fd p rm
F lo p p y d is k p a ra m e te rs
fs ta b
F ile s y s te m ta b le
g e tty d e fs
L o g in te rm in a l c h a ra c te ris tic s
g ro u p
U se r g ro u p s
in itta b
S y s te m s ta rtu p c o n fig u ra tio n
1 d .s o .c o n f
S y s te m lib ra ry c a c h e
lilo .c o n f
L in u x lo a d e r c o n fig u ra tio n
m o td
M e s s a g e o f th e d a y
m ta b
M o u n te d file s y s te m ta b le
n s s w itc h .c o n f L is t o f s q u re e s fo r in fo rm a tio n o n u s e rs , h o s ts ,n e tw o rk s ,a n d s e rv ic e s .
m to o ls .c o n f
C o n fig u ra tio n o f m to o ls u tilitie s
passw d
U s e r a c c o u n ts
p ro file
S h e ll in itia liz a tio n s c rip t
s e c u re tty
L is t o f s e c u re lo g in te rm in a ls
shadow
U s e r a c c o u n t_ e n c ry p te d p a s s w o rd s , if s h a d o w p a s s w o rd s e n a b le d
s h e lls
L is t o f a p p r o v e d s h e lls
s y s lo g . c o n f
S y s t e m lo g c o n f ig u r a t io n
e x p o rts
L is t o f N S P e x p o r ts
ftp *
F T P c o n f ig u r a t io n f ile s
h o s t.c o n f
H o s t n a m e r e s o lu tio n c o n f ig u r a tio n ( s e e a ls o r e s o lv .c o n f )
h o s ts
L is t o f k n o w n h o s t s
h o s t s . a llo w
L is t o f h o s ts a llo w e d a c c e s s to s e r v ic e s
h o s ts .d e n y
L is t o f h o s ts d e n ie d a c c e s s to s e r v ic e s
h o s t s .e q u iv
L is t o f tr u s te d h o s ts
in e td .c o n f
C o n f ig u r a t io n o f In te r n e t s u p e r - s e r v e r , in e td
n e tw o rk s
L is t o f k n o w n n e tw o r k s
p r in tc a p
P r in t e r c o n f ig u r a tio n
p r o to c o ls
L is t o f k n o w n p r o to c o ls
r e s o lv .c o n f
H o s t n a m e r e s o lu t io n c o n f ig u r a t io n ( s e e a ls o h o s t . c o n f )
rp c
L is t o f R P C s e r v ic e s
s e r v ic e s
L is t o f T C P / IP s e r v ic e s
Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 27

LINUX BASED NETWORKS

Important Subdirectories of /etc


Subdirectory
Contents
cron*
Configuration of corn service
httpd
Configuration of http (Web) service
pam.d
Configuration of PAM, Red Hat's security library
pcmcia
Configuration of PCMCIA slots and devices
ppp
Configuration of PPP services
rc.d
System initialization files
security
Security configuration
skel
User environment template files
sysconfig System configuration
Xll
X Window System configuration, including XF86 Config file

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 28

LINUX BASED NETWORKS

The /lib Directory

This is where the basic libraries for booting Linux and running
standard programs reside.
Do not delete anything in this directory, ever

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 29

LINUX BASED NETWORKS

The /proc Directory


The /proc directory contains special files that either extract
information or send information to the kernel..
I would advise against deleting anything in that
directory.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 30

LINUX BASED NETWORKSr

The /bin Directory


This is where basic shell commands such as ls and mv
reside. This directory is always in the executable path.
The /bin directory contains binary files that are essential
to system operation in single-user mode.
These files are generally commands, which may be used
by the system administrator and by users.
Similar files not required for single user mode are placed
in /usr/bin.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 31

LINUX BASED NETWORKS

Files in /bin
arch
ash
ash.static
awk
basename
bash
bash2
bsh
cat
chgrp
chmod
chown
consolechars
cp

df
dmesg
dnsdomainname
doexec
domainname
echo
ed
egrep
ex
false
fgrep
fsconf
gawk
gawk-3.0.3

igawk
ipcalc
kill
ksh
linuxconf
In
loadkeys
login
ls
mail
mkdir
mknod
mktemp
more

netstat
nice
nisdomainname
ping
PS
pwd
red
remadmin
rm
rmdir
rpm
rvi
rview
sed

sort
stty
su
sync
tar
tcsh
touch
true
umount
uname
userconf
usleep
vi
evie

And many more..


Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 32

LINUX BASED NETWORKS

The /sbin Directory


The /sbin directory is for executables used only by the root
user. The executables in /sbin are only used to boot and
mount /usr and perform system recovery operations.

arp, clock, getty, halt, init, fdisk, fsck.*, ifconfig, lilo,


mkfs.*, mkswap, reboot, route, shutdown, swapoff,
swapon, update

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 33

LINUX BASED NETWORKS

The /usr Directory

This is an interesting one. When you install programs like the


GIMP, and Window maker, they need to be accessed by all
users, so this is the directory they get installed into.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 34

LINUX BASED NETWORKS

The /var Directory

This is where your log files, and printer files are kept.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 35

LINUX BASED NETWORKSr

The /home Directory

This is where your users have their accounts. If you have


added any users other than your standard root account, they
will show up here. It can also house the directories than
your Web Server (Apache) accesses, if you have it
installed.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 36

LINUX BASED NETWORKS

The /mnt Directory

This is the location where you mount your cdrom, zip drives,
or dos drives.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 37

LINUX BASED NETWORKS

The /opt Directory

If you have this directory, its probably where Netscape has


installed if you have chosen Netscape to be loaded. Red
Hat's Applix office suite also installs here.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 38

LINUX BASED NETWORKS

The /root Directory

This is main account directory. The root user have this


space to keep all your downloads, and anything else you
want to keep in there basically

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 39

LINUX BASED NETWORKSr

The /tmp Directory


A useless directory, its short for Temporary. When you install
Linux first, it creates a file in your /tmp directory with all the
details.
The /tmp directory contains temporary files and
subdirectories that are automatically deleted by the
tmpwatch utility when they've not been used for a specified
period of time (by default, 10 days).

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 40

LINUX BASED NETWORKSr

/lost+found: Recovered Files

When you recover a file system, files and file data may be
partially recovered. For example, the recovery utility may
recover a file's data but not the file's name. Such files are
placed by the utility in the/lost+found subdirectory of the
root directory of the file system.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 41

LINUX BASED NETWORKSr

The Root and Standard Directories


The root filesystem includes the root directory and a
minimal set of files and subdirectories:

/boot for the kernel and boot up files;


/dev for device files;
/etc for configuration files (most important for SA);
/sbin (or /bin) for important utilities and binary files (usually link
to /usr/bin);

Recommended in separated partitions:

/usr for standard programs that are shareable across a whole site;
/home for home directories of users;
/var for spool directories, log files, accounting, etc.;
/tmp for temporary files;
/proc stores images of all running process

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 42

LINUX BASED NETWORKS

Basic File system Concepts

The basis of the Linux Filesystem is firmly rooted in the


proven concepts of the UNIX OS.
Files are represented as inodes, and directories are files
containing a list of entries and devices accessible by requesting
I/O on special files.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 43

LINUX BASED NETWORKSr

Data Storage Layout in ext2


Data within the ext2 file system is stored in a series of
identically sized data blocks.
These blocks are generally 1,024 bytes, though you can
set them to be a different size while making a file
system.
All this information is contained within a file system object
called an inode,

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 44

LINUX BASED NETWORKS

The UNIX File System Design


The i-nodes

These are organized in a table format and


created when the file system is created.
The inode contains more than 40 fields, such as
number of hard links, owner, group, mode, size,
time stamps, type (regular, directory, special file,
etc), pointers to location of data blocks, etc.
Use chown, chgrp, touch commands to change
some of those information.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 45

LINUX BASED NETWORKS

The UNIX File System Design


The Super-block
Its contains information on the size of the file
system, the number of inodes, the number of
data blocks, the free and used inodes, and the
block size for the file system.
The superblock is kept in memory and in multiple
locations on disk for each file system.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 46

LINUX BASED NETWORKS

Directories
Directories are structured in a hierarchical tree. Each directory
can contain files and subdirectories. Directories are
implemented as a special type of files.
Actually, a directory is a file containing a list of entries. Each
entry contains an inode number and a file name.

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 47

LINUX BASED NETWORKSr

Steps in looking up a file


Looking
Lookingup
up/home/pat/ch1.txt
/home/pat/ch1.txt
root directory
1
1
4
7
14
9
6
8

.
..
bin
dev
lib
etc
home
tmp

6
Size
time

132

home directory
in block 132
6
.
1
..
19
user1
30
john
51
pat
26
peter

pat directory
in block 406
51
Size
time

406

.
..
notes
cgi
ch1.txt
doc

81
Size
time

512
646
379
427

data block (1kb)

i-node
number
(2 bytes)
University of Lahore

51
6
64
92
81
17

i-node
zahidshafiq@linuxmail.org

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

48
Slide : 48

LINUX BASED NETWORKS

Exercise:

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 49

LINUX BASED NETWORKS

Homework
Homework this week:
Next week:

Filesystem Hierarchy Standards & filesystem Structure

Class Meeting 3

Slide : 50

Vous aimerez peut-être aussi