The Filesystem

Commands Config Files What is a filesystem?

Pathnames

A sequence of file names, separated by slashes (/), that describes the path, or route, the shell must follow to locate a file in the file system.

Two Types of Pathnames:

Fill in the type of path in this table:
 
/var/spool Absolute
mail Relative
/var/spool/mail
../lpd Relative
../../log
/etc
sysconfig/network-scripts
../network

Terminology: file, filename, pathname, and path

/project/engineering/cad/antenna/sims/aug02/...
|______________________________________________|
             255 characters total

Way around this limitation

Filename restrictions

PATH variable

Find out what your current path is

Mounting and Unmounting Filesystems


The mount command Syntax
mount [options] device directory
mount [options] server:directory directory
Note: If there is an entry in the /etc/fstab file for the filesystem to be mounted, it is not necessary to provide both the device and mount point.
mount /mnt/cdrom
Mini Lab: Mount a filesystem from the instructors machine
1. root on the instructor machine must have /mnt/cdrom exported
2. client must have the directory /mnt/pub created
# mkdir /mnt/pub
3. now mount the instructors cdrom filesystem

   # mount 10.2.128.30:/var/ftp/pub  /mnt/pub

   # cd /mnt/pub

         4. From another shell window try to umount /mnt/instructor
   # umount /mnt/pub
   umount: /mnt/pub: device is busy

5. Why are you seeing this error message?

6. Use the fuser or lsof command to see which processes are access the filesystem you are trying to umount.

   # fuser -mv /mnt/pub  

7. Use the ps command to get information about the offending processes.

   # ps -fp "pid1 pid2 pid3"

We will spend an entire class period on NFS coming soon...

Filesystem Organization

/bin Commands needed for minimal system operability
/boot Kernel and files needed to load the kernel
/dev Device entries for terminals, disks, floppies, modems...
/etc Startup scripts and configuration files
/lib Libraries, kernel modules, parts of the the C compiler
/proc Images of all running processes
/root Home directory of the root user (superuser)
/sbin Commands for booting, repairing, or recovering the system
/tmp Temporary files
/usr applications installed under the hierachy of directories beneath
/usr/bin commands and executable files
/usr/include Header files for C programs
/usr/lib Libraries
/usr/local Local software that you have installed yourself
/usr/sbin additinal system administration files
/usr/share man pages, documentation
/usr/src Source code, kernel source, RedHat SRPM build directories
/var system data, log files, user mail, printer spool area 

Types of Files

Regular Files Directories Character and block device files       Characteristics of device nodes Much more coming on Character and Block device files soon...

Local domain sockets

Named pipes (FIFO) Symbolic Links
$ ln source_file target_file
Hard Link
The ln comand, without any options is called a hard link.
Soft Link
Another type of link is a symbolic link created using the -s option (soft link).
Hard link Directory inode entry
 
inode    Name
1505 myfile
1505 myfile-lnk

Soft link Directory inode entry
 
 
inode    Name
1505 myfile
1766 myfile-lnk


Hard and symbolic links.
Link Figure  from: O'Reilly, Essential System Administration, Second Edition, page 41

First picture, top left

Second picture, on right Last picture, on bottom How symbolic links used on your system Make a shortcut to /etc/rc.d/init.d by creating a symbolic link:
# ln -s /etc/rc.d/init.d /etc/init.d
Take a look at /etc and find your link
# cd /etc
# ls -l | grep init

File Attributes

setuid and setgid bits setuid
  ---s--x--x   1 root root 80764 Jul 23 /usr/bin/sudo
setgid The Infamous Sticky Bit
Files

Changing Ownership and Group

chown
# chown someuser /home/someuser
chgrp Change both at the same time Recursive Changes

Additional Attributes

$ cp /etc/passwd .
$ sudo chattr +ia passwd
$ ls -l passwd
-rw-r--r--    1 pattyo   sysadmin 1947 Mar  4 14:15 passwd
$ lsattr passwd
---ia--------- passwd


$ rm passwd
rm: remove write-protected regular file `passwd'? y
rm: cannot remove `passwd': Operation not permitted

$ sudo chattr -ia passwd
$ rm passwd
rm: remove regular file `passwd'? y