17
The Unix File sytem

The Unix File sytem

Embed Size (px)

DESCRIPTION

The Unix File sytem. Introduction. Tree structure …. The on-line manual. man gives detailed information about UNIX commands and other facilities Details include command format, description, examples, known problems, related files and commands - PowerPoint PPT Presentation

Citation preview

Page 1: The Unix File sytem

The Unix File sytem

Page 2: The Unix File sytem

Introduction

• Tree structure …

Page 3: The Unix File sytem

The on-line manual• man <command> gives detailed

information about UNIX commands and other facilities

• Details include command format, description, examples, known problems, related files and commands

• Sections for commands, programming, admin and others

• man intro for the introduction• man man (of course)

Page 4: The Unix File sytem

UNIX Filestore

• Files and directories

• The filesystem hierarchy

• File handling commands

Page 5: The Unix File sytem

Files• From the user’s point of view, all

information on the computer is stored in files

• Files may contain many kinds of information, including programs, data and documents

• Like paper files, they have a name (chosen by the user) and some content

• By convention, the filename suffix suggests the type of content

Page 6: The Unix File sytem

Example files

• Me.sh = Shell script• Me.pl = Perl script• Me.txt = Text file• Me.jpg, Me.png, Me.gif = Image files• Me.html = HTML web page file• Me.zip, Me.gz Me.bz2 = Compressed file• Me.tar = Archived file• Me.log = Log file

These are just conventions and are not enforced by the operating system!

Page 7: The Unix File sytem

Directories

• Files are stored in directories (folders in Windows)

• Each directory may contain many files and also other directories

• By convention, directory names do not usually have suffixes

Page 8: The Unix File sytem

The filestore

• There is a single hierarchical filestore that is shared by all users

• It might be spread over the network, may involve many disks on may different computers and may even be linked to other filestores

Page 9: The Unix File sytem

• Each user has their own personal home directory (~)

• There are also common areas for programs, administration, etc.

• The filestore starts at the root directory (/)

• A user is always in a current working directory (CWP) from which they give commands to access files

• When users log on, the CWP is set to their home directory

The filestore

Page 10: The Unix File sytem

(root)

staff usr bin stud etc

Research Teaching Private

pgugitmastersxxxgtrxxx

CUA

Coursework1.txt

CUA

xxx02u xxx04u

MVR

Lecture1.ppt

Lecture2.doc

.profile

The filestore

Page 11: The Unix File sytem

Where am I in the File Structure?

• pwd prints the pathname of the current working directory

• cd pathname changes current directory– with no argument it goes to the home

directory

Page 12: The Unix File sytem

Where am I in the File Structure? (2)

robin$ pwd/stud/ug/xxx04urobin$ cd USTrobin$ pwd/stud/ug/xxx04u/UST

robin$ pwd/stud/ug/xxx04u/USTrobin$ cd ..robin$ pwd/stud/ug/xxx04u/

(root)

staff usr bin stud etc

Research Teaching Private

pgugitmastersxxxgtrxxx

CUA

Coursework1.txt

UST

xxx02u xxx04u

MVR

Lecture1.ppt

Lecture2.doc

.profile

Page 13: The Unix File sytem

File handling commands – Viewing File Contents

• The cat [filename…] command displays the contents of the named files

• It reads the contents of the file(s) and outputs to the shell window

• with no arguments cat simply echoes back what you type at the keyboard

• there is no scrolling with the cat command

• more [filename…] lets you scroll through a file– also less [filename…]

Page 14: The Unix File sytem

Viewing File Contents (2)

• head displays the first 10 lines of a file

• tail displays the last 10 lines of a file

Page 15: The Unix File sytem

• ls [pathname…] lists the contents of the named directories– with no argument, the current directory is

listed• mv pathname1 pathname2 moves a file

from pathname1 to pathname2– if pathname2 already exists, then its

previous contents are lost– if not, then it is created

Viewing and Changing Directory Contents

Page 16: The Unix File sytem

• cp pathname1 pathname2 copies the contents of pathname1 to pathname2

– if pathname2 already exists, – then its previous contents are lost– if not, then it is created

• rm pathname removes files but not directories (be careful)

Viewing and Changing Directory Contents (2)

Page 17: The Unix File sytem

• mkdir pathname ... creates a new directory– it fails if they already exist

Manipulating Directories

robin$ rmdir fredrmdir: directory “fred”: Directory not empty

robin$ mkdir fredrobin$ mkdir fredmkdir: failed to make directory “fred”; File exists

• rmdir pathname removes directories– it fails if they are not empty