Introduction to UNIX D UNIX File Structure June

  • Slides: 25
Download presentation
Introduction to UNIX D. UNIX File Structure June 1, 1999 UNIX File System 1

Introduction to UNIX D. UNIX File Structure June 1, 1999 UNIX File System 1

UNIX File System Performance Objectives: 1. 2. 3. 4. 5. 6. 7. Identify types

UNIX File System Performance Objectives: 1. 2. 3. 4. 5. 6. 7. Identify types of Files (file) Diagram the relationship of Files and Directories Navigate the UNIX Directory Structure (cd, pwd) Identify pathnames: Absolute (/) and Relative (. . . ~) Define file naming conventions Make and remove directories (mkdir, rmdir) List files and directories and their attributes (ls) June 1, 1999 UNIX File System 2

Types of Files • • • Documents (ordinary files) Directories (help organize other files)

Types of Files • • • Documents (ordinary files) Directories (help organize other files) Commands Special files - pipe | Hidden files (dot) Devices June 1, 1999 UNIX File System 3

Relation of Files & Directories • Root is like a file cabinet. n n

Relation of Files & Directories • Root is like a file cabinet. n n n A directory is like a file drawer A subdirectory is like a folder within a drawer. A path is a list of directories & subdirectories from root to a specific file or subdirectory. / Root Directories Files June 1, 1999 UNIX File System 4

UNIX Directory Structure • At login, you are in your home directory. • This

UNIX Directory Structure • At login, you are in your home directory. • This is your current working directory. • All files and directories below your home directory usually belong to you. • You change your working directory by changing to another directory (cd). June 1, 1999 UNIX File System 5

Pathnames • Absolute Pathname: n shows the absolute position of a file or directory

Pathnames • Absolute Pathname: n shows the absolute position of a file or directory in the hierarchy; /home/user 2/bif/docs n begins with a slash (/); and n describes how to get to the file from the root. June 1, 1999 UNIX File System 6

Pathnames • Relative Pathnames: n n Describes how to get to a file from

Pathnames • Relative Pathnames: n n Describes how to get to a file from your current working directory. Special characters represent directory locations. è home directory ~ ~chidhkra è current directory. cp ~chidhkra/file. è parent directory. . cp ~chidhkra/file. . June 1, 1999 UNIX File System 7

Filesystems • A file is identified by n n Combining directory pathnames To the

Filesystems • A file is identified by n n Combining directory pathnames To the filename /usr/local/meeting / root usr files local meeting June 1, 1999 UNIX File System 8

Naming Files • Filenames may be 1 to 255 characters n n UPPER and

Naming Files • Filenames may be 1 to 255 characters n n UPPER and lowercase, numbers, other ASCII characters, except special Shell characters, control characters and the space. June 1, 1999 UNIX File System 9

Filename DON'TS • Don't begin a filename with a dot (. ) • Don't

Filename DON'TS • Don't begin a filename with a dot (. ) • Don't use any of the following characters ; | ? * {} < > : # () [] ' $ - ~ " ! % & / June 1, 1999 UNIX File System 10

Examples of UNIX File Names: status. memo casey_mt 1. 2. 3 chapter 1 June

Examples of UNIX File Names: status. memo casey_mt 1. 2. 3 chapter 1 June 1, 1999 UNIX File System 11

Hidden Files (dot) • Used to establish your environment: . cshrc. pinerc . login.

Hidden Files (dot) • Used to establish your environment: . cshrc. pinerc . login. forward • Must use ls -a option to view • Always in home directory (some exceptions) June 1, 1999 UNIX File System 12

Naming Conventions • Programs like make, cc, and sccs use a default conventions to

Naming Conventions • Programs like make, cc, and sccs use a default conventions to name files generated: <f>. o Binary Compiler Output <f>. j FPP output files <f>. i C preprocessor Output <f>. a AR or BLD files <f>. c C/C++ language source code <f>. Z compressed files (use <f>. f Fortran source code uncompress) <f>. mk Makefiles <f>. gz gzipped files (use gunzip) s. <f> SCCS files <f>. tar tape archive (use tar) a. out executable name <f>. l compiler listings June 1, 1999 UNIX File System 13

