profile for joel goldstick at Stack Overflow, Q&A for professional and enthusiast programmers

JoelGoldstick.com

Directories

Categories: git

Published on April 19, 2016

Last Modified on April 19, 2016

Directories

In Linux and Linux like systems (BSD used on Macs) organize files into folders that can be visualized as and inverted tree. The root is the top of the tree. It is designated with aforward slash /. Contained in the root are other directories (branches) and files (leaves). Each directory can contain subordinate directories and files.

When using the shell, you are in a particular directory. You can use the pwd (present working directory) to find out where you are. A file can be identified by its abosolute or relative path. 'pwd' displays an abosolute path. That is, it starts with the root (/) and displays each of the directories in turn that lead to your pwd.

Here is an example from my computer:

jcg@jcg-netbook:~/code/venvs/git_course$ 
.
├── directories
├── file1
├── mac_add_terminal_to_dock
├── README.md
├── shell
├── toc
├── toc~
└── what_is_version_control

Note that the present working directory (pwd) is ~/code/venvs/git_course

if I want to view the file called toc, I can use a relative path:

cat toc

or an absolute path:

cat /home/jcg/code/git_course.toc

. and ..

Two special directories are . and ..

If you type ls you will get the directory for your pwd. You could also type ls . because the single dot indicates the present working directory. The double dot indicates the parent of the pwd, so ls .. will show the files in the parent of where you are now.

The dot also is used in a different way. If a file or directory name starts with a dot (like .git ) it will be hidden from the standard ls command. To see hidden files or directories type ls -l (l is for 'long')

If you want to look at what files are in the directory above your pwd do this:

ls ..

The . is also used to make files hidden. If you have a file or directory in your pwd called .git it will not be listed when you use the plain ls command.

However if you type ls -l (lower case el) you will see your hidden files listed