UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev...

22
UNIX File Hierarchy

Transcript of UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev...

Page 1: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

UNIX File

Hierarchy

Page 2: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

The UNIX/Linux File System Hierarchy

CIS 191 – Lesson 3

/

/bin

/boot

/dev

/etc

/home

/lib

/lost+found

/mnt

/opt

/proc

/root

/sbin

/tmp

/usr

Page 3: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 – Lesson 1Directory Contents/ the root directory, the top-level directory in the FHS

/bin binary files forming the commands and shells used by the system administrator and users

/boot files used during the initial boot-up process including the kernel

/dev device files for connected hardware

/etc system configuration files

/home individual home directories owned by each user

/lib shared libraries needed to boot the system and run the commands in the root filesystem (i.e. commands in /bin and /sbin)

/lost+found recovered files that were corrupted by power failures or system crashes

/mnt mount points for floppies, cds, or other file systems

/opt add-on software packages and/or commercial applications

/proc kernel level process information

/root home directory for the root user

/sbin system administration commands reserved for the superuser (root)

/tmp temporary files that are deleted when the system is rebooted or started

/usr program files and related files for use by all users

/var variable data such as log files, print spool files, and mail queues

Basic File Hierarchy Standard Directories

Page 4: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

/

/etcfstabgrouphostshosts.allowhosts.denyhttpd/ conf/ httpd.conf inittabissuemodules.confmotdmtabpam.d/ loginpasswdprofilerc.d/ rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rc.sysinit

/sbinarpbastillechkconfigdebugfsdhclientdmesgdumpe2labelfdiskgrubhaltifconfiginitinsmodiptableslsmodlspcimingettymkfspartprobeportmapquotaonquotaoffrestorermmodrouteserviceshutdowntripwiretune2fs

/binbashcatchgrpchmodchowncpcpiodatedddfdmesgechoenvgrephostnamelnlsmailmkdirmoremountmvnetstatpingpsrmrmdirrpmsleepsortsutartouchumountunamevi

Example GNU/Linux Directory Structure

/bootgrub/ grub.confinitrd-2.4.20-6.imgvmlinuz-2.4.20-6

/usrbin/ at bc cal cancel clear crontab fdformat file find finger gcc head id info less lp/lpr lpstat make man mesg mozilla openssl passwd perl quota scp spell ssh sudo tail tee telnet wc who write xxd

/root.bash_profile.bashrc

sbin/ crond cupsd httpd kudzu pppd sendmail sshd traceroute useradd usermod userdel xinetd X11R6/ bin/ startx twm X xclock xinit xsetroot xwd

/varlog/ Bastille/ Assessment/ assessment-report.html dmesg httpd/ access_log error_log spool/ clientmqueue

/procinteruptsioportsmodulessys/ net/ ipv4/ ip_forward

resolv.confsecurettyshadowsysctl.confsysconfig/ network network-scripts/ ifcfg-eth0xinetd.d/ telnet

/lib modules/ 2.4.20-6/ kernel/ drivers/ net/ 3c59x.o

/homersimms/.bash_profile.bashrc

/mntcdrom/floppy/

/optlampp/ bin mysql htdocs phpmyadmin/ index.php sbin/ mysqld

/tmpssh-XXjXuIH9/ agent.13695

/devhdahda1had2tty1

Note: shell builtins = cd, echo, exit, export, history, jobs, kill, pwd, set, type, umask, unset shell keywords = if, then, else, case, for, while

[root@tomcat ~]# ls /bin dev home lost+found misc net proc sbin srv tmp varboot etc lib media mnt opt root selinux sys usr[root@tomcat ~]#

Page 5: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

/

/etcfstabgrouphostshosts.allowhosts.denyhttpd/ conf/ httpd.conf inittabissuemodules.confmotdmtabpam.d/ loginpasswdprofilerc.d/ rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rc.sysinit

