CT320

CT320: Network and System Administration

Fall 2016

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 Jack Applin
% date >J*
% ls -l
total 4
-rw------- 1 neutron neutron  0 Jul  3 17:24 Applin
-rw------- 1 neutron neutron 29 Jul  3 17:24 Jack

% date >don't
> What is going on?
> I can't keep this up forever.
date: extra operand ‘this’
Try 'date --help' for more information.

% touch '~`!#$^&*( )[]\{}|;'\'':",.<>?½→⻥☂'
% ls -lhog *:*
-rw------- 1 0 Jul  3 17:28 ~`!#$^&*( )[]\{}|;':",.<>?½→⻥☂
% 

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

Identify Processes

fuser -mv /MST3K (Shows all open files, processes, and executables)

CodeMeaning
fProcess has a file open for reading
FProcess has a file open for writing
cProcess has a current working directory
eProcess is currently executing a file
rProcess has set a root directory (chroot)
mProcess has mapped a file or a shared library

Filesystem Structure

Examples

    $ ls -l /etc/passwd
    -rw-r--r--. 1 root root 2733 May 17 12:46 /etc/passwd
    $ ls -i /etc/passwd
    1468033 /etc/passwd
    $ stat /etc/passwd
    File: `/etc/passwd’
    Size: 2733 Blocks: 8 IO Block: 4096 regular file
    Device: 802h/2050d Inode: 1468033 Links: 1
    Access: (0644/-rw-r--r--) Uid: (0/ root) Gid: (0/ root)
    Access: 2012-08-29 18:50:01.213638229 -0600
    Modify: 2012-05-17 12:46:25.000000000 -0600
    Change: 2012-05-18 18:41:06.000000000 -0600

inode

An inode contains, at least:

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
    crw------- 1 root root 5, 1 Aug 24 15:24 /dev/console
    brw-rw---- 1 root disk 8, 0 Aug 24 15:23 /dev/sda
    srw-rw-rw- 1 root root    0 Aug 24 15:23 /dev/log

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

Regular file

Directories

Character and Block Device files

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

Kernel Data Structures

    % grep MHz /proc/cpuinfo
    cpu MHz         : 1199.000
    cpu MHz         : 1199.000
    cpu MHz         : 1199.000
    cpu MHz         : 1199.000
    cpu MHz         : 1199.000
    cpu MHz         : 1199.000
    cpu MHz         : 1199.000
    cpu MHz         : 1199.000

Modifying kernel parameters

#! /bin/bash

# Set display to half-bright:

for max in /sys/class/*/*/max_brightness
do
    echo $(($(<$max)/2)) >${max%/*}/brightness
done

Modified: 2016-07-03T17:28

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