Listing
-
2. Listing
Now try to List the Directory’s Contents
To List the Directory you are in execute:ls .
The “.” is optional and meaning the Location you are in.
[See how the Command “ls” is just an Abbreviation for Listing!]
The default Location each time you open a New Terminal Window is the Home Folder.
So the Output of the Command should be very similar to this:Desktop/ Downloads/ Pictures/ tmp/ Documents/ Music/ Templates/ Videos/
Here the Entities with a Trailing Slash are Directories.
Again to List the Downloads Folder inside on your Home, run:ls ~/Downloads
Or also:
ls $HOME/Downloads
Where “$HOME” is an Environment Variable always containing your User’s Home Path.
Next to List the Main System’s Root Directory:
(The Root of What? Of the System’s Directory Tree. The Trunk, all the other Directories are Branches.)ls /
So possibly to List the “usr” Directory:
[Again an Abbreviation for “User System Resources“]:ls /usr
Finally, to List the “bin” Branch:
[Again an Abbreviation for “Binaries” (The Executables)]ls /usr/bin
-
Next practice the Change of Directory
Change to the Root Directory:cd /
[Again find out how “cd” is an Abridgement for “Changing Directory“]
Then Go to /usr/bin:cd /usr/bin
Now to Navigate Back to the Parent use the “..” option.
So non to Return to the Root of the Directory Tree you may play:cd ../..
(It’s like to say: ‘One Step Back and then One Step Back’ again)
Finally, to Return Home is simple as:cd
Then to Verify you are in that Location Use:
pwd
[In this case the “pwd” Command is a Shortcut for “Print Working Directory“]
Hey Congratulations! you achieved the First, Step-by-step Walk into the Linux Directory Tree! :) - The System’s Directory Tree Root: /
- The root User’s Directory: /root
- The root User: the SuperAdmin that can Execute Any Command
-
Again experiment the Creative powers
With a test Directory like:mkdir $HOME/livingroom
[See here again how “mkdir” is an Abbreviation for “Making Directory“].
How you should have already understood, $HOME and ‘~‘ are both synonymous of your’s Home Folder.
And the Home Directory is where your User Contents are Stored by Default.Moreover, to enhance your Memorization and Fun I rightly Use some Metaphoric term. So here you can Immagine a directory like a Room into your Home :)
Try Making Multiple Directories at once with:
mkdir $HOME/bedroom $HOME/bathroom $HOME/garden
Try to use the “ls” Command to Check your creative Work:)
ls ~
Finally, use the ‘touch‘ Command to Make a New Empty File:
touch $HOME/livingroom/box
And how you could already have perceived, in my creative Examples I make use of the following Mnemonic Linking:
-
Directory -> Spatial Entity
-
File -> Thing
And so in the Previous Command to an “Empty File” corresponds a natively “Empty Thing” like a “box”, or otherwise you may take it as a simple Label/Name ;)
-
Especially relevant, about the Shell Terminology, there are 3 different Entities named as “Root”:
Contents