Chapter 5 Accessing Files and Directories - PowerPoint PPT Presentation

samara
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 5 Accessing Files and Directories PowerPoint Presentation
Download Presentation
Chapter 5 Accessing Files and Directories

play fullscreen
1 / 19
Download Presentation
86 Views
Download Presentation

Chapter 5 Accessing Files and Directories

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Chapter 5 Accessing Files and Directories

  2. How Directories Get Created • OS installation: usr, dev, etc, export, kernel and others • places to store installation files and to store data files • user accounts • By default, users have permission to create subdirectories and files under their home directory

  3. Directory Tree inverted tree parent directory child directories (subdirectories) root directory - always at top of the hierarchy, designated as a forward slash (/)

  4. Path Components directory paths are important so we can navigate within the system slashes within the pathname are delimiters between object names Object names can be directories, subdirectories or files DOS & Win uses a backward slash (\) - UNIX uses a forward slash (/) slash (/) in the first position of any pathname represents root directory

  5. Types of Pathnames • Absolute Pathname • specifies the entire Solaris file hierarchy • start at root (/) and list each directory along the path to the destination • slash (/) between each directory name in the path • Relative Pathname • relates to your current directory • If a pathname does not begin with a slash, it is a relative pathname • you must know what directory you are currently in since that is your starting point • Absolute pathnames are usually longer but they are consistent because you specify the path from the root every time regardless of where you are


  6. Absolute Path Absolute pathname to the user2 directory /home/user2 Absolute pathname to the dir1 directory /home/user2/dir1 Absolute pathname to the coffees directory /home/user2/dir1/coffees

  7. Relative Path If your current directory is /home: Relative pathname to the user2 directory user2 Relative pathname to the dir1 directory user2/dir1 Relative pathname to the coffees directory user2/dir1/coffees

  8. Command Line Syntax refers to the structure of the command specifies allowable options and arguments $ command [option(s)] [argument(s)] Items in square brackets are optional, meaning they are not always required

  9. Command Line Examples

  10. Using Navigation Shortcuts • pwd (print working directory) command - • no options or arguments • displays directory using absolute path name • cd (change directory) command - • used with absolute or relative pathnames to navigate • by itself takes you to your home directory • cd .. command takes you up one level • cd ~/ command takes you to a directory under your home directory (tilde = home)

  11. Using ls Command ls (list) listing of files and directories within the current directory or specified directories ls -a list all files in a directory, including hidden (.) files and current (.) and parent (..) directories ls -F command displays listing with a symbol to tell what the type the file is: directory – A forward slash (/) after the name ASCII Text File - no symbol Executable – asterisk (*) after the name Symbolic Link – An at sign (@)

  12. Displaying Long Listing

  13. Recursive Listing ls -R (recursive) command - displays the contents of all directories, subdirectories and their contents for a particular part of the directory tree If done at a high level in the directory structure, the output can be substantial!

  14. Metacharacters

  15. Metacharacters

  16. Labs/Assessment Lab 5.3.1 Basic Command Line Syntax Lab 5.3.3 Navigating the File System Lab 5.4.6 Listing Directory Information Lab 5.5.2 Directory Listing with Metacharacters chapter 5 assessment

  17. Metacharacters Exercise What does this command do? $ ls *[1-5]*p

  18. Metacharacters Exercise (solution) What does this command do? $ ls *[1-5]*p lists any file, no matter what the length of the filename, if there is a 1 or 2 or 3 or 4 or 5 somewhere AND the filename ends with the letter p