SlideShare a Scribd company logo
Lesson 7-Creating and Changing Directories
Overview  Using directories to create order. Managing files in directories. Using pathnames to manage files in directories. Accessing files in remote directories. Managing files from more than one directory. Moving and removing directories and their contents.
Using Directories to Create Order  A file is a collection of information stored electronically on the hard drive of a system. An inode contains all the information about each file, including the location of the actual file on the disk.
Using Directories to Create Order  The home directory. Listing files in a directory. Working with directories. Distinguishing between files and directories. Obtaining information about a directory or its contents.
The Home Directory The “pwd” command displays the path from root to the user’s home directory. The /etc/passwd file holds the user’s home directory path. A file is created and listed in the current home directory by default.
Listing Files in a Directory  The “ls” command reads the names of the files listed in the current directory, and then outputs those names. Each file in the directory contains only the name of that file and a number that leads to the inode for that file. The “–i” option instructs ls to include the inodes in its output. Inodes are small pieces of memory created on the hard disk when it is formatted.
Listing Files in a Directory  The inode has a list of addresses of the block on the disk where the data that comprise the file is actually located. It addresses up to 13 data blocks on the hard drive. The first ten blocks addressed from the inode contains the actual file data. If a file is too large, additional blocks are allocated to fit the data.
Working with Directories  The “mkdir” command is used for creating a new directory. Directories created in uppercase are listed first by the ls command. Each new directory created is called a subdirectory. The “cd” or “change directory” command instructs the shell to locate the directory listed as an argument.
Working with Directories  The “pwd” command outputs the absolute path from the top of the file system (root or /) to the current directory.  A path is a list of directory names separated by the / (slash) character. The topmost directory is called the root and is symbolized by the first forward slash (/) in the pathname.
Working with Directories  The vi editor can be used for creating a file within a directory or subdirectory. The cd command, without any directory name as an argument, returns to the home directory. The “–R” (recursive) option used with ls descends through each subdirectory in the directory tree.
Distinguishing between Files and Directories The “ls –F” command displays directory names with a slash appended at the end. Filenames displayed with an asterisk (*) at the end are executable files. The “–C” option to ls instructs ls to make several columns in the output instead of one.
Obtaining Information About a Directory or its Contents The “ls –l” command displays the permissions and owners of files listed in a directory. The “–d” option with ls command returns a listing of information about the contents of the target directory. The “ls –ld” displays the permissions of the directory, and not the information about the files.
Managing Files in Directories Moving or copying files into a subdirectory. Accessing a file in a subdirectory. Avoiding mistakes when moving files into directories. Renaming files. Removing files from subdirectories.
Moving or Copying Files into a Subdirectory  Moving a file or directory does not move the file electronically. The name and the inode number are erased from the current directory and are written in the subdirectory.
Moving or Copying Files into a Subdirectory  When a file is copied, a second electronic version is created. The copied file does not have the same inode number as the original. The copied file has its own inode, permission, and data blocks containing the new files actual contents.
Accessing a File in a Subdirectory To access a file in a subdirectory: Locate the inode number of the file. Check the permissions on the directory. Get the directory’s address from the inode. Identify the inode associated with the file. Read the files from the data blocks.
Avoiding Mistakes When Moving Files into Directories The mv utility takes two arguments. The first argument is the name of an existing file. The second argument is a new name assigned to existing file, unless the second argument is a directory. A slash at the end of the second argument interprets the argument as a directory name.
Renaming Files The command to move a file listing from the current directory to a new directory and also to change its filename is mv filename subdirectory/newfilename. Moving a file just moves its listing from one directory to another.
Removing Files from Subdirectories  The “rm” command can be used for removing files form a directory or subdirectory. After the rm command, the entry of the file is removed, and the data blocks listed in the inode for that file are released.
Using Pathnames to Manage Files in Directories  Accessing or creating a subdirectory. Using pathnames with utilities. Copying files into other directories using paths. Using parent directory names. Copying and moving multiple files to subdirectories. Examining the full path from root to directories and files.
Using Pathnames to Manage Files in Directories  Explicitly accessing a user’s home directory. Including other users’ logins in directory paths. Returning to the previous directory.
Accessing or Creating a Subdirectory  Providing a full path to the cd command without any spaces can access a subdirectory. Pathnames are the mechanism used to tell the shell what path to follow to access a file or directory not listed in the current directory. Remote directories can also be created by specifying the relative or absolute pathname.
Using Pathnames with Utilities  Pathnames can also be used as arguments to utilities. A relative path can be specified for accessing a file without changing the current directory.
Copying Files into Other Directories Using Paths  Pathnames are particularly useful with the “cp” and “mv” commands. Any command that takes a filename or directory name as an argument can be given an explicit pathname argument.
Using Parent Directory Names A single dot is used for referring to the current directory. In a directory, the .. (dot-dot) is the listing for its parent directory.  The parent directory is the directory located one level above the current directory.
Using Parent Directory Names The parent directory lists the current directory’s name and inode. The . and .. are the two listings that get created when a new directory is created.
Copying and Moving Multiple Files to Subdirectories  The move and copy commands are usually used with only two arguments. The cp utility displays a usage error message when more than two arguments are specified and the last argument is not a directory. In the cp command, if the third argument specified is a directory, then the rest of the file arguments are copied into the destination subdirectory.
Copying and Moving Multiple Files to Subdirectories  The mv and cp commands can affect multiple files when the last argument is a directory. The .. (dot-dot) listing can be used in the mv command for moving files into the parent directory.
Examining the Full Path from Root to Directories and Files A user can specify a directory’s location with the full path from the top of the file system. The full path starting at root identifies a file explicitly. The pathname for every file describes a particular file uniquely and absolutely. The full pathname to a file is called its absolute pathname.
Explicitly Accessing a User’s Home Directory  The “ls ~” command lists all filenames listed in the home directory. The C shell and all shells define the tilde (~) as the path to the user’s home directory. The shell replaces the tilde (~) with the value of the path to the user’s home directory. The shell replaces the tilde (~) in any command line with the absolute path from root to the user’s home directory.
Including Other Users’ Logins in Directory Paths The “echo ~root” option displays the path to the home directory of the user root. The contents of the home directory of a user are displayed if the user has appropriate permissions.
Returning to the Previous Directory The bash and ksh shells maintain the previous directory path as the value of a variable. The tcsh shell maintains a list of previous directories in a list that can be accessed. The value of the variable PWD is the path to the current directory.
Returning to the Previous Directory An alternative way of specifying the previous directory on many bash and ksh shells is to do it with a dash argument. The exit command can be used for exiting from a child bash or ksh to the login shell. The “popd” command instructs the shell to move the directory currently on the top of the list of directories that are added to the list.
Accessing Files in Remote Directories A filename that includes no relative path defaults to the current directory. The ./ is the default relative path that is used. Every file on the system has a unique pathname from / (root).
Accessing Files in Remote Directories The “pwd” command displays the absolute path of the present directory. A path always starts at root (/) and includes the appropriate subdirectories.
Managing Files from More Than One Directory A listing for a file in a directory is a link to the file. The ls –l command at the start lists the number of data blocks used by files and directories in the current directory. In a long listing entry, or record, the information for each file or directory is divided into seven fields. The second field in each entry of a file indicates the number of directories where the object is listed.
Managing Files from More Than One Directory Linking files: The “ln” command can be used for linking a file to the current directory. The index card of each file keeps track of the number of directories that list it. Each instance of the file listed in a directory is one link. Removing a file removes it from the directory listing.
Managing Files from More Than One Directory Linking files (continued): The ln utility can be used to link multiple files at a time. The “ls –il” command lists the current files with link count and inodes. The “–s” option to ln creates a file in the current directory that contains information required to locate the linked file.
Managing Files from More Than One Directory Using symbolic links: A symbolic link is a small file in a directory on one file system partition that points to the correct file system and the correct inode for the linked file. In the long listing of the symbolic link, the initial character is an “l” for directories and files. An arrow and path at the end of the listing displays the actual directory where the link points.
Managing Files from More Than One Directory Using symbolic links (continued): The ln utility provides a “–d” option for the root user to create hard links to directories. Ordinary users cannot create directory hard links. Ordinary users can create symbolic links to directories.
Managing Files from More Than One Directory The administrator can divide the hard drive into partitions for installing the system.  The partition labeled / holds the core of the hierarchal directory tree. A partition is further divided into small pieces called data blocks, which hold the actual data for the file.
Managing Files from More Than One Directory Each partition holds a single file system and has a set of unique inode numbers for that partition. The inode contains the whole of a file, including its descriptive characteristics and the addresses of the blocks where the file data resides.
Moving and Removing Directories and their Contents  Renaming a directory only changes the name of the directory, the inode number and its location remains unchanged. A directory can also be moved from a different location in the hierarchal file structure without affecting the child contents of the directory.
The “rmdir” command is used for removing an empty directory. The “–r” option instructs the rm command to recursively remove file. Moving and Removing Directories and their Contents
Summary  Files reside in one or more data blocks on the hard drive. Each file in a directory is assigned a unique inode. A directory is a special kind of file with very specific contents, namely the names of files and directories, each with its associated inode number. The passwd file holds the location of a user’s home directory.
Summary  The mkdir command is used for creating remote directories. The tilde (~) is interpreted as the user’s home directory. The name .. (dot-dot) is interpreted as the parent directory. The “rm –r dirname” command recursively removes the contents of the directory specified.

