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.
Ad

Recommended

intro unix/linux 11
intro unix/linux 11
duquoi
 
intro unix/linux 09
intro unix/linux 09
duquoi
 
intro unix/linux 02
intro unix/linux 02
duquoi
 
intro unix/linux 08
intro unix/linux 08
duquoi
 
intro unix/linux 06
intro unix/linux 06
duquoi
 
intro unix/linux 05
intro unix/linux 05
duquoi
 
intro unix/linux 10
intro unix/linux 10
duquoi
 
intro unix/linux 04
intro unix/linux 04
duquoi
 
Unix command line concepts
Unix command line concepts
Artem Nagornyi
 
intro unix/linux 03
intro unix/linux 03
duquoi
 
03 browsing the filesystem
03 browsing the filesystem
Shay Cohen
 
Karkha unix shell scritping
Karkha unix shell scritping
chockit88
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
vtunotesbysree
 
Command
Command
somoloye
 
Unix commands in etl testing
Unix commands in etl testing
Garuda Trainings
 
Unix
Unix
Thesis Scientist Private Limited
 
An a z index of the bash commands
An a z index of the bash commands
Ben Pope
 
Perintah dasar terminal kali linux
Perintah dasar terminal kali linux
Faizalguswanda
 
Unix Basics For Testers
Unix Basics For Testers
nitin lakhanpal
 
Files nts
Files nts
kalyani66
 
Windows command prompt a to z
Windows command prompt a to z
Subuh Kurniawan
 
Basic Linux day 2
Basic Linux day 2
Saikumar Daram
 
Basic unix commands_1
Basic unix commands_1
thakor bharati
 
Lession1 Linux Preview
Lession1 Linux Preview
leminhvuong
 
Bozorgmeh os lab
Bozorgmeh os lab
FS Karimi
 
Tool Development 08 - Windows Command Prompt
Tool Development 08 - Windows Command Prompt
Nick Pruehs
 
Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Linux Introduction (Commands)
Linux Introduction (Commands)
anandvaidya
 
Chapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptx
alehegn9
 
Basic linux commands
Basic linux commands
Dheeraj Nambiar
 

More Related Content

What's hot (20)

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

Similar to intro unix/linux 07 (20)

Chapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptx
alehegn9
 
Basic linux commands
Basic linux commands
Dheeraj Nambiar
 
Introduction to linux2
Introduction to linux2
Gourav Varma
 
Unit3 browsing the filesystem
Unit3 browsing the filesystem
root_fibo
 
Linux file system nevigation
Linux file system nevigation
hetaldobariya
 
Module 5_Reading and Writing Files.pptx.
Module 5_Reading and Writing Files.pptx.
ManjuManjunath70
 
linux-file-system01.ppt
linux-file-system01.ppt
MeesanRaza
 
Linux[122-150].pdf
Linux[122-150].pdf
ZINEBAGOURRAM1
 
Linux_Ch2 Lecture (1).pdf
Linux_Ch2 Lecture (1).pdf
AllinOne746595
 
Introduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
Linux day 2.ppt
Linux day 2.ppt
Kalkey
 
LinuxLabBasics.ppt
LinuxLabBasics.ppt
CharuJain396881
 
Linux ppt
Linux ppt
Sanmuga Nathan
 
Introduction to linux day1
Introduction to linux day1
UtpalenduChakrobortt1
 
linux commands.pdf
linux commands.pdf
amitkamble79
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1
solgenomics
 
Basics of UNIX Commands
Basics of UNIX Commands
Subra Das
 
managing-the-linux-file-system_suse_.ppt
managing-the-linux-file-system_suse_.ppt
submarinoaguadulce1
 
managing-the-linux-file-system________________________
managing-the-linux-file-system________________________
saurabhbquest
 
Files and Directories in PHP
Files and Directories in PHP
Nicole Ryan
 
Chapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptx
alehegn9
 
Introduction to linux2
Introduction to linux2
Gourav Varma
 
Unit3 browsing the filesystem
Unit3 browsing the filesystem
root_fibo
 
Linux file system nevigation
Linux file system nevigation
hetaldobariya
 
Module 5_Reading and Writing Files.pptx.
Module 5_Reading and Writing Files.pptx.
ManjuManjunath70
 
linux-file-system01.ppt
linux-file-system01.ppt
MeesanRaza
 
Linux_Ch2 Lecture (1).pdf
Linux_Ch2 Lecture (1).pdf
AllinOne746595
 
Introduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
Linux day 2.ppt
Linux day 2.ppt
Kalkey
 
linux commands.pdf
linux commands.pdf
amitkamble79
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1
solgenomics
 
Basics of UNIX Commands
Basics of UNIX Commands
Subra Das
 
managing-the-linux-file-system_suse_.ppt
managing-the-linux-file-system_suse_.ppt
submarinoaguadulce1
 
managing-the-linux-file-system________________________
managing-the-linux-file-system________________________
saurabhbquest
 
Files and Directories in PHP
Files and Directories in PHP
Nicole Ryan
 
Ad

More from duquoi (9)

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

Recently uploaded (20)

Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 

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.