BONUS: learn directory relationships
This exercise shows directories (folders) and files on my computer and how they are related. Everything that happens on the computer ends up in a file in a directory.
preview
I use these commands in the chapter to build each part of the tree below step by step, to see how files and folders are related.
ls to show what is in directories
tree to show the relationships between directories
rm to remove directories
doe
├── a_file_in_doe
├── .a_hidden_file_in_doe
├── .a_hidden_folder_in_doe
├── aka_grandparent_of_lil
├── aka_grandparent_of_mary
├── aka_parent_of_jane
├── aka_parent_of_john
├── jane
│ ├── .a_hidden_file_in_jane
│ ├── .a_hidden_folder_in_jane
│ ├── aka_aunt_of_lil
│ ├── aka_jane_doe
│ ├── aka_parent_of_mary
│ ├── aka_sibling_of_john
│ ├── child_of_doe
│ └── mary
│ ├── .a_hidden_file_in_mary
│ ├── .a_hidden_folder_in_mary
│ ├── aka_mary_jane_doe
│ ├── child_of_jane
│ ├── child_of_sibling_of_john
│ ├── cousin_of_lil
│ └── grandchild_of_doe
└── john
├── .a_hidden_file_in_john
├── .a_hidden_folder_in_john
├── aka_john_doe
├── aka_parent_of_lil
├── aka_sibling_of_jane
├── aka_uncle_of_mary
├── child_of_doe
└── lil
├── .a_hidden_file_in_lil
├── .a_hidden_folder_in_lil
├── aka_lil_john_doe
├── child_of_john
├── child_of_sibling_of_jane
├── cousin_of_mary
└── grandchild_of_doe
10 directories, 30 files
Remove-Item to remove directories
C:.\...\PUMPING_PYTHON\DOE
│ .a_hidden_file_in_doe
│ aka_grandparent_of_lil
│ aka_grandparent_of_mary
│ aka_parent_of_jane
│ aka_parent_of_john
│ a_file_in_doe
│
├── .a_hidden_folder_in_doe
├── jane
│ │ .a_hidden_file_in_jane
│ │ aka_aunt_of_lil
│ │ aka_jane_doe
│ │ aka_parent_of_mary
│ │ aka_sibling_of_john
│ │ child_of_doe
│ │
│ ├── .a_hidden_folder_in_jane
│ └── mary
│ │ .a_hidden_file_in_mary
│ │ aka_mary_jane_doe
│ │ child_of_jane
│ │ child_of_sibling_of_john
│ │ cousin_of_lil
│ │ grandchild_of_doe
│ │
│ └── .a_hidden_folder_in_mary
└── john
│ .a_hidden_file_in_john
│ aka_john_doe
│ aka_parent_of_lil
│ aka_sibling_of_jane
│ aka_uncle_of_mary
│ child_of_doe
│
├── .a_hidden_folder_in_john
└── lil
│ .a_hidden_file_in_lil
│ aka_lil_john_doe
│ child_of_john
│ child_of_sibling_of_jane
│ cousin_of_mary
│ grandchild_of_doe
│
└── .a_hidden_folder_in_lil
questions about directory relationships
There are answers to these questions in this chapter
what is a folder?
A folder (directory) is a box for files, it can also have other folders (directories). It helps keep things that should be together, in one place, the same way a folder in a file cabinet keeps files that should be together in one place.
I keep every project I work on in its own directory. All the code in this book is kept in a folder named pumping_python.
what is a file?
A file is a collection or container for text, like paper we write or print on and keep in a folder. Everything that happens on the computer ends up in files. The name of a file can end with an extension to show what type of file it is. For example
.pyfor a Python module.txtfor a plain text file.shfor a bash file.ps1for a PowerShell file.docfor a Word Document.xlsfor an Excel Spreadsheet.htmlfor a HyperText Markup Language file.jsonfor a JavaScript Object Notation file.mdfor a Markdown file
note
The code I type is
highlightedand comes after something likeI type this in the terminalThe result of the code I type after I press enter/return on the keyboard comes after something like
the terminal shows ...if you get a different result from what I promise then one of two things happened
I made a mistake or
You made a mistake
To make sure it is my mistake check that you typed the same thing I typed. If you still have a different result after you check, email jacobitegboje@gmail.com or text 1-469-751-7595 with the error
commands are given to the computer with space between arguments or options, for example
command argument command --option command argument_1 argument_2 ... argument_N command --option_1 --option_2 ... --option_N command argument --option command --optionNote
the space is important, it is how the computer knows what command you mean and what arguments or options you are giving, for example
commandargument_1 argument_2tells the computer to run a command named
commandargument_1withargument_2as the argument, whilecommand argument_1 argument_2tells the computer to run a command named
commandwithargument_1andargument_2as the argumentsoptions for commands sometimes have a long and short form, for example
--long_optioncould have-las the short option, which means I can put many short options together like thiscommand -abcdwhere
a,b,canddare different options
if you have Windows without Windows Subsystem for Linux, some of the commands and terminal output will be different, click on the tab where it shows no WSL, for example
You clicked on WSL/Linux/Mac
You clicked on no WSL
requirements
I type this in a terminal to make sure the tree program is installed
treeIf it is not installed on the computer, the terminal is my friend, and shows
tree: command not foundsee how to install tree to install tree
If it is installed and there is nothing in the directory, the terminal is my friend, and shows
. 0 directories, 0 filesIf it is installed and there is something in the directory, the terminal is my friend, and shows how they are related.
I type tree
Folder PATH listing
Volume serial number is ABCD:EFGH
C:.
No subfolders exist
The tree program shows how files and folders on a computer are related, this helps to know how to go from one folder to another, because it shows the way I can go.
It is easier to go where I want, if I know where I am.
how to install tree
how to install tree on Linux/Windows Subsystem for Linux
Attention
Do this only if you are using Linux or Windows Subsystem for Linux and tree is not installed.
sudo apt update
I always do a full upgrade (you do not have to)
sudo apt full-upgrade --yes
type this in the terminal to install tree
sudo apt install tree
how to install tree on Windows without Windows Subsystem for Linux
Attention
Do this only if you are using Windows and could not install Windows Subsystem for Linux
no need to install tree because it comes with Windows.
Click on the tab that says no WSL to see the commands or results if you have Windows without Windows Subsystem for Linux. These are the commands I use
treefortree -dto show only directoriesdiror Get-ChildItem orlsforls --all/-aRemove-Item for rm
when you type pwd or tree, the terminal is my friend, and shows \ between folder names, not /. Click the no WSL tab for an example
.../pumping_python/doe
Path
----
C:\...\pumping_python\doe
Your tree will also look different because of different ways of drawing and sorting.
how to install tree on Mac OS
type this in the terminal to install tree
brew install tree
how to see what directory I am in
I start with a check of where I am in the terminal because It is easier to go where I want, if I know where I am. I can do this with the pwd program
pwd
the terminal is my friend, and shows
.../pumping_python
Path
----
C:\...\pumping_python
if I am in the pumping_python folder
pwd means
print working directory, it prints the path/address of the directory I am in, to the terminal
Note
If you see
pumping_pythonwhen you typepwd, click here to make ‘doe’If you see a different name, go to the next step - how to change directory
how to change directory
I use the cd program to change directories
cd pumping_python
cd means change directory
the terminal is my friend, and shows
cd: no such file or directory: pumping_python
Set-Location: Cannot find path
'C:\...\pumping_python'
because it does not exist
this means the folder I want to go to is not in the folder where I am.
how to make a directory
I use the mkdir program to make a folder (directory)
mkdir pumping_pythonmkdirmeansmake directorythe terminal is my friend, and shows
.../pumping_pythonDirectory: C:\... Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PM pumping_python
I use cd to change directory to
pumping_pythoncd pumping_pythonthe terminal shows I am in the
pumping_pythonfolder (directory).../pumping_pythonPath ---- C:\...\pumping_pythonTip
I open the
pumping_pythonfolder to make sure I can see it in my Integrated Development Environment (IDE). Here is how to do that with Visual Studio Code from the terminalcode .A new Visual Studio Code window opens in the
pumping_pythondirectoryI close the window I had before the new window to work only in the new window.
I open another terminal to continue
I want to work in a directory named
doe, I try to change directory todoecd doethe terminal is my friend, and shows
cd: no such file or directory: doeSet-Location: Cannot find path 'C:\...\pumping_python\doe' because it does not existdoeis not in thepumping_pythondirectory, yetI use mkdir to make
doemkdir doethe terminal is my friend, and shows
.../pumping_pythonDirectory: C:\... Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PMI change directory to
doecd doethe terminal is my friend, and shows
.../pumping_python/doeI am in the
doefolder I just madeI use pwd to see where I am
pwdthe terminal is my friend, and shows
.../pumping_python/doePath ---- C:\...\pumping_python\doe
It is easier to go where I want, if I know where I am.
how to see what is in a directory
I can use ls to see what is in a directory and see more information about the files and folders in it
lsI try to change directory to
.cd .the terminal is my friend, and shows
.../pumping_python/doeI try cd with
..cd ..the terminal is my friend, and shows
.../pumping_pythonI am back in the
pumping_pythondirectory..is for the parent of the directory I am in..ispumping_pythonwhen I am indoepumping_pythonis the parent ofdoeI can change directory from the directory I am in to its parent with
cd ..
how to look at directory relationships
I use cd to go back to
doecd doethe terminal is my friend, and shows
.../pumping_python/doeI can use the tree program to see the files and folders in a directory and how they are related. I type it in the terminal to see what is in the
doedirectorytreethe terminal is my friend, and shows
. 0 directories, 0 filesFolder PATH listing Volume serial number is ABCD:EFGH C:. No subfolders existthere is nothing in
doe, it is emptyI try to change directory to
janecd janethe terminal is my friend, and shows
cd: no such file or directory: janeSet-Location: Cannot find path 'C:\...\pumping_python\doe\jane' because it does not existjaneis not a child ofdoe, yetI use mkdir to make
janemkdir janethe terminal goes back to the command line
I use ls to see what is now in
doelsthe terminal is my friend, and shows
janeI use tree to show what is in
doetreethe terminal is my friend, and shows
. └── jane 2 directories, 0 filesC:. └── janejaneis a child ofdoe.is the working directory, which isdoein this casethe line in the tree that goes from
.tojaneshows I can go fromdoeright tojane
I change directory to
janecd janethe terminal is my friend, and shows
.../pumping_python/doe/janeI am in
janeI change directory to
doecd doethe terminal is my friend, and shows
cd: no such file or directory: doedoeis not a child ofjaneI cannot go from
janetodoethis way
I change directory back to the parent of
janecd ..the terminal shows
.../pumping_python/doeI am back in
doe..is for the parent of the directory I am inI can change directory from the directory I am in to its parent with
cd ....isdoewhen I am injane
I try to change directory to
johncd johnthe terminal is my friend, and shows
cd: no such file or directory: johnSet-Location: Cannot find path 'C:\...\pumping_python\doe\john' because it does not existjohnis not a child ofdoe, yetI use mkdir to make
johnmkdir johnthe terminal goes back to the command line
I use ls to see what is in
doelsthe terminal is my friend, and shows
jane johnI use tree to show the folders inside
doetreethe terminal is my friend, and shows
. ├── jane └── john 3 directories, 0 filesjohnis a child ofdoe.is the working directory, which isdoein this casethe line in the tree that goes from
.tojohnshows I can go fromdoeright tojohn
I change directory to
johncd johnthe terminal is my friend, and shows
.../pumping_python/doe/johnI am in
johnI change directory to
doecd doethe terminal is my friend, and shows
cd: no such file or directory: doedoeis not a child ofjohnI cannot go from
johntodoethis way
I change directory back to the parent of
johncd ..the terminal shows
.../pumping_python/doeI am back in
doe..is for the parent of the directory I am inI can change directory from the directory I am in to its parent with
cd ....isdoewhen I am injohn
I change directory to a hidden folder in
doecd .a_hidden_folder_in_doethe terminal is my friend, and shows
cd: no such file or directory: .a_hidden_folder_in_doe.a_hidden_folder_in_doeis not indoe, yetI use mkdir to make
.a_hidden_folder_in_doemkdir .a_hidden_folder_in_doethe terminal goes back to the command line
I use ls to see what is in
doelsthe terminal is my friend, and shows
jane johnMode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PM .a_hidden_folder_in_doe d----- MM/DD/YYYY HH:MM A/PM jane d----- MM/DD/YYYY HH:MM A/PM john.a_hidden_folder_in_doeis not hidden on Windows without Windows Subsystem for LinuxI use tree to show the folders inside
doetreethe terminal is my friend, and shows
. ├── jane └── john 3 directories, 0 filesI can also use tree with the
-aoption to show things that are hiddentree -athe terminal is my friend, and shows
. ├── .a_hidden_folder_in_doe ├── jane └── john 4 directories, 0 files.is the working directory, which isdoein this casethe line in the tree that goes from
.to.a_hidden_folder_in_doeshows I can go fromdoeright to.a_hidden_folder_in_doe
C:. ├── .a_hidden_folder_in_doe ├── jane └── john.a_hidden_folder_in_doeis not hidden on Windows without Windows Subsystem for LinuxI change directory to
.a_hidden_folder_in_doecd .a_hidden_folder_in_doethe terminal is my friend, and shows
.../pumping_python/doe/.a_hidden_folder_in_doeI am in
.a_hidden_folder_in_doeI change directory to
doecd doethe terminal is my friend, and shows
cd: no such file or directory: doeSet-Location: Cannot find path `C:\...\pumping_python\doe\john\lil\doe` because it does not existdoeis not a child of.a_hidden_folder_in_doeI cannot go from
.a_hidden_folder_in_doetodoethis way
I change directory back to the parent of
.a_hidden_folder_in_doecd ..the terminal shows
.../pumping_python/doeI am back in
doe..is for the parent of the directory I am inI can change directory from the directory I am in to its parent with
cd ....isdoewhen I am in.a_hidden_folder_in_doe
I change directory to
janecd janethe terminal is my friend, and shows
.../pumping_python/doe/janeI use ls to show what is in
janelsjanehas no childrenI use tree
treethe terminal is my friend, and shows
. 0 directories, 0 filesjanehas no childrenI change directory to
marycd marythe terminal is my friend, and shows
cd: no such file or directory: maryjanehas no children, yetI use mkdir to make
marymkdir marythe terminal goes back to the command line
I try to change directory to
maryagaincd marythe terminal is my friend, and shows
.../doe/jane/maryI am in the
maryfoldermaryis a child ofjanejaneis a child ofdoe
I change directory to
janecd janethe terminal is my friend, and shows
cd: no such file or directory: janejaneis not a child ofmaryI cannot go from
marytojanethis way
I go up a level to the parent of
marycd ..the terminal is my friend, and shows
.../doe/janeI am back in
janeI change directory to a hidden folder in
janecd .a_hidden_folder_in_janethe terminal is my friend, and shows
cd: no such file or directory: .a_hidden_folder_in_janethere is no folder named
.a_hidden_folder_in_janeinjaneI make
.a_hidden_folder_in_janemkdir .a_hidden_folder_in_janethe terminal goes back to the command line
I try to change directory to
.a_hidden_folder_in_janeagaincd .a_hidden_folder_in_janethe terminal is my friend, and shows
.../doe/jane/.a_hidden_folder_in_janeI change directory to
janecd janethe terminal is my friend, and shows
cd: no such file or directory: janejaneis not a child of.a_hidden_folder_in_janeI cannot go from
.a_hidden_folder_in_janetojanethis way
I go up a level to the parent of
.a_hidden_folder_in_janecd ..the terminal is my friend, and shows
.../doe/janeI am back in
janeI use tree
treethe terminal is my friend, and shows
. └── mary 2 directories, 0 filesI use tree with the
-aoptiontree -athe terminal is my friend, and shows
. ├── .a_hidden_folder_in_jane └── mary 3 directories, 0 files.isjanewhen I am injanethe line in the tree that goes from
.tomaryshows I can go fromjaneright tomarythe line in the tree that goes from
.to.a_hidden_folder_in_janeshows I can go fromjaneright to.a_hidden_folder_in_jane
C:. ├── .a_hidden_folder_in_jane └── maryI go up a level to the parent of
janecd ..the terminal is my friend, and shows
.../pumping_python/doeI am back in
doe
I change directory to
johncd johnthe terminal is my friend, and shows
.../pumping_python/doe/johnjohnis a child ofdoeI use ls to show what is in
johnlsjohnhas no childrenI use tree
treethe terminal is my friend, and shows
. 0 directories, 0 filesjohnhas no children, yetI change directory to
lilcd lilthe terminal is my friend, and shows
cd: no such file or directory: liljohnhas no childrenI use mkdir to make
lilmkdir lilthe terminal goes back to the command line
I try to change directory to
lilagaincd lilthe terminal is my friend, and shows
.../doe/john/lilI am in the
lilfolderlilis a child ofjohnjohnis a child ofdoe
I change directory to
johncd johnthe terminal is my friend, and shows
cd: no such file or directory: johnjohnis not a child oflilI cannot go from
liltojohnthis way
I go up a level to the parent of
lilcd ..the terminal is my friend, and shows
.../doe/johnI am back in
johnI change directory to a hidden folder in
johncd .a_hidden_folder_in_johnthe terminal is my friend, and shows
cd: no such file or directory: .a_hidden_folder_in_johnthere is no folder named
.a_hidden_folder_in_johninjohnI use mkdir to make
.a_hidden_folder_in_johnmkdir .a_hidden_folder_in_johnthe terminal goes back to the command line
I try to change directory to
.a_hidden_folder_in_johnagaincd .a_hidden_folder_in_johnthe terminal is my friend, and shows
.../doe/john/.a_hidden_folder_in_johnI change directory to
johncd johnthe terminal is my friend, and shows
cd: no such file or directory: johnjohnis not a child of.a_hidden_folder_in_johnI cannot go from
.a_hidden_folder_in_johntojohnthis way
I go up a level to the parent of
.a_hidden_folder_in_johncd ..the terminal is my friend, and shows
.../doe/johnI am back in
johnI use tree
treethe terminal is my friend, and shows
. └── lil 2 directories, 0 filesI use tree with the
-aoptiontree -athe terminal is my friend, and shows
. ├── .a_hidden_folder_in_john └── lil 3 directories, 0 files.isjohnwhen I am injohnthe line in the tree that goes from
.tolilshows I can go fromjohnright tolilthe line in the tree that goes from
.to.a_hidden_folder_in_johnshows I can go fromjohnright to.a_hidden_folder_in_john
C:. ├── .a_hidden_folder_in_john └── lilI go up a level to the parent of
johncd ..the terminal is my friend, and shows
.../pumping_python/doeI am back in
doeI use tree to show the files and folders related to
doetreethe terminal is my friend, and shows
. ├── jane │ └── mary └── john └── lil 5 directories, 0 filesC:. ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_folder_in_jane │ └── mary └── john ├── .a_hidden_folder_in_john └── lilthe lines show that
I can go from
doeright to.a_hidden_folder_in_doeI can go from
doeright tojaneI can go from
doeright tojohnI can go from
janeright to.a_hidden_folder_in_janeI can go from
janeright tomaryI can go from
johnright to.a_hidden_folder_in_johnI can go from
johnright tolil
how to make an empty file
I can use the touch or New-Item program to make empty files in a folder
I use touch to make an empty file in
doetouch a_file_in_doethe terminal goes back to the command line
on Windows without Windows Subsystem for Linux
use New-Item in place of
touchNew-Item a_file_in_doeI use touch to make an empty hidden file in
doetouch .a_hidden_file_in_doeI use ls to see what is in the folder
lsthe terminal is my friend, and shows
a_file_in_doe jane johnI use ls with the
-aoptionls -athe terminal is my friend, and shows
. .. a_file_in_doe .a_hidden_file_in_doe .a_hidden_folder_in_doe jane john
I use New-Item to make an empty file in
doeNew-Item a_file_in_doethe terminal goes back to the command line
I use New-Item to make an empty hidden file in
doeNew-Item .a_hidden_file_in_doeI use ls to show what is in
doelsthe terminal is my friend, and shows
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PM .a_hidden_folder_in_doe d----- MM/DD/YYYY HH:MM A/PM jane d----- MM/DD/YYYY HH:MM A/PM john -a---- MM/DD/YYYY HH:MM A/PM 0 .a_hidden_file_in_doe -a---- MM/DD/YYYY HH:MM A/PM 0 a_file_in_doethe terminal does not show
.and..and always shows hidden folders and files on Windows without Windows Subsystem for Linux
I change directory to
janecd janethe terminal is my friend, and shows
.../pumping_python/doe/janeI use touch to make an empty file in
janetouch aka_jane_doethe terminal goes back to the command line
I use touch to make an empty hidden file in
janetouch .a_hidden_file_in_janethe terminal goes back to the command line
I use ls to show what is in
janels -athe terminal is my friend, and shows
. .. .a_hidden_file_in_jane .a_hidden_folder_in_jane aka_jane_doe mary
I use New-Item to make an empty file in
janeNew-Item aka_jane_doethe terminal goes back to the command line
I use New-Item to make an empty hidden file in
janeNew-Item .a_hidden_file_in_janethe terminal goes back to the command line
I use ls to show what is in
janelsthe terminal is my friend, and shows
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PM .a_hidden_folder_in_jane d----- MM/DD/YYYY HH:MM A/PM mary -a---- MM/DD/YYYY HH:MM A/PM 0 .a_hidden_file_in_jane -a---- MM/DD/YYYY HH:MM A/PM 0 aka_jane_doethe terminal does not show
.and..and always shows hidden folders and files on Windows without Windows Subsystem for Linux
I change directory to the parent of
janecd ..the terminal is my friend, and shows
.../pumping_python/doeI am back in
doe
I change directory to
johncd johnthe terminal is my friend, and shows
.../pumping_python/doe/johnI use touch to make an empty file in
johntouch aka_john_doethe terminal goes back to the command line
I use touch to make an empty hidden file in
johntouch .a_hidden_file_in_johnthe terminal goes back to the command line
I use ls to show what is in
johnls -athe terminal is my friend, and shows
. .. .a_hidden_file_in_john .a_hidden_folder_in_john aka_john_doe lil
I use New-Item to make an empty file in
johnNew-Item aka_john_doethe terminal goes back to the command line
I use New-Item to make an empty hidden file in
johnNew-Item .a_hidden_file_in_johnthe terminal goes back to the command line
I use ls to show what is in
johnlsthe terminal is my friend, and shows
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PM .a_hidden_folder_in_john d----- MM/DD/YYYY HH:MM A/PM lil -a---- MM/DD/YYYY HH:MM A/PM 0 .a_hidden_file_in_john -a---- MM/DD/YYYY HH:MM A/PM 0 aka_john_doethe terminal does not show
.and..and always shows hidden folders and files on Windows without Windows Subsystem for Linux
I change directory to the parent of
johncd ..the terminal is my friend, and shows
.../pumping_python/doeI am back in
doeI use tree to show the files and folders related to
doeTip
Your terminal may use colors to show the difference between directories and files
treethe terminal is my friend, and shows
. ├── a_file_in_doe ├── jane │ ├── aka_jane_doe │ └── mary └── john ├── aka_john_doe └── lil 5 directories, 3 filesI use tree with the
-aoptiontree -athe terminal is my friend, and shows
. ├── a_file_in_doe ├── .a_hidden_file_in_doe ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_file_in_jane │ ├── .a_hidden_folder_in_jane │ ├── aka_jane_doe │ └── mary └── john ├── .a_hidden_file_in_john ├── .a_hidden_folder_in_john ├── aka_john_doe └── lil 8 directories, 6 filestreethe terminal is my friend, and shows
C:. ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_folder_in_jane │ └── mary └── john ├── .a_hidden_folder_in_john └── lilI use tree with the
/Foption to show files and folderstree /Fthe terminal is my friend, and shows
C:. │ .a_hidden_file_in_doe │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_jane_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ ├── .a_hidden_folder_in_john └── lil
how to use directory relationships
I try to change directory from
doetomaryin one stepcd marythe terminal is my friend, and shows
cd: no such file or directory: maryI use tree with the
-doption to show only the directoriestree -dthe terminal is my friend, and shows
. ├── jane │ └── mary └── john └── lil 5 directories
Set-Location: Cannot find path 'C:\...\pumping_python\doe\mary' because it does not existI use tree to show only the directories
treethe terminal is my friend, and shows
C:. ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_folder_in_jane │ └── mary └── john ├── .a_hidden_folder_in_john └── lil
there is no line from
doetomarybecausemaryis not a child ofdoethere is a line from
janetomarybecausemaryis a child ofjanethere is a line from
doetojanebecausejaneis a child ofdoe
I can go from
doetojanetomaryin one step withcd jane/marythe terminal is my friend, and shows
.../doe/jane/maryI cannot go to
marywithout its parent. How do I get back todoe?I change directory to
doecd doethe terminal is my friend, and shows
cd: no such file or directory: doedoeis not a child ofmaryI cannot go from
marytodoethis way
I can go from
maryback todoein one step with..cd ../..the terminal is my friend, and shows
.../pumping_python/doeI am back in
doe..is for the parent of a directory../..is for the parent of the parent, that is a grandparent. I can use as many as I need for each parent, for example../../../..is the great great grand parent..frommaryisjane..fromjaneisdoe
I try to change directory from
doetolilin one stepcd lilthe terminal is my friend, and shows
cd: no such file or directory: lilI use tree with the
-doption to show only the directoriestree -dthe terminal is my friend, and shows
. ├── jane │ └── mary └── john └── lil 5 directories
Set-Location: Cannot find path 'C:\...\pumping_python\doe\lil' because it does not existI use tree to show only the directories
treethe terminal is my friend, and shows
C:. ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_folder_in_jane │ └── mary └── john ├── .a_hidden_folder_in_john └── lil
there is no line from
doetolilbecauselilis not a child ofdoethere is a line from
johntolilbecauselilis a child ofjohnthere is a line from
doetojohnbecausejohnis a child ofdoe
I can go from
doetojohntolilin one step withcd john/lilthe terminal is my friend, and shows
.../doe/john/lilI cannot go to
lilwithout its parent. How do I get back todoe?I change directory to
doecd doethe terminal is my friend, and shows
cd: no such file or directory: doedoeis not a child oflilI cannot go from
liltodoethis way
I can go from
lilback todoein one step with..cd ../..the terminal is my friend, and shows
.../pumping_python/doe🎶 that will bring us back to …/
doea deer, a female deer…🎶..is for the parent of a directory../..is for the parent of the parent..fromlilisjohn..fromjohnisdoe
Note
how to use touch with directory relationships
I use tree to show the files and folders related to
doetreethe terminal is my friend, and shows
. ├── a_file_in_doe ├── jane │ ├── aka_jane_doe │ └── mary └── john ├── aka_john_doe └── lil 5 directories, 3 filestree /Fthe terminal is my friend, and shows
C:. │ .a_hidden_file_in_doe │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_jane_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ ├── .a_hidden_folder_in_john └── lilI change directory to
marycd jane/marythe terminal is my friend, and shows
.../doe/jane/maryI am in
maryI use mkdir to make a hidden directory in
marymkdir .a_hidden_folder_in_marythe terminal goes back to the command line
I use ls to show what is in
maryls -athe terminal is my friend, and shows
. .. .a_hidden_file_in_mary .a_hidden_folder_in_mary aka_mary_jane_doelsTip
I can also use
dirthe terminal is my friend, and shows
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PM .a_hidden_folder_in_mary -a---- MM/DD/YYYY HH:MM A/PM 0 .a_hidden_file_in_mary -a---- MM/DD/YYYY HH:MM A/PM 0 aka_mary_jane_doeI use cd to go back to the grandparent of
marycd ../..the terminal is my friend, and shows
...pumping_python/doeI am back in
doe
I change directory to
lilcd john/lilthe terminal is my friend, and shows
.../doe/john/lilI am in
lilI use mkdir to make a hidden directory in
lilmkdir .a_hidden_folder_in_lilI use ls to show what is in
lills -athe terminal is my friend, and shows
. .. .a_hidden_file_in_lil .a_hidden_folder_in_lil aka_lil_john_doelsTip
I can also use
dirthe terminal is my friend, and shows
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- MM/DD/YYYY HH:MM A/PM .a_hidden_folder_in_lil -a---- MM/DD/YYYY HH:MM A/PM 0 .a_hidden_file_in_lil -a---- MM/DD/YYYY HH:MM A/PM 0 aka_lil_john_doeI use cd to go back to the grandparent of
lilcd ../..the terminal is my friend, and shows
...pumping_python/doeI am back in
doeI use tree to see what I have so far
treethe terminal is my friend, and shows
. ├── a_file_in_doe ├── jane │ ├── aka_jane_doe │ └── mary │ └── aka_mary_jane_doe └── john ├── aka_john_doe └── lil └── aka_lil_john_doe 5 directories, 5 filesI use tree with the
-aoptiontree -athe terminal is my friend, and shows
. ├── a_file_in_doe ├── .a_hidden_file_in_doe ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_file_in_jane │ ├── .a_hidden_folder_in_jane │ ├── aka_jane_doe │ └── mary │ ├── .a_hidden_file_in_mary │ ├── .a_hidden_folder_in_mary │ └── aka_mary_jane_doe └── john ├── .a_hidden_file_in_john ├── .a_hidden_folder_in_john ├── aka_john_doe └── lil ├── .a_hidden_file_in_lil ├── .a_hidden_folder_in_lil └── aka_lil_john_doe 10 directories, 10 filestree /Fthe terminal is my friend, and shows
C:. │ .a_hidden_file_in_doe │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_jane_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary │ │ .a_hidden_file_in_mary │ │ aka_mary_jane_doe │ │ │ └── .a_hidden_folder_in_mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ └── .a_hidden_folder_in_lil
I use touch to make an empty file in
janefrom insidedoetouch jane/child_of_doethe terminal goes back to the command line
I use touch to make an empty file in
maryfrom insidedoetouch jane/mary/grandchild_of_doethe terminal goes back to the command line
I use touch to make an empty file in
johnfrom insidedoetouch john/child_of_doethe terminal goes back to the command line
I use touch to make an empty file in
lilfrom insidedoetouch john/lil/grandchild_of_doethe terminal goes back to the command line
I use New-Item to make an empty file in
janefrom insidedoeNew-Item jane/child_of_doethe terminal goes back to the command line
I use New-Item to make an empty file in
maryfrom insidedoeNew-Item jane/mary/grandchild_of_doethe terminal goes back to the command line
I use New-Item to make an empty file in
johnfrom insidedoeNew-Item john/child_of_doethe terminal goes back to the command line
I use New-Item to make an empty file in
lilfrom insidedoeNew-Item john/lil/grandchild_of_doethe terminal goes back to the command line
I use tree to show the files and folders related to
doetreethe terminal is my friend, and shows
. ├── a_file_in_doe ├── jane │ ├── aka_jane_doe │ ├── child_of_doe │ └── mary │ ├── aka_mary_jane_doe │ └── grandchild_of_doe └── john ├── aka_john_doe ├── child_of_doe └── lil ├── aka_lil_john_doe └── grandchild_of_doe 5 directories, 9 filestree /Fthe terminal is my friend, and shows
C:. │ .a_hidden_file_in_doe │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_jane_doe │ │ child_of_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary │ │ .a_hidden_file_in_mary │ │ aka_mary_jane_doe │ │ grandchild_of_doe │ │ │ └── .a_hidden_folder_in_mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ child_of_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ grandchild_of_doe │ └── .a_hidden_folder_in_lilI change directory to
janecd janeI use touch to make an empty file in
maryfrom insidejanetouch mary/child_of_janeI use touch to make an empty file in
doefrom insidejanetouch ../aka_parent_of_janeI use touch to make an empty file in
johnfrom insidejanetouch ../john/aka_sibling_of_jane..is the parent ofjanewhich isdoejohnis a child ofdoe
I use touch to make an empty file in
lilfrom insidejanetouch ../john/lil/child_of_sibling_of_john
I use New-Item to make an empty file in
maryfrom insidejaneNew-Item mary/child_of_janeI use New-Item to make an empty file in
doefrom insidejaneNew-Item ../aka_parent_of_janeI use New-Item to make an empty file in
johnfrom insidejaneNew-Item ../john/aka_sibling_of_jane..is the parent ofjanewhich isdoejohnis a child ofdoe
I use New-Item to make an empty file in
lilfrom insidejaneNew-Item ../john/lil/child_of_sibling_of_john
..is the parent ofjanewhich isdoejohnis a child ofdoelilis a child ofjohn
I made a mistake -
child_of_sibling_of_johnshould bechild_of_sibling_of_jane
how to rename a file or directory
I can use the mv program to move a file and rename it at the same time.
I change directory to
lilcd ../john/lilI use mv to change
child_of_sibling_of_johntochild_of_sibling_of_janemv child_of_sibling_of_john \ child_of_sibling_of_janethe terminal goes back to the command line
Tip
I can also rename the file with one line from inside
janewithout cd (it is a long line)mv ../john/lil/\ child_of_sibling_of_john \ ../john/lil/\ child_of_sibling_of_jane\is a symbol that tells the computer I want to break up the line after I hit the enter/return key on the keyboard
mv means move, it takes two arguments
mv source target
sourceis the path/address I want to move the original file or folder fromtargetis the path/address I want to move the original file or folder tothis allows me to rename a file or folder in one step, the other way would be to
that is two steps too many, I leave that to the dancers, give me one step.
I use cd to go back to the grandparent of
lilcd ../..I use tree to show the files and folders related to
doetreethe terminal is my friend, and shows
. ├── a_file_in_doe ├── aka_parent_of_jane ├── jane │ ├── aka_jane_doe │ ├── child_of_doe │ └── mary │ ├── aka_mary_jane_doe │ ├── child_of_jane │ └── grandchild_of_doe └── john ├── aka_john_doe ├── aka_sibling_of_jane ├── child_of_doe └── lil ├── aka_lil_john_doe ├── child_of_sibling_of_jane └── grandchild_of_doe 5 directories, 13 filestree /Fthe terminal is my friend, and shows
C:. │ .a_hidden_file_in_doe │ aka_parent_of_jane │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_jane_doe │ │ child_of_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary │ │ .a_hidden_file_in_mary │ │ aka_mary_jane_doe │ │ child_of_jane │ │ grandchild_of_doe │ │ │ └── .a_hidden_folder_in_mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ aka_sibling_of_jane │ child_of_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ child_of_sibling_of_jane │ grandchild_of_doe │ └── .a_hidden_folder_in_lil
I change directory to
johncd johnI use touch to make an empty file in
lilfrom insidejohntouch lil/child_of_johnI use touch to make an empty file in
doefrom insidejohntouch ../aka_parent_of_johnI use touch to make an empty file in
janefrom insidejohntouch ../jane/aka_sibling_of_john..is the parent ofjohnwhich isdoejaneis a child ofdoe
I use touch to make an empty file in
maryfrom insidejohntouch ../jane/mary/child_of_sibling_of_jane
I use New-Item to make an empty file in
lilfrom insidejohnNew-Item lil/child_of_johnI use New-Item to make an empty file in
doefrom insidejohnNew-Item ../aka_parent_of_johnI use New-Item to make an empty file in
janefrom insidejohnNew-Item ../jane/aka_sibling_of_john..is the parent ofjohnwhich isdoejaneis a child ofdoe
I use New-Item to make an empty file in
maryfrom insidejohnNew-Item ../jane/mary/child_of_sibling_of_jane
..is the parent ofjohnwhich isdoejaneis a child ofdoemaryis a child ofjane
I made a mistake again -
child_of_sibling_of_janeshould bechild_of_sibling_of_johnI change directory to
marycd ../jane/maryI use mv to change
child_of_sibling_of_janetochild_of_sibling_of_johnmv child_of_sibling_of_jane \ child_of_sibling_of_johnthe terminal goes back to the command line
Tip
I can also rename the file with one line from inside
johnwithout cd (it is a long line)mv ../jane/mary/\ child_of_sibling_of_jane \ ../jane/mary/\ child_of_sibling_of_john\is the symbol that tells the computer I want to break up the line after I hit the enter/return key on the keyboardI use cd to go back to the grandparent of
lilcd ../..I use tree to show the files and folders related to
doetreethe terminal is my friend, and shows
. ├── a_file_in_doe ├── aka_parent_of_jane ├── aka_parent_of_john ├── jane │ ├── aka_jane_doe │ ├── aka_sibling_of_john │ ├── child_of_doe │ └── mary │ ├── aka_mary_jane_doe │ ├── child_of_jane │ ├── child_of_sibling_of_john │ └── grandchild_of_doe └── john ├── aka_john_doe ├── aka_sibling_of_jane ├── child_of_doe └── lil ├── aka_lil_john_doe ├── child_of_john ├── child_of_sibling_of_jane └── grandchild_of_doe 5 directories, 17 filestree /Fthe terminal is my friend, and shows
C:. │ .a_hidden_file_in_doe │ aka_parent_of_jane │ aka_parent_of_john │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_jane_doe │ │ aka_sibling_of_john │ │ child_of_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary │ │ .a_hidden_file_in_mary │ │ aka_mary_jane_doe │ │ child_of_jane │ │ child_of_sibling_of_john │ │ grandchild_of_doe │ │ │ └── .a_hidden_folder_in_mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ aka_sibling_of_jane │ child_of_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ child_of_john │ child_of_sibling_of_jane │ grandchild_of_doe │ └── .a_hidden_folder_in_lilI change directory to
marycd jane/maryI made a mistake -
aka_aunt_of_maryshould beaka_uncle_of_maryI change directory to
johncd ../../johnI use mv to change
aka_aunt_of_marytoaka_uncle_of_marymv aka_aunt_of_mary aka_uncle_of_maryI change directory back to
marycd ../jane/maryI use tree to show the files and folders related to
doefrom insidemarytree ../..the terminal is my friend, and shows
../.. ├── a_file_in_doe ├── aka_grandparent_of_mary ├── aka_parent_of_jane ├── aka_parent_of_john ├── jane │ ├── aka_jane_doe │ ├── aka_parent_of_mary │ ├── aka_sibling_of_john │ ├── child_of_doe │ └── mary │ ├── aka_mary_jane_doe │ ├── child_of_jane │ ├── child_of_sibling_of_john │ └── grandchild_of_doe └── john ├── aka_john_doe ├── aka_sibling_of_jane ├── aka_uncle_of_mary ├── child_of_doe └── lil ├── aka_lil_john_doe ├── child_of_john ├── child_of_sibling_of_jane ├── cousin_of_mary └── grandchild_of_doe 5 directories, 21 filestree ../.. /Fthe terminal is my friend, and shows
C:.\...\PUMPING_PYTHON\DOE │ .a_hidden_file_in_doe │ aka_grandparent_of_mary │ aka_parent_of_jane │ aka_parent_of_john │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_jane_doe │ │ aka_parent_of_mary │ │ aka_sibling_of_john │ │ child_of_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary │ │ .a_hidden_file_in_mary │ │ aka_mary_jane_doe │ │ child_of_jane │ │ child_of_sibling_of_john │ │ grandchild_of_doe │ │ │ └── .a_hidden_folder_in_mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ aka_sibling_of_jane │ aka_uncle_of_mary │ child_of_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ child_of_john │ child_of_sibling_of_jane │ cousin_of_mary │ grandchild_of_doe │ └── .a_hidden_folder_in_lilI change directory to
lilfrommarycd ../../john/lilthe terminal is my friend, and shows
.../doe/john/lilI use touch to make an empty file in
johnfrom insideliltouch ../aka_parent_of_lilI use touch to make an empty file in
doefrom insideliltouch ../../aka_grandparent_of_lilI use touch to make an empty file in
janefrom insideliltouch ../../jane/aka_uncle_of_lilI made another mistake -
aka_uncle_of_lilshould beaka_aunt_of_lil
I use New-Item to make an empty file in
johnfrom insidelilNew-Item ../aka_parent_of_lilI use New-Item to make an empty file in
doefrom insidelilNew-Item ../../aka_grandparent_of_lilI use New-Item to make an empty file in
janefrom insidelilNew-Item ../../jane/aka_uncle_of_lilI made another mistake -
aka_uncle_of_lilshould beaka_aunt_of_lil
I change directory to
janecd ../../janeI use mv to change
aka_uncle_of_liltoaka_aunt_of_lilmv aka_uncle_of_lil aka_aunt_of_lilI change directory back to
lilcd ../john/lilI use tree to show the files and folders related to
doefrom insidelilthrough the parent ofdoetree ../../../doethe terminal is my friend, and shows
doe ├── a_file_in_doe ├── .a_hidden_file_in_doe ├── .a_hidden_folder_in_doe ├── aka_grandparent_of_lil ├── aka_grandparent_of_mary ├── aka_parent_of_jane ├── aka_parent_of_john ├── jane │ ├── .a_hidden_file_in_jane │ ├── .a_hidden_folder_in_jane │ ├── aka_aunt_of_lil │ ├── aka_jane_doe │ ├── aka_parent_of_mary │ ├── aka_sibling_of_john │ ├── child_of_doe │ └── mary │ ├── .a_hidden_file_in_mary │ ├── .a_hidden_folder_in_mary │ ├── aka_mary_jane_doe │ ├── child_of_jane │ ├── child_of_sibling_of_john │ ├── cousin_of_lil │ └── grandchild_of_doe └── john ├── .a_hidden_file_in_john ├── .a_hidden_folder_in_john ├── aka_john_doe ├── aka_parent_of_lil ├── aka_sibling_of_jane ├── aka_uncle_of_mary ├── child_of_doe └── lil ├── .a_hidden_file_in_lil ├── .a_hidden_folder_in_lil ├── aka_lil_john_doe ├── child_of_john ├── child_of_sibling_of_jane ├── cousin_of_mary └── grandchild_of_doe 10 directories, 30 filestree ../../../doe /Fthe terminal is my friend, and shows
C:.\...\PUMPING_PYTHON\DOE │ .a_hidden_file_in_doe │ aka_grandparent_of_lil │ aka_grandparent_of_mary │ aka_parent_of_jane │ aka_parent_of_john │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_aunt_of_lil │ │ aka_jane_doe │ │ aka_parent_of_mary │ │ aka_sibling_of_john │ │ child_of_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary │ │ .a_hidden_file_in_mary │ │ aka_mary_jane_doe │ │ child_of_jane │ │ child_of_sibling_of_john │ │ cousin_of_lil │ │ grandchild_of_doe │ │ │ └── .a_hidden_folder_in_mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ aka_parent_of_lil │ aka_sibling_of_jane │ aka_uncle_of_mary │ child_of_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ child_of_john │ child_of_sibling_of_jane │ cousin_of_mary │ grandchild_of_doe │ └── .a_hidden_folder_in_lil..is for the parent oflilwhich isjohn../..is for the parent of the parent oflilwhich isdoe../../..is for the parent of the parent of the parent oflilwhich ispumping_pythondoeis a child ofpumping_python
I can add a file to any folder when I know its path or relation to where I am, if I have permission to write to the folder.
how to use ls with directory relationships
I can see what is in any folder when I know its path or relation to where I am.
I go to the parent of
doecd ../../..the terminal is my friend, and shows
.../pumping_pythonI am in
pumping_pythonI use ls to show what is in
doels -a doels doeTip
I can also use
dirdir doethe terminal is my friend, and shows
. .. a_file_in_doe .a_hidden_file_in_doe .a_hidden_folder_in_doe aka_grandparent_of_lil aka_grandparent_of_mary aka_parent_of_jane aka_parent_of_john jane johnI use ls to show what is in
janels -a doe/janels doe/janethe terminal is my friend, and shows
. .. .a_hidden_file_in_jane .a_hidden_folder_in_jane aka_aunt_of_lil aka_jane_doe aka_parent_of_mary aka_sibling_of_john child_of_doe maryI use ls to show what is in
maryls -a doe/jane/maryls doe/jane/marythe terminal is my friend, and shows
. .. .a_hidden_file_in_mary .a_hidden_folder_in_mary aka_mary_jane_doe child_of_jane child_of_sibling_of_john cousin_of_lil grandchild_of_doeI change directory to
marycd doe/jane/maryI use ls to show what is in
johnfrom insidemaryls -a ../../johnls ../../johnthe terminal is my friend, and shows
. .. .a_hidden_file_in_john .a_hidden_folder_in_john aka_john_doe aka_parent_of_lil aka_sibling_of_jane aka_uncle_of_mary child_of_doe lilI use ls to show what is in
lilfrom insidemaryls -a ../../john/lills ../../john/lilthe terminal is my friend, and shows
. .. .a_hidden_file_in_lil .a_hidden_folder_in_lil aka_lil_john_doe child_of_john child_of_sibling_of_jane cousin_of_mary grandchild_of_doe
how to use tree with directory relationships
I use tree to show what is in
liltree ../../john/lilthe terminal is my friend, and shows
../../john/lil ├── aka_lil_john_doe ├── child_of_john ├── child_of_sibling_of_jane ├── cousin_of_mary └── grandchild_of_doe 1 directory, 5 filestree ../../john/lil /Fthe terminal is my friend, and shows
C:\...\PUMPING_PYTHON\DOE\JOHN\LIL │ .a_hidden_file_in_lil │ aka_lil_john_doe │ child_of_john │ child_of_sibling_of_jane │ cousin_of_mary │ grandchild_of_doe │ └── .a_hidden_folder_in_lilI use tree to show what is in
johntree ../../johnthe terminal is my friend, and shows
../../john ├── aka_john_doe ├── aka_parent_of_lil ├── aka_sibling_of_jane ├── aka_uncle_of_mary ├── child_of_doe └── lil ├── aka_lil_john_doe ├── child_of_john ├── child_of_sibling_of_jane ├── cousin_of_mary └── grandchild_of_doe 2 directories, 10 filestree /F ../../johnthe terminal is my friend, and shows
C:\...\PUMPING_PYTHON\DOE\JOHN │ .a_hidden_file_in_john │ aka_john_doe │ aka_parent_of_lil │ aka_sibling_of_jane │ aka_uncle_of_mary │ child_of_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ child_of_john │ child_of_sibling_of_jane │ cousin_of_mary │ grandchild_of_doe │ └── .a_hidden_folder_in_lilI change directories from
marytolilcd ../../john/lilthe terminal is my friend, and shows
.../doe/john/lilI am in
lilI look at what is in
maryfrom insidelills -a ../../jane/maryls ../../jane/marythe terminal is my friend, and shows
. .. .a_hidden_file_in_mary .a_hidden_folder_in_mary aka_mary_jane_doe child_of_jane child_of_sibling_of_john cousin_of_lil grandchild_of_doeI use tree to show what is in
marytree ../../jane/marythe terminal is my friend, and shows
../../jane/mary ├── aka_mary_jane_doe ├── child_of_jane ├── child_of_sibling_of_john ├── cousin_of_lil └── grandchild_of_doe 1 directory, 5 filestree ../../jane/mary /Fthe terminal is my friend, and shows
C:\...\PUMPING_PYTHON\DOE\JANE\MARY │ .a_hidden_file_in_mary │ aka_mary_jane_doe │ child_of_jane │ child_of_sibling_of_john │ cousin_of_lil │ grandchild_of_doe │ └── .a_hidden_folder_in_maryI use tree to show what is in
janetree ../../janethe terminal is my friend, and shows
../../jane ├── aka_aunt_of_lil ├── aka_jane_doe ├── aka_parent_of_mary ├── aka_sibling_of_john ├── child_of_doe └── mary ├── aka_mary_jane_doe ├── child_of_jane ├── child_of_sibling_of_john ├── cousin_of_lil └── grandchild_of_doe 2 directories, 10 filestree /F ../../janethe terminal is my friend, and shows
C:\...\PUMPING_PYTHON\DOE\JANE │ .a_hidden_file_in_jane │ aka_aunt_of_lil │ aka_jane_doe │ aka_parent_of_mary │ aka_sibling_of_john │ child_of_doe │ ├── .a_hidden_folder_in_jane └── mary │ .a_hidden_file_in_mary │ aka_mary_jane_doe │ child_of_jane │ child_of_sibling_of_john │ cousin_of_lil │ grandchild_of_doe │ └── .a_hidden_folder_in_maryI go to the parent of
doecd ../../..the terminal is my friend, and shows
.../pumping_pythonI show all the
doefamily directoriestree doe -adthe terminal is my friend, and shows
doe ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_folder_in_jane │ └── mary │ └── .a_hidden_folder_in_mary └── john ├── .a_hidden_folder_in_john └── lil └── .a_hidden_folder_in_lil 10 directoriestree doethe terminal is my friend, and shows
C:\...\PUMPING_PYTHON\DOE ├── .a_hidden_folder_in_doe ├── jane │ ├── .a_hidden_folder_in_jane │ └── mary │ └── .a_hidden_folder_in_mary └── john ├── .a_hidden_folder_in_john └── lil └── .a_hidden_folder_in_lilI show the relationships of files and folders in
doetree -a doethe terminal is my friend, and shows
doe ├── a_file_in_doe ├── .a_hidden_file_in_doe ├── .a_hidden_folder_in_doe ├── aka_grandparent_of_lil ├── aka_grandparent_of_mary ├── aka_parent_of_jane ├── aka_parent_of_john ├── jane │ ├── .a_hidden_file_in_jane │ ├── .a_hidden_folder_in_jane │ ├── aka_aunt_of_lil │ ├── aka_jane_doe │ ├── aka_parent_of_mary │ ├── aka_sibling_of_john │ ├── child_of_doe │ └── mary │ ├── .a_hidden_file_in_mary │ ├── .a_hidden_folder_in_mary │ ├── aka_mary_jane_doe │ ├── child_of_jane │ ├── child_of_sibling_of_john │ ├── cousin_of_lil │ └── grandchild_of_doe └── john ├── .a_hidden_file_in_john ├── .a_hidden_folder_in_john ├── aka_john_doe ├── aka_parent_of_lil ├── aka_sibling_of_jane ├── aka_uncle_of_mary ├── child_of_doe └── lil ├── .a_hidden_file_in_lil ├── .a_hidden_folder_in_lil ├── aka_lil_john_doe ├── child_of_john ├── child_of_sibling_of_jane ├── cousin_of_mary └── grandchild_of_doe 10 directories, 30 filesI show the path for each file and folder in
doewith the-aand-foptionstree -af doethe terminal is my friend, and shows
doe ├── doe/a_file_in_doe ├── doe/.a_hidden_file_in_doe ├── doe/.a_hidden_folder_in_doe ├── doe/aka_grandparent_of_lil ├── doe/aka_grandparent_of_mary ├── doe/aka_parent_of_jane ├── doe/aka_parent_of_john ├── doe/jane │ ├── doe/jane/.a_hidden_file_in_jane │ ├── doe/jane/.a_hidden_folder_in_jane │ ├── doe/jane/aka_aunt_of_lil │ ├── doe/jane/aka_jane_doe │ ├── doe/jane/aka_parent_of_mary │ ├── doe/jane/aka_sibling_of_john │ ├── doe/jane/child_of_doe │ └── doe/jane/mary │ ├── doe/jane/mary/.a_hidden_file_in_mary │ ├── doe/jane/mary/.a_hidden_folder_in_mary │ ├── doe/jane/mary/aka_mary_jane_Doe │ ├── doe/jane/mary/child_Of_jane │ ├── doe/jane/mary/child_of_sibling_of_john │ ├── doe/jane/mary/cousin_of_lil │ └── doe/jane/mary/grandchild_of_doe └── doe/john ├── doe/john/.a_hidden_file_in_john ├── doe/john/.a_hidden_folder_in_john ├── doe/john/aka_john_doe ├── doe/john/aka_parent_of_lil ├── doe/john/aka_sibling_of_jane ├── doe/john/aka_uncle_of_mary ├── doe/john/child_of_doe └── doe/john/lil ├── doe/john/lil/.a_hidden_file_in_lil ├── doe/john/lil/.a_hidden_folder_in_lil ├── doe/john/lil/aka_lil_john_doe ├── doe/john/lil/child_of_john ├── doe/john/lil/child_of_sibling_of_jane ├── doe/john/lil/cousin_of_mary └── doe/john/lil/grandchild_of_doe 10 directories, 30 files
tree /F doethe terminal is my friend, and shows
C:.\...\PUMPING_PYTHON\DOE │ .a_hidden_file_in_doe │ aka_grandparent_of_lil │ aka_grandparent_of_mary │ aka_parent_of_jane │ aka_parent_of_john │ a_file_in_doe │ ├── .a_hidden_folder_in_doe ├── jane │ │ .a_hidden_file_in_jane │ │ aka_aunt_of_lil │ │ aka_jane_doe │ │ aka_parent_of_mary │ │ aka_sibling_of_john │ │ child_of_doe │ │ │ ├── .a_hidden_folder_in_jane │ └── mary │ │ .a_hidden_file_in_mary │ │ aka_mary_jane_doe │ │ child_of_jane │ │ child_of_sibling_of_john │ │ cousin_of_lil │ │ grandchild_of_doe │ │ │ └── .a_hidden_folder_in_mary └── john │ .a_hidden_file_in_john │ aka_john_doe │ aka_parent_of_lil │ aka_sibling_of_jane │ aka_uncle_of_mary │ child_of_doe │ ├── .a_hidden_folder_in_john └── lil │ .a_hidden_file_in_lil │ aka_lil_john_doe │ child_of_john │ child_of_sibling_of_jane │ cousin_of_mary │ grandchild_of_doe │ └── .a_hidden_folder_in_lil
I can do things with files and folders in one step as long as
I know their paths/addresses
I know their relation to where I am and
I can write to them
It is easier to go where I want, if I know where I am.
how to remove a directory and all the things in it
I try to remove
doeand all its children and their childrenrm doethe terminal is my friend, and shows
rm: cannot remove 'doe': Is a directoryI cannot remove a directory this way
I remove
doeand all its children and their children with the-r/--recursiveoptionDanger
This is a destructive operation that takes a lot of work and time to undo on MacOS or Linux/Windows Subsystem for Linux. Do you want to do it?
rm --recursive doethe terminal goes back to the command line
rmmeansremove--recursiveor-rmeans remove child directories and what is in them until there is nothing left. It goes through every directory in the tree and removes everything
Remove-Item doethe terminal is my friend, and shows
Confirm The item at C:\...\pumping_python\doe has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):I could use A on the keyboard to answer
Yes to Allor give one command to delete all the files and folders and ask me no questions.I use ctrl+c on the keyboard to go back to the command line then use Remove-Item with the
-Recurseand-ForceoptionsRemove-Item doe -Recurse -ForceRemove-Item is used to remove files and folders
-Recursemeans remove child directories and what is in them until there is nothing left. It goes through every directory in the tree and removes everything-Forcemeans do not ask me any questions, just remove the file or folder
I try to change directory back to
doecd doethe terminal is my friend, and shows
cd: no such file or directory: doeSet-Location: Cannot find path 'C:\...\pumping_python\doe' because it does not existdoeis gone!
review
I ran these commands to play with folders (directories)
ls to show what is in directories
tree to show the relationships between directories
rm to remove directories
How many questions do you think you can answer after going through this chapter?
code from the chapter
what is next?
You know
Homework
use these commands - mkdir, cd, ls, tree and touch - to make your family tree. Send it to me when you are done.
Click Here to see me make a Python Test Driven Development Environment
rate pumping python
If this has been a 7 star experience for you, please CLICK HERE to leave a 5 star review of pumping python. It helps other people get into the book too