More Related Content

What's hot (20)

PDF
Unix command line concepts
Artem Nagornyi
 
PPT
intro unix/linux 03
duquoi
 
PPT
03 browsing the filesystem
Shay Cohen
 
PPT
Karkha unix shell scritping
chockit88
 
PDF
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
vtunotesbysree
 
PDF
Command
somoloye
 
PDF
Unix commands in etl testing
Garuda Trainings
 
TXT
An a z index of the bash commands
Ben Pope
 
DOCX
Perintah dasar terminal kali linux
Faizalguswanda
 
DOC
Unix Basics For Testers
nitin lakhanpal
 
DOCX
Files nts
kalyani66
 
PDF
Windows command prompt a to z
Subuh Kurniawan
 
PPT
Basic Linux day 2
Saikumar Daram
 
PDF
Basic unix commands_1
thakor bharati
 
PPT
Lession1 Linux Preview
leminhvuong
 
PDF
Bozorgmeh os lab
FS Karimi
 
PDF
Tool Development 08 - Windows Command Prompt
Nick Pruehs
 
PPTX
Commands and shell programming (3)
christ university
 
ODP
Linux Introduction (Commands)
anandvaidya
 
Unix command line concepts
Artem Nagornyi
 
intro unix/linux 03
duquoi
 