/sbinarpbastillechkconfigdebugfsdhclientdmesgdumpe2labelfdiskgrubhaltifconfiginitinsmodiptableslsmodlspcimingettymkfspartprobeportmapquotaonquotaoffrestorermmodrouteserviceshutdowntripwiretune2fs

/binbashcatchgrpchmodchowncpcpiodatedddfdmesgechoenvgrephostnamelnlsmailmkdirmoremountmvnetstatpingpsrmrmdirrpmsleepsortsutartouchumountunamevi

Example GNU/Linux Directory Structure

/bootgrub/ grub.confinitrd-2.4.20-6.imgvmlinuz-2.4.20-6

/usrbin/ at bc cal cancel clear crontab fdformat file find finger gcc head id info less lp/lpr lpstat make man mesg mozilla openssl passwd perl quota scp spell ssh sudo tail tee telnet wc who write xxd

/root.bash_profile.bashrc

Note: shell builtins = cd, echo, exit, export, history, jobs, kill, pwd, set, type, umask, unset shell keywords = if, then, else, case, for, while

sbin/ crond cupsd httpd kudzu pppd sendmail sshd traceroute useradd usermod userdel xinetd X11R6/ bin/ startx twm X xclock xinit xsetroot xwd

/varlog/ Bastille/ Assessment/ assessment-report.html dmesg httpd/ access_log error_log spool/ clientmqueue

/procinteruptsioportsmodulessys/ net/ ipv4/ ip_forward

resolv.confsecurettyshadowsysctl.confsysconfig/ network network-scripts/ ifcfg-eth0xinetd.d/ telnet

/lib modules/ 2.4.20-6/ kernel/ drivers/ net/ 3c59x.o

/homersimms/.bash_profile.bashrc

/mntcdrom/floppy/

/optlampp/ bin mysql htdocs phpmyadmin/ index.php sbin/ mysqld

/tmpssh-XXjXuIH9/ agent.13695

/devhdahda1had2tty1

CIS 90 files, directories, commands

Page 6: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

/

/etcfstabgrouphostshosts.allowhosts.denyhttpd/ conf/ httpd.conf inittabissuemodules.confmotdmtabpam.d/ loginpasswdprofilerc.d/ rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rc.sysinit

/sbinarpbastillechkconfigdebugfsdhclientdmesgdumpe2labelfdiskgrubhaltifconfiginitinsmodiptableslsmodlspcimingettymkfspartprobeportmapquotaonquotaoffrestorermmodrouteserviceshutdowntripwiretune2fs

/binbashcatchgrpchmodchowncpcpiodatedddfdmesgechoenvgrephostnamelnlsmailmkdirmoremountmvnetstatpingpsrmrmdirrpmsleepsortsutartouchumountunamevi

Example GNU/Linux Directory Structure

/bootgrub/ grub.confinitrd-2.4.20-6.imgvmlinuz-2.4.20-6

/usrbin/ at bc cal cancel clear crontab fdformat file find finger gcc head id info less lp/lpr lpstat make man mesg mozilla openssl passwd perl quota scp spell ssh sudo tail tee telnet wc who write xxd

/root.bash_profile.bashrc

Note: shell builtins = cd, echo, exit, export, history, jobs, kill, pwd, set, type, umask, unset shell keywords = if, then, else, case, for, while

sbin/ crond cupsd httpd kudzu pppd sendmail sshd traceroute useradd usermod userdel xinetd X11R6/ bin/ startx twm X xclock xinit xsetroot xwd

/varlog/ Bastille/ Assessment/ assessment-report.html dmesg httpd/ access_log error_log spool/ clientmqueue

/procinteruptsioportsmodulessys/ net/ ipv4/ ip_forward

resolv.confsecurettyshadowsysctl.confsysconfig/ network network-scripts/ ifcfg-eth0xinetd.d/ telnet

/lib modules/ 2.4.20-6/ kernel/ drivers/ net/ 3c59x.o

/homersimms/.bash_profile.bashrc

