Exploring pwd Options
The pwd
command has a couple of options that can be useful in certain situations. We'll explore these now.
Note: In this step, we'll encounter some new concepts like symbolic links. Don't worry if you don't fully understand these yet - we'll cover them in detail in future lessons. For now, just focus on how the pwd
command behaves with different options.
-
First, let's use the pwd
command without any options:
pwd
You should see:
/home/labex/project
-
Now, let's use the -L
option (logical path):
pwd -L
You should see the same output:
/home/labex/project
-
Finally, let's try the -P
option (physical path):
pwd -P
Again, you'll see the same output:
/home/labex/project
You might be wondering why all these commands give the same output. The -L
and -P
options become relevant when dealing with symbolic links, which are like shortcuts in Windows. In our current directory, we don't have any symbolic links that affect our current path, so all versions of the command show the same result.
To see the difference, we need to navigate into the symlink_dir
:
cd symlink_dir
pwd -L
pwd -P
To see the difference between -L
and -P
options, we would need to navigate into a directory that is a symbolic link. However, navigating between directories involves using the cd
command, which we haven't learned yet. Don't worry - we'll cover the cd
command and dive deeper into symbolic links in future lessons.
For now, it's enough to know that pwd
has these options available for specific use cases. As you continue your Linux journey, you'll encounter situations where understanding these options becomes more relevant.