03 browsing the filesystem
Shay Cohen
 
Karkha unix shell scritping
chockit88
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
vtunotesbysree
 
Command
somoloye
 
Unix commands in etl testing
Garuda Trainings
 
An a z index of the bash commands
Ben Pope
 
Perintah dasar terminal kali linux
Faizalguswanda
 
Unix Basics For Testers
nitin lakhanpal
 
Files nts
kalyani66
 
Windows command prompt a to z
Subuh Kurniawan
 
Basic Linux day 2
Saikumar Daram
 
Basic unix commands_1
thakor bharati
 
Lession1 Linux Preview
leminhvuong
 
Bozorgmeh os lab
FS Karimi
 
Tool Development 08 - Windows Command Prompt
Nick Pruehs
 
Commands and shell programming (3)
christ university
 
Linux Introduction (Commands)
anandvaidya
 

Similar to intro unix/linux 07 (20)

PDF
Command Line Tools
David Harris
 
PDF
Linux_Ch2 Lecture (1).pdf
AllinOne746595
 
PDF
linux commands.pdf
amitkamble79
 
PPTX
An Introduction to Linux
Dimas Prasetyo
 
PPTX
Directory Management in Unix
Vpmv
 
PPT
8.1.intro unix
southees
 
PDF
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
PPTX
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
pssafvan97
 
PPTX
Linux Command.pptx
SaileshB5
 
PDF
Unit3 browsing the filesystem
root_fibo
 
PDF
Basics of UNIX Commands
Subra Das
 