Identifying File Content • The command file identifies file content: host% file passwd: ascii

Identifying File Content • The command file identifies file content: host% file passwd: ascii text host% file ~dhk/* PSaddress: Post. Script document acl: directory address: [nt]roff, tbl, or eqn input text adv. fil: ascii text cfs. size: executable shell script dip: shell commands June 1, 1999 UNIX File System 14

Directory Commands • mkdir • cd • pwd • ls • rmdir June 1,

Directory Commands • mkdir • cd • pwd • ls • rmdir June 1, 1999 making a directory changing your working directory printing your working directory listing the contents of a directory removing a directory UNIX File System 15

Directory Commands - mkdir • Make directory under current working directory host% mkdir docs

Directory Commands - mkdir • Make directory under current working directory host% mkdir docs • Make directory under subdirectory host% mkdir docs/index • Make directory and subdirectory host% mkdir docs/index • Make directory using absolute path User 1 (cwd) docs index host% mkdir /usr/tmp/abc June 1, 1999 UNIX File System 16

Common Error Messages: mkdir: dirname: File exists mkdir: dirname: Permission denied June 1, 1999

Common Error Messages: mkdir: dirname: File exists mkdir: dirname: Permission denied June 1, 1999 UNIX File System 17

Directory Commands - cd userx host% cd docs host% cd /usr/tmp/abc/docs /usr tmp abc

Directory Commands - cd userx host% cd docs host% cd /usr/tmp/abc/docs /usr tmp abc host% cd ~abc/docs host% cd docs ~abc docs host% cd. . June 1, 1999 UNIX File System 18

Common Error Messages: • pathname: No such file or directory • pathname: Permission denied

Common Error Messages: • pathname: No such file or directory • pathname: Permission denied June 1, 1999 UNIX File System 19

Directory Commands - pwd • Determining the current working directory: host% pwd /scc/users/chitspit/bif •

Directory Commands - pwd • Determining the current working directory: host% pwd /scc/users/chitspit/bif • where: / è scc/ è users/ è chitspit/ è bif è June 1, 1999 root file system followed by the delimiter (/) subdirectory of scc directory followed by the delimiter (/) current working directory UNIX File System 20

Directory Commands - ls cwd host% ls bin mbox complex. f outdis remodel test

Directory Commands - ls cwd host% ls bin mbox complex. f outdis remodel test host% ls -s. F (Multiple options may be specified) 15 bin/ 256 mbox 3 remodel/ 34 complex. f 6 outdis@ 1 test* host% ls ~chitspit/bin au clst prod show June 1, 1999 xref UNIX File System 21

Directory Commands - ls • The long list provides additional file information: List alphabetized

Directory Commands - ls • The long list provides additional file information: List alphabetized host% ls -l total 31 drwxr-xr-x -rw-r--r--rw-------rw-r--r-drwxr-xr-x -rwxr-xr-x June 1, 1999 2 1 1 1 2 1 dhk 512 dhk 129 dhk 4291 dhk 512 dhk 10291 UNIX File System Oct Nov Jul Jun Jan Mar 23 20 2 16 22 19 1985 10: 05 14: 18 11: 07 12: 55 bin comp mbox outdis remod test 22

List Hidden Files: ls -a • The -a option lists all files in a

List Hidden Files: ls -a • The -a option lists all files in a directory: host% ls -a. . login. . bin. cshrc complex. f June 1, 1999 mail test public_html remodel UNIX File System 23

Directory Commands - rmdir • The rmdir command removes directories. host% rmdir bif/docs •

Directory Commands - rmdir • The rmdir command removes directories. host% rmdir bif/docs • Directory must be empty. userx bif docs • Common error messages: rmdir: docs: Directory not empty è rmdir: /scc/users/abc/docs: Permission denied è June 1, 1999 UNIX File System 24

End of Module Complete UNIX File Structure Exercises June 1, 1999 UNIX File System

End of Module Complete UNIX File Structure Exercises June 1, 1999 UNIX File System 25