/mntcdrom/floppy/

/optlampp/ bin mysql htdocs phpmyadmin/ index.php sbin/ mysqld

/tmpssh-XXjXuIH9/ agent.13695

/devhdahda1had2tty1

CIS 191 files, directories, commands

Page 7: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

/

/etcfstabgrouphostshosts.allowhosts.denyhttpd/ conf/ httpd.conf inittabissuemodules.confmotdmtabpam.d/ loginpasswdprofilerc.d/ rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rc.sysinit

/sbinarpbastillechkconfigdebugfsdhclientdmesgdumpe2labelfdiskgrubhaltifconfiginitinsmodiptableslsmodlspcimingettymkfspartprobeportmapquotaonquotaoffrestorermmodrouteserviceshutdowntripwiretune2fs

/binbashcatchgrpchmodchowncpcpiodatedddfdmesgechoenvgrephostnamelnlsmailmkdirmoremountmvnetstatpingpsrmrmdirrpmsleepsortsutartouchumountunamevi

Example GNU/Linux Directory Structure

/bootgrub/ grub.confinitrd-2.4.20-6.imgvmlinuz-2.4.20-6

/usrbin/ at bc cal cancel clear crontab fdformat file find finger gcc head id info less lp/lpr lpstat make man mesg mozilla openssl passwd perl quota scp spell ssh sudo tail tee telnet wc who write xxd

/root.bash_profile.bashrc

Note: shell builtins = cd, echo, exit, export, history, jobs, kill, pwd, set, type, umask, unset shell keywords = if, then, else, case, for, while

sbin/ crond cupsd httpd kudzu pppd sendmail sshd traceroute useradd usermod userdel xinetd X11R6/ bin/ startx twm X xclock xinit xsetroot xwd

/varlog/ Bastille/ Assessment/ assessment-report.html dmesg httpd/ access_log error_log spool/ clientmqueue

/procinteruptsioportsmodulessys/ net/ ipv4/ ip_forward

resolv.confsecurettyshadowsysctl.confsysconfig/ network network-scripts/ ifcfg-eth0xinetd.d/ telnet

/lib modules/ 2.4.20-6/ kernel/ drivers/ net/ 3c59x.o

/homersimms/.bash_profile.bashrc

/mntcdrom/floppy/

/optlampp/ bin mysql htdocs phpmyadmin/ index.php sbin/ mysqld

/tmpssh-XXjXuIH9/ agent.13695

/devhdahda1had2tty1

CIS 192 files, directories, commands

Page 8: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

/

/etcfstabgrouphostshosts.allowhosts.denyhttpd/ conf/ httpd.conf inittabissuemodules.confmotdmtabpam.d/ loginpasswdprofilerc.d/ rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rc.sysinit

/sbinarpbastillechkconfigdebugfsdhclientdmesgdumpe2labelfdiskgrubhaltifconfiginitinsmodiptableslsmodlspcimingettymkfspartprobeportmapquotaonquotaoffrestorermmodrouteserviceshutdowntripwiretune2fs

/binbashcatchgrpchmodchowncpcpiodatedddfdmesgechoenvgrephostnamelnlsmailmkdirmoremountmvnetstatpingpsrmrmdirrpmsleepsortsutartouchumountunamevi

Example GNU/Linux Directory Structure(showing just a few of the many files)

/bootgrub/ grub.confinitrd-2.4.20-6.imgvmlinuz-2.4.20-6

/usrbin/ at bc cal cancel clear crontab fdformat file find finger gcc head id info less lp/lpr lpstat make man mesg mozilla openssl passwd perl quota scp spell ssh sudo tail tee telnet wc who write xxd

/root.bash_profile.bashrc

sbin/ crond cupsd httpd kudzu pppd sendmail sshd traceroute useradd usermod userdel xinetd X11R6/ bin/ startx twm X xclock xinit xsetroot xwd

