Chapter 5
This presentation is the property of its rightful owner.
Sponsored Links
1 / 19

Chapter 5 Accessing Files and Directories PowerPoint PPT Presentation


  • 41 Views
  • Uploaded on
  • Presentation posted in: General

Chapter 5 Accessing Files and Directories. 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

Download Presentation

Chapter 5 Accessing Files and Directories

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Chapter 5 accessing files and directories

Chapter 5

Accessing Files and Directories


How directories get created

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


Directory tree

Directory Tree

inverted tree

parent directory

child directories (subdirectories)

root directory - always at top of the hierarchy, designated as a forward slash (/)


Path components

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


Types of pathnames

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


Absolute path

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


Relative path

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


Command line syntax

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


Command line examples

Command Line Examples


Using navigation shortcuts

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)


Using ls command

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 (@)


Displaying long listing

Displaying Long Listing


Recursive listing

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!


Metacharacters

Metacharacters


Metacharacters1

Metacharacters


Labs assessment

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


Metacharacters exercise

Metacharacters Exercise

What does this command do?

$ ls *[1-5]*p


Metacharacters exercise solution

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


  • Login