PPT
2.Utilities.ppt
SupunAsanga2
 
PDF
Linux Administration in 10 Minutes
ajones_mannix
 
PPT
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS
 
PDF
Lecture1 2 intro-unix
nghoanganh
 
PDF
Unix primer
dummy
 
PPTX
Chapter 2 Linux File System and net.pptx
alehegn9
 
PPT
LinuxLabBasics.ppt
CharuJain396881
 
PPT
101 3.3 perform basic file management
Acácio Oliveira
 
Command Line Tools
David Harris
 
Linux_Ch2 Lecture (1).pdf
AllinOne746595
 
linux commands.pdf
amitkamble79
 
An Introduction to Linux
Dimas Prasetyo
 
Directory Management in Unix
Vpmv
 
8.1.intro unix
southees
 
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
pssafvan97
 
Linux Command.pptx
SaileshB5
 
Unit3 browsing the filesystem
root_fibo
 
Basics of UNIX Commands
Subra Das
 
2.Utilities.ppt
SupunAsanga2
 
Linux Administration in 10 Minutes
ajones_mannix
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS
 
Lecture1 2 intro-unix
nghoanganh
 
Unix primer
dummy
 
Chapter 2 Linux File System and net.pptx
alehegn9
 
LinuxLabBasics.ppt
CharuJain396881
 
101 3.3 perform basic file management
Acácio Oliveira
 
Ad

More from duquoi (9)

PDF
Troubleshooting CD Burning
duquoi
 
PDF
Advanced Bash Scripting Guide 2002
duquoi
 
PDF
Astrolog: Switches
duquoi
 
PDF
Cinelerra Video Editing Manual
duquoi
 
PDF
Iptables
duquoi
 
PDF
Ffmpeg
duquoi
 
ODP
rosegarden
duquoi
 
PPT
intro unix/linux 12
duquoi
 
PPT
intro unix/linux 01
duquoi
 
Troubleshooting CD Burning
duquoi
 
Advanced Bash Scripting Guide 2002
duquoi
 
Astrolog: Switches
duquoi
 
Cinelerra Video Editing Manual
duquoi
 
Iptables
duquoi
 
Ffmpeg
duquoi
 
rosegarden
duquoi
 
intro unix/linux 12
duquoi
 
intro unix/linux 01
duquoi
 
Ad

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Python basic programing language for automation
DanialHabibi2
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 

