CUNY CSCI 132 - Overview of the UNIX File System

Unformatted text preview:

Overview of the UNIX File SystemThe UNIX File SystemThe UNIX File System HierarchyThe UNIX File System HierarachySpecial DirectoriesThe /bin subdirectoryThe /etc subdirectoryThe /dev subdirectoryOther Important Top-Level DirectoriesYour Current Working DirectoryYour Working Directory (2)The Home DirectoryNames for the Home DirectoryWhat is a Directory, Anyway?ExampleDisplaying files in a directoryIdentifying Files by PathnamesAbsolute PathnamesExample of Absolute PathnameRelative PathnamesHidden Files in UNIXHow ls "hides" FilesWhy Hide Files?Configuration FilesTwo Entries in Every DirectoryThe . directoryThe .. DirectoryMore about .. EntriesUseful Related Commands: cdUseful Related Commands: pwdCreating DirectoriesMore About mkdirOutput RedirectionThe Output Redirection OperatorCreating Files Using >Your EnvironmentViewing Your EnvironmentUsing printenvBasic Environment VariablesOther Ways to View VariablesEchoing Environment VariablesThings to tryCopyright 2006 Stewart WeissCopyright 2006 Stewart WeissOverview of the UNIX File SystemOverview of the UNIX File SystemNavigating and Viewing Directories2 CSci 132 Practical UNIX with PerlThe UNIX file systemThe most distinguishing characteristic of the UNIX file system is the nature of its files.In UNIX, everything is a file: directories (folders), devices (like keyboards, monitors, and printers), documents, programs, network connections, and even random access memory.By making everything a file, UNIX's designers simplified the operating system, making it easy to extend and maintain.3 CSci 132 Practical UNIX with PerlThe UNIX file system hierarchyThe UNIX file system is organized into a hierarchy whose top level is called the root ("/") directory. The root directory always has certain specific sub-directories, which in turn have specific sub-directories of their own. Below are some of the directories present in every UNIX system:/etc sbin usr devbin libroot4 CSci 132 Practical UNIX with PerlThe UNIX file system hierarchyEvery directory is either empty, or it has other directories or non-directory files. This is a fragment of a fictitious file system:/etc home usr devbin libcourses libstewart tbw asia man docbin share localfaculty gradstud5 CSci 132 Practical UNIX with PerlSpecial directoriesThe top level sub-directories keep UNIX organized. Some contain executable programs, some contain administrative files, some contain special library files, and others contain device drivers. Some contain important data.Every UNIX system uses these directories in the same way, no matter what "flavor" of UNIX it is.Ordinary users cannot modify any of the files in these special directories.Following are descriptions of a few of these directories.6 CSci 132 Practical UNIX with PerlThe /bin subdirectoryOriginally UNIX was small enough that all programs could be placed into a single directory, /bin.Programs are executable files, consisting not of words and letters, but sequences of binary digits (i.e., bits), 0 and 1. They are called executables, because they are executed (run) by the computer. Executables are also called binaries.bin is short for binaries. In UNIX all words were abbreviated, to make it compact and faster.7 CSci 132 Practical UNIX with PerlThe /etc subdirectoryThe /etc directory was created as a place to store configuration and administrative files. The type of stuff you'd find in a Windows registry or in the Mac's System folder is found in /etc. So much is stored in /etc these days that it has many subdirectories of its own.8 CSci 132 Practical UNIX with PerlThe /dev subdirectoryThe /dev directory is a marvel to behold. It embodies the ingenuity of UNIX's creators.Every file in /dev represents some physical or logical device. Each actually contains a device driver; i.e., an executable program. The interesting part is that you never "run" these files. Instead you read from them or write to them as if they were ordinary text files. We will visit this directory in future lessons.9 CSci 132 Practical UNIX with PerlOther important top-level directories/usr usually contains executables/var more administrative files/lib library files /tmp temporary work space for programs/boot start up files/home usually the top level of user home directories/proc images of running programs10 CSci 132 Practical UNIX with PerlYour current working directoryWhenever you are logged into a UNIX system, you have a unique, special directory called your current or present working directory (PWD for short).The present working directory is where you "are" in the file system at the moment, i.e., the directory that you feel like you are currently "in". UNIX keeps track of your PWD as you move about the file system. (We'll see how soon.)11 CSci 132 Practical UNIX with PerlYour current working directory (2)Many commands operate on the PWD if you do not give them an argument. We say that the PWD is their default argument. (Defaults are fall-backs – what happens when you don't do something.)For example, when you enter the "ls" command (list files) without an argument, it displays the contents of your PWD. The dot "." is the name of the PWD: ls . and ls both display the files in the PWD.12 CSci 132 Practical UNIX with PerlThe home directoryWhen you first login, your present working directory is set to your home directory. Your home directory is a directory created for you by the system administrator. It is the top level of the part of the file system that belongs to you. You can create files and directories within your home directory, but usually nowhere else.Usually your home directory's name is the same as your username.13 CSci 132 Practical UNIX with PerlThe home directory's namesThe home directory is can be referred to by the tilde ~ (located above the ` on the keyboard). For example,ls ~means list the files in your home directory.Every user's home directory can be referenced using the form, ~username, where username is the person's login name, as incd ~sweisswhich is the same as cd ~14 CSci 132 Practical UNIX with PerlWhat is a directory, anyway?How do directories "contain" files?A directory is a file with a specific structure: it is a table with as many rows as the number of files it contains. Each row represents a file and is called a directory entry. The entry has two parts: the name of the file and an index number that UNIX uses to find the file's contents on the disk:name of file index number UNIX uses to find file15 CSci 132 Practical UNIX with


View Full Document

CUNY CSCI 132 - Overview of the UNIX File System

Download Overview of the UNIX File System
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Overview of the UNIX File System and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Overview of the UNIX File System 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?