Here is the video version, if you prefer it:
Maybe you heard the terms “parent directory” and “current directory”, “working directory” or “current working directory”. “What do these terms mean?” you might ask yourself. Well, fear not, because I have come to alleviate you from your ignorance! (imagine epic music playing in the background)
Working directory (or its synonyms), in the context of using the Linux command line, refers to the directory you are currently located in. (Barrett, 2016)Let me elaborate:
I just started a new Terminal session and this is what I get as output:
~ between the : and
$? Well, that is my working directory.
~ actually stands for my home directory, so instead of
~, if we wanted to be fully correct, there should be
/home/mislav. If you start a Terminal session, your working directory should also be
~ as well. From within the Terminal, you can change directories (using the
cd command), but that is not the topic of this post.
Now, more importantly, why is it important to know in which directory you are in? A good question. It’s like I asked it myself. Let’s look at the following example:
anaconda3 grep-hadoop-example Python-3.7.4
'Calibre Library' hadoop-example stanfordnlp_resources
… here means output continues)
The ls command lists directory contents. (“LS(1),” n.d.) But contents of what directory, exactly? Well, if you don’t explicitly say what directory, it is assumed that you want the ls to list the contents of the working directory.
So that’s why it is useful! Imagine if you were inside the directory you desire to operate upon and every time you wanted to call a command you needed to write out the full “trajectory” (also called a path) to the directory you wanted to operate on (as in
ls /home/mislav while already being in
/home/mislav). That’s tedious and programmers don’t like tedious. Thus, when calling a command (in our case, ls), it assumes you want to operate on the current directory.
Lastly, parent directory is the directory directly above the current directory. (Shotts, 2019) For example, if I was in the folder
the parent directory of the
mislav directory is the
home directory. (3 uses of the word directory in one sentence, whew!)
Hope you learned something useful!
Barrett, D. J. (2016). Linux pocket guide (3rd ed.). O’Reilly Media. Pages 17-19
LS(1). (n.d.). Retrieved December 29, 2019, from http://man7.org/linux/man-pages/man1/ls.1.html
Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 31-32
Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.