intro unix/linux 07

  • 1. Lesson 7-Creating and Changing Directories
  • 2. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files in directories. Accessing files in remote directories. Managing files from more than one directory. Moving and removing directories and their contents.
  • 3. Using Directories to Create Order A file is a collection of information stored electronically on the hard drive of a system. An inode contains all the information about each file, including the location of the actual file on the disk.
  • 4. Using Directories to Create Order The home directory. Listing files in a directory. Working with directories. Distinguishing between files and directories. Obtaining information about a directory or its contents.
  • 5. The Home Directory The “pwd” command displays the path from root to the user’s home directory. The /etc/passwd file holds the user’s home directory path. A file is created and listed in the current home directory by default.
  • 6. Listing Files in a Directory The “ls” command reads the names of the files listed in the current directory, and then outputs those names. Each file in the directory contains only the name of that file and a number that leads to the inode for that file. The “–i” option instructs ls to include the inodes in its output. Inodes are small pieces of memory created on the hard disk when it is formatted.
  • 7. Listing Files in a Directory The inode has a list of addresses of the block on the disk where the data that comprise the file is actually located. It addresses up to 13 data blocks on the hard drive. The first ten blocks addressed from the inode contains the actual file data. If a file is too large, additional blocks are allocated to fit the data.
  • 8. Working with Directories The “mkdir” command is used for creating a new directory. Directories created in uppercase are listed first by the ls command. Each new directory created is called a subdirectory. The “cd” or “change directory” command instructs the shell to locate the directory listed as an argument.
  • 9. Working with Directories The “pwd” command outputs the absolute path from the top of the file system (root or /) to the current directory. A path is a list of directory names separated by the / (slash) character. The topmost directory is called the root and is symbolized by the first forward slash (/) in the pathname.
  • 10. Working with Directories The vi editor can be used for creating a file within a directory or subdirectory. The cd command, without any directory name as an argument, returns to the home directory. The “–R” (recursive) option used with ls descends through each subdirectory in the directory tree.
  • 11. Distinguishing between Files and Directories The “ls –F” command displays directory names with a slash appended at the end. Filenames displayed with an asterisk (*) at the end are executable files. The “–C” option to ls instructs ls to make several columns in the output instead of one.
  • 12. Obtaining Information About a Directory or its Contents The “ls –l” command displays the permissions and owners of files listed in a directory. The “–d” option with ls command returns a listing of information about the contents of the target directory. The “ls –ld” displays the permissions of the directory, and not the information about the files.
  • 13. Managing Files in Directories Moving or copying files into a subdirectory. Accessing a file in a subdirectory. Avoiding mistakes when moving files into directories. Renaming files. Removing files from subdirectories.
  • 14. Moving or Copying Files into a Subdirectory Moving a file or directory does not move the file electronically. The name and the inode number are erased from the current directory and are written in the subdirectory.
  • 15. Moving or Copying Files into a Subdirectory When a file is copied, a second electronic version is created. The copied file does not have the same inode number as the original. The copied file has its own inode, permission, and data blocks containing the new files actual contents.
  • 16. Accessing a File in a Subdirectory To access a file in a subdirectory: Locate the inode number of the file. Check the permissions on the directory. Get the directory’s address from the inode. Identify the inode associated with the file. Read the files from the data blocks.
  • 17. Avoiding Mistakes When Moving Files into Directories The mv utility takes two arguments. The first argument is the name of an existing file. The second argument is a new name assigned to existing file, unless the second argument is a directory. A slash at the end of the second argument interprets the argument as a directory name.
  • 18. Renaming Files The command to move a file listing from the current directory to a new directory and also to change its filename is mv filename subdirectory/newfilename. Moving a file just moves its listing from one directory to another.
  • 19. Removing Files from Subdirectories The “rm” command can be used for removing files form a directory or subdirectory. After the rm command, the entry of the file is removed, and the data blocks listed in the inode for that file are released.
  • 20. Using Pathnames to Manage Files in Directories Accessing or creating a subdirectory. Using pathnames with utilities. Copying files into other directories using paths. Using parent directory names. Copying and moving multiple files to subdirectories. Examining the full path from root to directories and files.
  • 21. Using Pathnames to Manage Files in Directories Explicitly accessing a user’s home directory. Including other users’ logins in directory paths. Returning to the previous directory.
  • 22. Accessing or Creating a Subdirectory Providing a full path to the cd command without any spaces can access a subdirectory. Pathnames are the mechanism used to tell the shell what path to follow to access a file or directory not listed in the current directory. Remote directories can also be created by specifying the relative or absolute pathname.
  • 23. Using Pathnames with Utilities Pathnames can also be used as arguments to utilities. A relative path can be specified for accessing a file without changing the current directory.
  • 24. Copying Files into Other Directories Using Paths Pathnames are particularly useful with the “cp” and “mv” commands. Any command that takes a filename or directory name as an argument can be given an explicit pathname argument.
  • 25. Using Parent Directory Names A single dot is used for referring to the current directory. In a directory, the .. (dot-dot) is the listing for its parent directory. The parent directory is the directory located one level above the current directory.
  • 26. Using Parent Directory Names The parent directory lists the current directory’s name and inode. The . and .. are the two listings that get created when a new directory is created.
  • 27. Copying and Moving Multiple Files to Subdirectories The move and copy commands are usually used with only two arguments. The cp utility displays a usage error message when more than two arguments are specified and the last argument is not a directory. In the cp command, if the third argument specified is a directory, then the rest of the file arguments are copied into the destination subdirectory.
  • 28. Copying and Moving Multiple Files to Subdirectories The mv and cp commands can affect multiple files when the last argument is a directory. The .. (dot-dot) listing can be used in the mv command for moving files into the parent directory.
  • 29. Examining the Full Path from Root to Directories and Files A user can specify a directory’s location with the full path from the top of the file system. The full path starting at root identifies a file explicitly. The pathname for every file describes a particular file uniquely and absolutely. The full pathname to a file is called its absolute pathname.
  • 30. Explicitly Accessing a User’s Home Directory The “ls ~” command lists all filenames listed in the home directory. The C shell and all shells define the tilde (~) as the path to the user’s home directory. The shell replaces the tilde (~) with the value of the path to the user’s home directory. The shell replaces the tilde (~) in any command line with the absolute path from root to the user’s home directory.
  • 31. Including Other Users’ Logins in Directory Paths The “echo ~root” option displays the path to the home directory of the user root. The contents of the home directory of a user are displayed if the user has appropriate permissions.
  • 32. Returning to the Previous Directory The bash and ksh shells maintain the previous directory path as the value of a variable. The tcsh shell maintains a list of previous directories in a list that can be accessed. The value of the variable PWD is the path to the current directory.
  • 33. Returning to the Previous Directory An alternative way of specifying the previous directory on many bash and ksh shells is to do it with a dash argument. The exit command can be used for exiting from a child bash or ksh to the login shell. The “popd” command instructs the shell to move the directory currently on the top of the list of directories that are added to the list.
  • 34. Accessing Files in Remote Directories A filename that includes no relative path defaults to the current directory. The ./ is the default relative path that is used. Every file on the system has a unique pathname from / (root).
  • 35. Accessing Files in Remote Directories The “pwd” command displays the absolute path of the present directory. A path always starts at root (/) and includes the appropriate subdirectories.
  • 36. Managing Files from More Than One Directory A listing for a file in a directory is a link to the file. The ls –l command at the start lists the number of data blocks used by files and directories in the current directory. In a long listing entry, or record, the information for each file or directory is divided into seven fields. The second field in each entry of a file indicates the number of directories where the object is listed.
  • 37. Managing Files from More Than One Directory Linking files: The “ln” command can be used for linking a file to the current directory. The index card of each file keeps track of the number of directories that list it. Each instance of the file listed in a directory is one link. Removing a file removes it from the directory listing.
  • 38. Managing Files from More Than One Directory Linking files (continued): The ln utility can be used to link multiple files at a time. The “ls –il” command lists the current files with link count and inodes. The “–s” option to ln creates a file in the current directory that contains information required to locate the linked file.
  • 39. Managing Files from More Than One Directory Using symbolic links: A symbolic link is a small file in a directory on one file system partition that points to the correct file system and the correct inode for the linked file. In the long listing of the symbolic link, the initial character is an “l” for directories and files. An arrow and path at the end of the listing displays the actual directory where the link points.
  • 40. Managing Files from More Than One Directory Using symbolic links (continued): The ln utility provides a “–d” option for the root user to create hard links to directories. Ordinary users cannot create directory hard links. Ordinary users can create symbolic links to directories.
  • 41. Managing Files from More Than One Directory The administrator can divide the hard drive into partitions for installing the system. The partition labeled / holds the core of the hierarchal directory tree. A partition is further divided into small pieces called data blocks, which hold the actual data for the file.
  • 42. Managing Files from More Than One Directory Each partition holds a single file system and has a set of unique inode numbers for that partition. The inode contains the whole of a file, including its descriptive characteristics and the addresses of the blocks where the file data resides.
  • 43. Moving and Removing Directories and their Contents Renaming a directory only changes the name of the directory, the inode number and its location remains unchanged. A directory can also be moved from a different location in the hierarchal file structure without affecting the child contents of the directory.
  • 44. The “rmdir” command is used for removing an empty directory. The “–r” option instructs the rm command to recursively remove file. Moving and Removing Directories and their Contents
  • 45. Summary Files reside in one or more data blocks on the hard drive. Each file in a directory is assigned a unique inode. A directory is a special kind of file with very specific contents, namely the names of files and directories, each with its associated inode number. The passwd file holds the location of a user’s home directory.
  • 46. Summary The mkdir command is used for creating remote directories. The tilde (~) is interpreted as the user’s home directory. The name .. (dot-dot) is interpreted as the parent directory. The “rm –r dirname” command recursively removes the contents of the directory specified.