15 Unix03 Directory Structure

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

By: anitatomar (106 month(s) ago)

plz send this ppt on my mail id : anitarawat86@gmail.com....

By: vinodkumarbc (115 month(s) ago)

It was awesome ppt.... if possibl will u mail me this ppt on vinodkumarnie@gmail.com... thank you

By: vaishali_papneja (93 month(s) ago)

plz send me this ppt on vaishalipapneja2012@gmail.com if possible.. i need this urgent..

 

By: deeptikalra (117 month(s) ago)

if possibl mail me on neetu237.kalra@gmail.com thank you

By: devyfong (138 month(s) ago)

It's good stuff!

Presentation Transcript

UNIX/Linux: 

UNIX/Linux Directory Structure

Outline: 

Outline Linux directory structure & common directories Absolute & relative paths Dot, and Dot-Dot files Commands mkdir pwd cd ls rmdir Wildcards - * ? [ ]

The UNIX Directory Structure: 

The UNIX Directory Structure The UNIX file structure is hierarchical or tree structured and is quite similar to that of DOS (and MS Windows). This is no coincidence since the DOS (and thus Windows) file structure was derived from UNIX. In UNIX (and DOS) this structure is made up of “directories” and “subdirectories”. In Windows we call these “folders”.

The UNIX Directory Structure: 

The UNIX Directory Structure

The UNIX Directory Structure: 

The UNIX Directory Structure Directory Contents bin UNIX utilities lib Libraries used by the UNIX language processors tmp Temporary files

The UNIX Directory Structure: 

The UNIX Directory Structure Directory Contents home Files associated with the various users dev Files needed for I/O devices (Device Drivers) etc Administrative programs and tables

The UNIX Directory Structure: 

The UNIX Directory Structure Directory Contents mail Mail system files news News files spool Spool files for printing / (root) top node; designated by the / (forward slash).

Methods of specifying locations: 

Methods of specifying locations Absolute pathnames begin with the root Relative pathnames begin with the current working directory A slash is used to separate elements in a path description

Example - files in marys directory: 

Example - files in marys directory If the current working directory is marys: %ls

Example- files in marys directory: 

Example- files in marys directory If the current working directory is marys: %ls xyz BD350 mail mbox lists all files in the directory marys uses relative addressing

Example - files in BD350 directory: 

Example - files in BD350 directory If the current working directory is marys: %ls BD350

Example- files in BD350 directory: 

Example- files in BD350 directory If the current working directory is marys: %ls BD350 assign1 assign2 prog1 junk lists all files in the directory BD350 uses relative addressing

Example- files in BD350 directory: 

Example- files in BD350 directory If the current working directory is marys: %ls /home/marys/BD350

Example- files in BD350 directory: 

Example- files in BD350 directory If the current working directory is marys: %ls /home/marys/BD350 assign1 assign2 prog1 junk lists all files in the subdirectory BD350 in the marys subdirectory of the /home directory uses absolute addressing It’s actually irrelevant that the cwd is /home/marys, because of absolute addressing

Directory structure: 

Directory structure Every user is assigned to a home directory After login, users are automatically positioned in that directory to start with (if everything went correctly…)

Relative path codes: 

Relative path codes A “dot” ( . ) indicates the current working directory “Dot-dot” ( .. ) indicates the parent directory the parent directory is the directory immediately above the current working directory

Example- files in usr directory: 

Example- files in usr directory If the current working directory is /home/marys: %ls ..

Example- files in usr directory: 

Example- files in usr directory If the current working directory is /home/marys: %ls .. johnd marys lists all files in the directory /home /home is the parent directory of /home/marys

Example- files in johnd directory: 

Example- files in johnd directory If the current working directory is /home/marys: %ls ../johnd

Example- files in johnd directory: 

Example- files in johnd directory If the current working directory is /home/marys: %ls ../johnd abs xyz mail mbox lists all files in the directory /home/johnd Assuming marys has permission to list /home/johnd johnd is a subdirectory of /home

Example- files in bin directory: 

Example- files in bin directory If the current working directory is /home/marys: %ls ../../bin

Example- files in bin directory: 

Example- files in bin directory If the current working directory is /home/marys: %ls ../../bin grep sort cc vi lists all files in the directory /bin

Directory Manipulation Commands: 

Directory Manipulation Commands

mkdir Command : 

mkdir Command Purpose creates one or more new directories Syntax mkdir [ -m Mode ] [ -p ] Directory ...

mkdir Command: 

mkdir Command Description Creates one or more new directories specified by the Directory parameter. Each new directory contains the standard entries . (dot) and .. (dot-dot).

mkdir Command: 

mkdir Command Note: To make a new directory you must have write permission in the parent directory.

mkdir Command: 

mkdir Command To create a new directory called Test in the current working directory, enter: %mkdir Test

mkdir Command: 

mkdir Command To create a new directory called Test in the current working directory, enter: %mkdir Test % The new directory has been created

pwd Command : 

pwd Command Purpose Displays the path name of the working directory pwd = “print working directory” Syntax pwd

pwd Command : 

pwd Command Description Writes to standard output the full path name of your current directory (from the root directory). All directories are separated by a / (slash). The root directory is represented by the first / (slash) the last directory named is your current directory