/varlog/ Bastille/ Assessment/ assessment-report.html dmesg httpd/ access_log error_log spool/ clientmqueue

/procinteruptsioportsmodulessys/ net/ ipv4/ ip_forward

resolv.confsecurettyshadowsysctl.confsysconfig/ network network-scripts/ ifcfg-eth0xinetd.d/ telnet

/lib modules/ 2.4.20-6/ kernel/ drivers/ net/ 3c59x.o

/homersimms/.bash_profile.bashrc

/mntcdrom/floppy/

/optlampp/ bin mysql htdocs phpmyadmin/ index.php sbin/ mysqld

/tmpssh-XXjXuIH9/ agent.13695

/devhdahda1had2tty1

Note: shell builtins = cd, echo, exit, export, history, jobs, kill, pwd, set, type, umask, unset shell keywords = if, then, else, case, for, while

Page 9: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

FileTypes

Page 10: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 – Lesson 3

File Types and Commands

Note: Other files types includes sockets (s) and named pipes (p)

Long listing code (ls –l)

Type How to make one

d directory mkdir

- regular touch

l symbolic link ln -s

c special (character device files) mknod

b special (block device files, buffered) mknod

Page 11: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 – Lesson 3

Various Types of Files (found in /etc)

Directories (blue)

Regular files (black)

Regular files with execute bit set (green)

Page 12: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 – Lesson 3

Various Types of Files (found in /bin)

Symbolic links (light blue) with arrow to real file

Rest are regular files with execute bit set (green)

Regular file with setuid bit (red background)

Long listing of files with names starting with s or z

Use file command to show additional file type information

Page 13: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 – Lesson 3

Various Types of Files (found in /dev)

Special files (yellow with black background)

Character

Block

Page 14: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 – Lesson 3

/boot (Ubuntu 8.04 Desktop)

The kernel (compressed)

Kernel major revision number. Prior to version 2.6, stable releases were even and developmental versions odd

Kernel version number

Kernel minor revision number

Kernel patch number

Page 15: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 – Lesson 3

/boot (Red Hat 9)

The kernel (compressed)

The kernel

Symbolic link to kernel

Page 16: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

System Installation

• Prepare the Disk

• Select the software

• Install the Boot Loader

Page 17: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

Preparing the Disk

• Partitioning– fdisk (command line)– Disk Druid (curses and graphical)

• Formatting– mkfs (command line)

• Assigning Mount Points– /etc/fstab (text file)

Page 18: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

Partitioning Schemes

1. One primary partition: / (root)

2. Two partitions: / and swap

3. Three partitions: boot, /, and swap

4. Three partitions: /, swap, and home

5. N partitions: /, swap, home, usr, var, tmp, and boot.

Page 19: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

Types of Filesystems

• EXT – Extended File System– ext2, ext3, ext4

• Reiser – R.I.P.• JFS – from IBM• XFS – from SGI• FAT• NTFS• ISO9660

Page 20: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

/dev/sda2

/dev/sda5

/dev/sda1

Mounting File Systems/

boot bin etc dev home lib tmp usr var

Page 21: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 - Lesson 3

New Commands

and files

Page 22: UNIX File Hierarchy. The UNIX/Linux File System Hierarchy CIS 191 – Lesson 3 / /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /proc /root /sbin.

CIS 191 - Lesson 3New commands:

df - Show free disk spacedpkg - Show packages (Debian)dmesg - Show kernel boot messagesdu - Show disk usagefdisk - Partition utilityfree - show memoryhostname - Show hostnameifconfig - Show NIC configurationinit - Change runlevelslspci - Show PCI devicesman - Show manual page documentationmount - Show mount pointssu - Switch usersudo - Do command as rootuname - show OS info

New Files and Directories:/etc/password - user accounts/etc/mtab - current mount points/proc/cpuinfo - kernel cpu info

UNIX top level tree directories:/bin, /boot, /dev, /etc, /home, /lib, /proc, /root, /sbin, /tmp, /usr, /var