CT320

CT320: Network and System Administration

Fall 2018

Filesystem

See this page as a slide show

The Filesystem

Original slides from Dr. James Walden at Northern Kentucky University.

Topics

  1. Overview
  2. Pathnames
  3. Mounting
  4. Structure
  5. Organization
  6. File types
  7. Kernel Data Structures

Overview

Filesystem Components

Filesystem Types

https://en.wikipedia.org/wiki/Comparison_of_file_systems

Hierarchy

Files are located by traversing a directory tree:

Linux filesystem is a single unified hierarchy, unlike Windows.

Filenames

Characters in Filenames

Really, anything?

$ touch Test results

$ date >T*

$ id >'~`!#$^&*( )[]\{}|;'\'':",.<>?½→☂☺'

$ ls -l
total 8
-rw------- 1 ct320 class 29 Jan 21 19:33 Test
-rw------- 1 ct320 class  0 Jan 21 19:33 results
-rw------- 1 ct320 class 51 Jan 21 19:33 ~`!#$^&*( )[]\{}|;':",.<>?½→☂☺

$ cal >Don't Panic!
.script: line 24: unexpected EOF while looking for matching `''
.script: line 25: syntax error: unexpected end of file

Anything‽

$ rm -z
rm: invalid option -- 'z'
Try 'rm --help' for more information.

$ rm '-z'
rm: invalid option -- 'z'
Try 'rm --help' for more information.

$ rm ./-z
rm: cannot remove './-z': No such file or directory

$ rm -- -z
rm: cannot remove '-z': No such file or directory

Mounted Filesystems

Global filesystem contains mounted filesystems:

Mounting

Unmounting

fuser

CodeMeaning
ffile open for reading
Ffile open for writing
ccurrent working directory
eexecuting a file
rroot directory (chroot)
mmapped file or shared library
$ PATH=/bin:/usr/bin:/sbin:/usr/sbin

$ pwd
/tmp/PmWiki-tmp
$ fuser -v .
                     USER        PID ACCESS COMMAND
/tmp/PmWiki-tmp:     ct320      4575 ..c.. php-cgi
                     ct320      4604 ..c.. bash

$ sleep 10 </etc/group &
$ fuser -v /etc/group
                     USER        PID ACCESS COMMAND
/etc/group:          ct320      4612 f.... sleep
$ kill %%

.script: line 2:  4612 Terminated              sleep 10 < /etc/group
$ echo "My PID is $$"
My PID is 4604
$ fuser -v /bin/bash
                     USER        PID ACCESS COMMAND
/usr/bin/bash:       ct320      4604 ...e. bash

Filesystem Structure

Examples

$ ls -l /etc/passwd
-rw-r--r-- 1 root root 3857 Dec 20 16:50 /etc/passwd

$ ls -i /etc/passwd
524532 /etc/passwd

$ stat /etc/passwd
  File: '/etc/passwd'
  Size: 3857      	Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d	Inode: 524532      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-01-21 16:51:23.006153264 -0700
Modify: 2017-12-20 16:50:49.141543476 -0700
Change: 2017-12-20 16:50:49.142543464 -0700
 Birth: -

inode

inode block pointers

A classic inode has thirteen pointers:

Some filesystems optimize the storage of tiny files by storing the data itself in the inode.

Filesystem Organization

Standard directories

DirectoryMeaningDirectoryMeaning
/bootBoot directory/usrMost standard programs
/devDevice files/varSpool directories
/etcCritical system files/homeMount point for users
/sbinSystem utilities/libLibs and parts of the C compiler
/binImportant utilities/mediaRemovable media
/tmpTemp files/optOptional applications

Standard directories

/usr/binMost commands and executables
/usr/includeHeader files
/usr/libLibraries, support files for standard programs
/usr/localLocal software
/usr/local/binLocal executables
/usr/local/Other local (etc, lib, sbin, src)

Standard directories

/usr/manMan pages
/usr/sbinLess essential sysadmin commands
/usr/shareCommon to multiple systems
/usr/share/manShared man pages
/usr/srcSource code for nonlocal packages

Standard directories

/var/admLogs, system setup records
/var/logSystem log files
/var/spoolSpooling directories (mail, printers)
/var/tmpMore temp space (preserved between boots)

File types

$ ls -ld /dev/console /dev/log /dev/sda
crw------- 1 root root 5, 1 Jan 10 17:33 /dev/console
srw-rw-rw- 1 root root    0 Jan 10 17:33 /dev/log
brw-rw---- 1 root disk 8, 0 Jan 10 17:33 /dev/sda

File type encoding

File typeSymbolCreated byRemoved by
Regular file-cp, mv, virm
Directorydmkdir, cp -rrmdir, rm -r
Character device filecmknodrm
Block device filebmknodrm
Local domain socketssocket(2)rm
Named pipepmknodrm
Symbolic linklln -srm

Examples

$ ls -ldU /etc/passwd /tmp /dev/random /dev/sda /dev/gpmctl /bin/cc
-rw-r--r-- 1 root root 3857 Dec 20 16:50 /etc/passwd
drwxrwxrwt 5 root root 1620 Jan 21 19:33 /tmp
crw-rw-rw- 1 root root 1, 8 Jan 10 17:33 /dev/random
brw-rw---- 1 root disk 8, 0 Jan 10 17:33 /dev/sda
srwxrwxrwx 1 root root    0 Jan 10 17:33 /dev/gpmctl
lrwxrwxrwx 1 root root    3 Dec  1 12:19 /bin/cc -> gcc

Regular file

Directories

Character and Block Device files

$ ls -l /dev/cdrom
lrwxrwxrwx 1 root root 3 Jan 10 17:33 /dev/cdrom -> sr0
$ ls -lH /dev/cdrom
brw-rw----+ 1 root cdrom 11, 0 Jan 10 17:33 /dev/cdrom

Some Device Files

NameDescription
/dev/sda2disk
/dev/ttyS0RS-232 serial line
/dev/pts/1Pseudo-tty (pty)
/dev/ttyAn alias for your terminal
/dev/nullRead fails, write succeeds
/dev/fullRead succeeds, write fails
/dev/zeroRead yields zeroes
/dev/randomRead yields random data

Local domain sockets

Named Pipes

Communication mechanisms

Symbolic links

Hard Links

Hard/Soft Link Differences

Modified: 2017-09-13T15:14

User: Guest

Check: HTML CSS
Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building