pwd Command: 

pwd Command To display the current directory, enter: %pwd

pwd Command: 

pwd Command To display the current directory, enter: %pwd /home/marys %

cd Command: 

cd Command Purpose Changes the current directory Syntax cd [ Directory ]

cd Command: 

cd Command Description moves you from your present directory to another directory. You must have execute (search) permission in the specified directory.

cd Command: 

cd Command Description (cont’d) If you do not specify a Directory parameter, the cd command moves you to your login (HOME) directory $HOME in the ksh and bash environments $home in the csh environment If the specified directory name is a full path name, it becomes the current directory.

cd Command: 

cd Command To change to your home directory, enter: %cd

cd Command: 

cd Command To change to your home directory, enter: %cd % You are now in your home directory can use pwd command to confirm this

cd Command: 

cd Command To change to an arbitrary directory, enter: %cd /home/johnd

cd Command: 

cd Command To change to an arbitrary directory, enter: %cd /home/johnd % Current directory is now /home/johnd

cd Command: 

cd Command To go down one level of the directory tree (current working directory is /home/marys), enter: %cd BD350

cd Command: 

cd Command To go down one level of the directory tree (current working directory is /home/marys), enter: %cd BD350 % Current directory is now /home/marys/BD350

cd Command: 

cd Command To go up one level of the directory tree, enter: %cd ..

cd Command: 

cd Command To go up one level of the directory tree, enter: %cd .. % The special file name, .. (dot-dot), refers to the directory immediately above the current directory.

rmdir Command: 

rmdir Command Purpose Removes a directory. Syntax rmdir [ -p ] Directory ...

rmdir Command: 

rmdir Command Description Removes the directory, specified by the Directory parameter, from the system. The directory must be empty before you can remove it, and you must have write permission in its parent directory. Use the ls -la command to check whether the directory is empty.

rmdir Command: 

rmdir Command Flags -p Removes all directories along the path name specified by the Directory parameter. Parent directories must be empty and the user must have write permission in the parent directories before they can be removed.

rmdir Command: 

rmdir Command To empty and remove the current working directory named BD350, enter: %rm * removes all files in the current working directory Warning: BE CAREFUL! Make sure you really want to do this – there’s no “recycle bin” from which to restore…

rmdir Command: 

rmdir Command To empty and remove the current working directory named BD350, enter: %rm * %cd .. moves to the parent directory

rmdir Command: 

rmdir Command To empty and remove the current working directory named BD350, enter: %rm * %cd .. %rmdir BD350 removes the directory BD350 (immediately below the current working directory, /home/marys).

rmdir Command: 

rmdir Command To remove the /home, /home/demo, and /home/demo/mydir directories, enter: %rmdir -p /home/demo/mydir An assumption is that the current working directory is not one of these directories.

rmdir Command: 

rmdir Command %rmdir -p /home/demo/mydir This removes first the /mydir directory, then the /demo and /home directories, respectively. If a directory is not empty or does not have write permission when it is to be removed, the command terminates.

Wildcards: 

Wildcards ? (question mark) matches any one character * (asterisk) matches any grouping of zero or more characters

Wildcards: 

Wildcards %ls hog hug huge thug %

Wildcards: 

Wildcards %ls hog hug huge thug %ls hu?

Wildcards: 

Wildcards %ls hog hug huge thug %ls hu? hug

Wildcards: 

Wildcards %ls hog hug huge thug %ls hu??

Wildcards: 

Wildcards %ls hog hug huge thug %ls hu?? huge

Wildcards: 

Wildcards %ls hog hug huge thug %ls ???

Wildcards: 

Wildcards %ls hog hug huge thug %ls ??? hog hug

Wildcards: 

Wildcards %ls hog hug huge thug %ls ?o?

Wildcards: 

Wildcards %ls hog hug huge thug %ls ?o? hog

Wildcards: 

Wildcards %ls hog hug huge thug %ls h*

Wildcards: 

Wildcards %ls hog hug huge thug %ls h* hog hug huge

Wildcards: 

Wildcards %ls hog hug huge thug %ls *g

Wildcards: 

Wildcards %ls hog hug huge thug %ls *g hog hug thug

Wildcards: 

Wildcards %ls hog hug huge thug %ls hug*

Wildcards: 

Wildcards %ls hog hug huge thug %ls hug* hug huge

Wildcards: 

Wildcards %ls hog hug huge thug %ls *hug

Wildcards: 

Wildcards %ls hog hug huge thug %ls *hug hug thug

Wildcards: 

Wildcards Putting a list of characters in [ ] %ls hog hug huge thug %ls h[aeiou]g [list] matches any single character from the list.

Wildcards: 

Wildcards Putting a list of characters in [ ] %ls hog hug huge thug %ls h[aeiou]g hog hug

Wildcard Ranges: 

Wildcard Ranges Using a range notation %ls [A-Z] => all filenames consisting of a single capital letter %ls [A-Z]* => all filenames starting with a capital letter

Wildcard Ranges: 

Wildcard Ranges The range is based on the collating sequence. Unless you really know what you are doing , it is a good idea to stay with ranges of the same type. [A-Z] [1-9] [a-z]

authorStream Live Help