UNIX File Systems and Directories: A Comprehensive Guide, Study notes of Computer Science

An in-depth exploration of unix file systems and directories. Topics include the unix file hierarchy, working with directories and files, file names, pathnames, and various commands such as ls, cd, mkdir, and rmdir. Understand the concept of home directories, special directories, and the difference between absolute and relative pathnames.

Typology: Study notes

Pre 2010

Uploaded on 08/19/2009

koofers-user-m6w-1
koofers-user-m6w-1 🇺🇸

10 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMP 4/6262:
Programming UNIX
Lecture 3
File systems
January 25, 2006
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download UNIX File Systems and Directories: A Comprehensive Guide and more Study notes Computer Science in PDF only on Docsity!

  • COMP 4/6262: Programming UNIX Lecture 3 File systems January 25,

Outline {

UNIX file hierarchy

Working with directories

z current working directory, home directory z pathnames z list directory: ls (learn commands in general) z cd, mkdir, rmdir

Working with files

z list files z organize files: what goes where

UNIX filesystem {

The filesystem is your interface to

z physical storage (disks) on your machine z storage on other machines z output devices z etc.

Everything

in UNIX is a file (programs,

text, binaries, directories, peripheraldevices, terminals, …)

The file system provides a

logical

view of

the storage devices

UNIX file hierarchy

comp / usr bin home var lib classes students faculty comp 6262- 6262- 6262- 6262-

aquota.user

output.dat

Disk vs. Filesystem

The entire hierarchy can actuallyinclude many disk drives. z some directories can be on othercomputers / bin etc users tmp usr hollid scully

Working directory {

The current directory in which you areworking

pwd

command: prints the current working

directory

Unless you specify another directory,commands will assume you want tooperate on the working directory

Home directory {

A special place for each user to storepersonal files

When you log in, your working directorywill be set to your home directory

Your home directory is represented by thesymbol ~(tilde)

The home directory of 6262-00 isrepresented by

Special Directories {

current directory

parent directory

example

z if my current directory is my home directory z output.dat is equivalent to ./output.dat z .. is comp

These directories can be chained

z “../..” stands for two directories directly abovethe current directory /

usr

bin

home

lib

comp

classes

comp

Commands

in

general

synopsis: ls [options]… [dirNames]… { Options z [-abc]: any or all arguments within [] are optional z -a|-b : options delimited by | cannot be used together { Arguments z [expression]: entire expression within [] isrepeatable z argument … : argument is repeatable { You can mix any options with any dirNames { You can have multiple dirNames

Examples:

ls

{ ls { ls. { ls ~ { ls /home/classes { ls / { ls .. { ls -al /usr/bin { ls /usr/bin /tmp /etc { ls –l /usr /etc { ls /usr /bin -a

Creating and removing directories mkdir, rmdir {

mkdir

z

Makes a directory

z

mkdir myDir

{ rmdir

z

Removes an empty directory

z

rmdir myDir

File Contents {

Each file can hold some raw data

UNIX does not impose any structure onfiles

z files can hold any sequence of bytes

Many programs

interpret

the contents of

a file as having some special structure

z text file, sequence of integers, databaserecords, etc.

What Goes Where? {

/ z Root of the entire system z Comparable in Windows to C: (but you may haveD:, E: .. several roots) { /bin z Commonly used binaries (programs) { /sbin z More programs to run { /usr z User related commands as well as a whole bunch ofrandom stuff { /lib z Libraries go in here

And… {

/dev z All devices are located in here { /home z Traditionally, this is where user accounts are stored { /etc z Startup files and configuration files for daemons andother programs { /var z Various files go in here z Traditional location of mailboxes {

/var/spool/mail

/proc z Special files that contain information about thesystem or info from running programs