+5 votes
394 views
How to use pwd command in Linux

in Linux / Unix by (552k points)
reopened | 394 views

1 Answer

+3 votes
Best answer

1. How to print the current directory pwd Linux command
2. How to print the real names pwd Linux command
3. How to use / bin / pwd Linux pwd command
4. How to print symbolic links pwd Linux command
5. How to view the used version of pwd Linux

Are you of what when you hear the word "command" you want the earth to swallow it? Or maybe you think that the commands are an almost impossible mission to carry out. Well, it's not like that, TechnoWikis assures you that every command in Linux , although it seems complex and extremely difficult to assimilate, is actually very practical and supports the tasks of support to be performed. Just understand its structure and purpose to realize that they will be our friends and with them many, we would say hundreds of tasks, will be executed more simply and completely..

Well, one of these "dark" commands is the pwd command which we will discuss in detail and with examples in this tutorial.

What is the PWD command?
The command PWD (Present Working Directory), we already understood clearly what it does, has as task to print the name of the current working directory in which we are, this helps to understand more about what we are working on without making mistakes.

The pwd command prints the name of the current directory, integrating the complete path with the root (/) as its origin. When using this command, it is important to know that it is integrated in the shell command and is available in most shell: bash, Bourne shell, ksh, zsh and more..

To determine which pwd is the default in our system, we must execute the following:

 type pwd 

image

The basic syntax of use of pwd is the following:

 pwd [OPTION] ... 
Now, the options that Linux offers us for the pwd command are:
-L, - logical
This option states that if the PWD environment variable has an absolute name of the current directory without "." or the components "..", we can be sure that this content will be generated, even if it contains symbolic links.

-PAG, --physical
With this option, we will obtain in response the printing of the name of the current directory, understanding that all the components of the name are real directory names but not symbolic links.

--help
Display command help

--version
Display the used version of pwd

TechnoWikis will explain some ways in which we can use this practical command in Linux and thus have one more ally in each task of support to execute.


1. How to print the current directory pwd Linux command


To visualize in which directory we are currently going to execute the following:
 pwd 
This option prints the name of the current working directory, in case any subdirectory in the path is a symbolic link, those symbolic link names will be printed.

image


2. How to print the real names pwd Linux command


In the previous command, the symbolic names of the current work path will be printed, but if we want the real names of the directory components printed, we must use the following line:
 pwd -P 
For this example we have created a symbol link to / tmp and we can notice the difference between both commands:

image


3. How to use / bin / pwd Linux pwd command


While pwd is integrated in the shell, / bin / pwd is the tool that is available in the Linux distribution used, we can verify this by executing:
 type -a pwd 

image

We can visualize the current directory by executing:

 / bin / pwd 

image


4. How to print symbolic links pwd Linux command


If we want to print the current working directory even if it contains symbolic links, we will execute:
 / bin / pwd -L 

image


5. How to view the used version of pwd Linux


To check which version we are using, we must execute the following:
 / bin / pwd -version 

image

We have seen how the use of commands in Linux is not a mystery of another universe, but it is clear that it will be very practical to carry out more management tasks in Linux..


by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Oct 20, 2020 in Linux / Unix by backtothefuture (552k points) | 240 views
+4 votes
1 answer
asked Sep 22, 2020 in Linux / Unix by backtothefuture (552k points) | 333 views
+3 votes
1 answer
asked Nov 9, 2019 in Linux / Unix by backtothefuture (552k points) | 302 views
+5 votes
1 answer
asked Oct 24, 2019 in Linux / Unix by backtothefuture (552k points) | 231 views
+5 votes
1 answer
asked Sep 19, 2019 in Linux / Unix by backtothefuture (552k points) | 313 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users