Linux directory structure by jitu mistry
-
Upload
jitu-mistry -
Category
Education
-
view
1.127 -
download
1
description
Transcript of Linux directory structure by jitu mistry
LINUX DIRECTORY STRUCTURE
Presented By :-
JITU MISTRY
INTRODUCTION
7/19/2013
2
What is Directory?
It’s bunch of system files and also data files.
What is Directory in LINUX?
It’s same meaning in LINUX but in the LINUX there is
only one root.
How the LINUX Directory differ from that of familiar
Windows?
In windows every drive has it’s own root , opposite to it
, in linux only single drive and single root.
Example
7/19/2013
3
Root
7/19/2013
4
Root is ambiguous in one respect.
1. It can refer to the top of the file structure.
2. It can also be the name of the Administrator type
account in Linux.
7/19/2013
5
Difference between ‘/’ and ‘/Root’
7/19/2013
6
1. /
‘/’ is called as a root.
It’s Root directory.
Root of the all file systems of linux.
Every directory is “under” root ultimately.
2. /root
7/19/2013
7
Root is the user with God-like powers over the system. !!!
It’s administrative(root) user’s home directory.
/boot
7/19/2013
8
Contains the boot loader , Grub and linux kernel
Contains everything required for the boot process except
for configuration files not needed at boot time.
Stores data that is used before the kernel begins
executing user-mode programs.
/boot is static and unsharable directory.
If /boot is lost , then we can’t boot os .
Some command for /Boot
7/19/2013
9
/Root
7/19/2013
10
Home directory of root user.
Root is the name of system Admin.
/Root = system admin or Super User directory.
Why not in '/home'?
Because '/home' is often located on a different
partition or even on another system and would thus
be inaccessible to 'root' when - for some reason -
only '/' is mounted.
/bin
7/19/2013
11
Stands for binary
Need for system startup
Used by everyone in terminal
Shells like bash, csh
No subdirectories in /bin
Basic commands for
Navigating in filesystem
File management
7/19/2013
12
bin
bash bzip2 cat gzip ls mv rm...
/sbin
7/19/2013
13
binary files usually for system administration.
Only root can access.
System configuration programs
Format hard disk
Manage hardware
7/19/2013
14
sbin
fsck mkfs mount adduser poweroff...
/bin vs /sbin
7/19/2013
15
/bin directory contains executable programs which
are needed in single user mode and to bring the
system up or repair it.
/sbin Like /bin, holds commands needed to boot the
sys-tem, but which are usually not executed by normal
users.
/opt
7/19/2013
16
“optional” software
/opt/bin, /opt/doc, /opt/include, /opt/info,
/opt/lib, and /opt/man
installed under either /opt/ or /opt/ sub-
directory.
/srv
7/19/2013
17
srv stands for service.
site-specific data
Contains server specific services related data.
For example, /srv/cvs contains CVS related
data.
/tmp
7/19/2013
18
Contains file that are required temporarily
Directory is cleared out at boot or at shutdown.
/lib
7/19/2013
19
All essential libraries which are needed for
system startup
Windows equivalent to a shared library would
be a DLL (dynamically linked library) file
Also in this directory are kernel modules
/lib (conti..)
7/19/2013
20
Other library locations for other programs include
/usr/lib and /usr/local/lib
Generally these correspond to where the binary is
installed, i.e. a binary in /usr/bin would put a library
in /usr/lib, and a binary in /usr/local/bin would put
a library in usr/local/lib
/dev
7/19/2013
21
• Stands for devices.
• Linux filesystem : everything is a file or a directory.
• So device is treated as file. Usually It is the location
of device files
• C:\Windows\System in Windows Contains a file describing every device,and these files can send data to each device.
• It is equivalent to a mashup of the Device Manager.
• A device and a file both can be read from and written to. So config a device is same with edit a file.
/dev
7/19/2013
22
EX: sending data to /dev/ttyS0 that means you are
sending data to a communication device, such as a
modem.
/dev/dsp : speaker device
/dev/dsp is speaker configuration file means it is for
sound card.
cat /etc/lilo.conf > /dev/dsp
The sound you will hear is the sound of
your /etc/lilo.conf file
/dev
7/19/2013
23
●/dev/ttyS0
●/dev/psaux
●/dev/lp0
●/dev/dsp
●/dev/usb
●/dev/sda
●/dev/scd
●/dev/cdrom
●/dev/fd0
●/dev/had
→Device connected to Com1 (Modem, mouse,..)
→PS/2 mouse connection
→First parallel port
→Sound card (digital signal processor)
→USB device nodes.
→First SCSI device
→First SCSI CD-ROM device
→CD-ROM drive
→floppy drive
→The partition on primary hdd
/etc
7/19/2013
24
• Contains all system related configuration files.
• Those files must be static and cannot be an executable binary.
• These files are generally text files andcan be edited using any
text editor:emacs or vi on the command line, or whatever
graphical equivalent (e.g. gedit, kate) your desktop offers.
• /etc/rc.d directory contains the system startup scripts.
/etc
7/19/2013
25
• Fstab : Static information about filesystems.
• Group : User group file.
• Passwd : This is the password file, but it contains more: user
name, user password, userID, group ID, home directory, and
shell. It can optionally contain the user's “real name”.
• /etc/sgml : Configuration files for SGML
• /etc/xml : Configuration files for XML
• /etc/hostname : Contains the hostname of your machine
• /etc/hosts : This file is used to define a system name and
domain combination with a specific IP address
/etc
7/19/2013
26
• /etc/inittab:
• /etc/fstab: system what drive to access, and where
to mount it in your System.
• /etc/x11: Configuration directory for x11, which is
the display system for graphical interfaces in Linux.
• /etc/x11/xorg.conf : specify the resolutions your
monitor and graphics card can display, for instance.
/home
7/19/2013
27
• Linux is a multi-user environment so each user is also
assigned a specific directory which is accessible only
to them and the system administrator.
• containing saved files, personal settings, etc. Contains
the user’s personal configuration files and their name
start with “.” (hidden file).
• Quite large to be used as User’s Documents Space
/mnt
7/19/2013
28
Mounting is the process by which you make a
filesystem available to the system.
On older Linux systems, the /mnt directory contains
mount.
points for removable devices that have been mounted
manually.
Mount point for temporary mounted file system.
/media
7/19/2013
29
On modern Linux systems the /media directory will
contain the mount points for removable media such as,
-USB drives,
-CD-ROMs, etc.
that are mounted automatically at insertion.
/proc
7/19/2013
30
Pseudo file system residing in the virtual memory.It is
virtual file system maintained by the Linux kernel. The
“files” it contains are peepholes into the kernel itself.
The files are readable and will give you a picture of
how the kernel sees your computer.
Maintains highly dynamic data on the state of your
operating system.
A new /proc file system is created every time your
Linux machine reboots.
/usr
7/19/2013
31
/usr is the second major section of the
filesystem.
/usr is shareable, read-only data.
Any information that is host-specific or varies
with time is stored elsewhere.
Large software packages must not use a direct
subdirectory under the /usr hierarchy.
Requirements of /usr
7/19/2013
32
bin -----Most user commands
include -----Header files included by C
programs
lib -----Libraries
local -----Local hierarchy (empty
after main installation)
sbin -----Non-vital system binaries
share -----Architecture-independent
data
/usr/bin
7/19/2013
33
Contains executable files for many Linux
commands
These are commands that are not part of the
core Linux operating system
Examples of commands in here:
- Perl
- Python
/usr/include
7/19/2013
34
General use include files, including header files,
for
C and C++ programming languages.
/usr/lib
7/19/2013
35
Contains libraries for the C and C++
programming languages
Object files, libraries, and internal files not
intended to be executed directly by users or
shell scripts
/usr/local
7/19/2013
36
The /usr/local hierarchy is for use by the system
administrator when installing software locally.
It may be used for programs and data that are
shareable amongst a group of hosts, but not
found in /usr.
Locally installed software must be placed within
/usr/local rather than /usr unless it is being
installed to replace or upgrade software in /usr.
Requirements of /usr/local
7/19/2013
37
s bin -----Local binaries
etc -----Host-specific system configuration for local binaries
games -----Local game binaries
include -----Local C header files
lib -----Local libraries
man -----Local online manuals
sbin -----Local system binaries
share -----Local architecture-independent hierarchy
src -----Local source code
/usr/sbin
7/19/2013
38
This directory contains any non-essential
binaries used exclusively by the system
administrator.
System administration programs that are
required for system repair, system recovery,
mounting /usr, or other essential functions must
be placed in /sbin instead.
/usr/share
7/19/2013
39
/usr/share is for read-only architecture independent data
files
Intended to be shared across platforms (e.g. i386,
Alpha, PPC)
Any program or package which contains or requires data
that doesn’t need to be modified should store
If the contents are variable, go to /var e.g. a game file in
/usr/share/games must be static. Game play
logs go in /var/games
Requirements of /usr/share
7/19/2013
40
man -----Online manuals
misc -----Miscellaneous architecture-
independent data
/usr/src
7/19/2013
41
Source code is placed here, for reference
purposes only.
This includes the source code for the Linux
kernel.
/var
7/19/2013
42
• This is files that are expected to be updated and
changed.
• This includes:
Administrative and Logging data
Temporary files
Websites
Mail directories
Print spool
/var Sharing
7/19/2013
43
Not Shareable:
/var/log, /var/lock, and /var/run.
Shareable:
/var/mail, /var/cache/man, /var/cache/fonts, and
/var/spool/news.
7/19/2013
44
Because there might be circumstances when you may
want to mount /usr as read-only,
e.g. if it is on a CD or on another computer.
However, /var must not be linked to /usr because this
makes separation of /usr and /var more difficult and
is likely to create a naming conflict. Instead, link /var
to /usr/var
Why not put it into /usr ?
var
cache lib lock log www named
message boot.log
Backups
Subdirectory of /var
7/19/2013
46
Directory Description
cache Application cache data
lib Variable state information
local Variable data for /usr/local
lock Lock files
log Log files and directories
opt Variable data for /opt
run Data relevant to running processes
spool Application spool data
tmp Temporary files preserved between
system reboots
Carsh for the dumped data
7/19/2013
47
‘Reserved’ Directory
They must not be used arbitrarily by some new
application,
since they would conflict with historical and/or local
practice. They are
/var/backups
/var/msgs
/var/preserve
Permissions in FS
7/19/2013
48
There are 3 basic permissions
Read (r)
Write (w)
Execute (x)
There are 3 basic level of users
Owner
Groups
Others
How to find the permissions:
ls -l
Mehod for Permission
7/19/2013
49
(1) Octal method
Eg: chmod 444 hello.txt
(2) Alphabets
chmod [a/u/g/o +/- r/w/x]
<filename>
Eg: chmod ugo+r-wx hello.txt
(3) Reference
Eg: chmod –reference=hello.txt testfile.txt
Adv. Softlink in Linux FS
7/19/2013
50
If Root FS become 100% full, we have to create one
soft link that would point to another point mount
created with on same disk ultimately that New
Fs(/test) will store data instead of root
Symbolic links, or "symlinks" work a little like
Windows shortcuts
Symbolic links work on the files and directory
Adv. Hard link in Linux FS
7/19/2013
51
There are basically two main limitations with hard
links:
- Hard links normally require that the link and the file
reside in the same file system.
- Only the super user can create a hard link to a
directory.
Thus, symbolic links were introduced to get around the
limitations of hard links.
So, the question is, are hard links still needed?
Are Hard links still needed?
7/19/2013
52
Symlinks aren't followed by some HTTP servers
Hard-Links can be used for backups
You can delete any version of a hard link without
affecting the others.
Hard links allow us to take one file and have it be
multiple places in the file system at once, which save
lots of memory.
Thank you
7/19/2013
53
?