01. pwd command - muneeb-mbytes/linux_course GitHub Wiki

pwd stands for Present Working Directory. It prints the path of the working directory, starting from the root. $PWD is an [environment variable] which stores the path of the current directory.The pwd command writes to standard output the full path name of your current directory (from the root directory). All directories are separated by a / (slash). The root directory is represented by the first /, and the last directory named is your current directory.

Cheat Sheet for pwd command

S.No pwd commands Description
1. pwd Give the present working path
2. pwd -L Print the symbolic path
3. pwd -P Print the actual path

pwd

Figure.1 shows the path of working directory starting from the root .

11-Page-5 drawio

                               Figure.1. Usage of pwd commnd

GIF.1 shows the whole process from sourcing scripting file till the output.

pwd_pre

                                           GIF.1. pwd command output GIF 

Github lab link: https://github.com/muneeb-mbytes/linux_course/blob/b7_Team_SiliconCrew/pwd_commands/present_dir.csh

There are two main flags in pwd command .

pwd -L: Prints the symbolic path.

pwd -P: Prints the actual path.


For more details regarding symbolic links , refer to symbolic link page.


pwd -L

--L is the shorthand for the logic option . The -L option instructs pwd to print the working directory path, including any symbolic links. We used a symbolic link to navigate to a directory and ran pwd -L.

Syntax : pwd -L


pwd -P

Here, the --P is the shorthand for the path. Prints the path to the current directory. All the components are directory names, and symbolic links are resolved.

Syntax : pwd -P

Figure.2 shows pwd -L command to check the logical path of the link and pwd -P command to check the physical path of the link.

pwd22

                             Figure.2. Usage of pwd -L and pwd -P

GIF.2 shows the whole process from sourcing scripting file till the output.

gif of Both pwd -L and pwd -P command

pwd_-L

                                           GIF.2. pwd [options] output GIF 

Github lab link: https://github.com/muneeb-mbytes/linux_course/blob/b7_Team_SiliconCrew/pwd_commands/pwd_options.csh


pwd --version-

Check which pwd version is installed by running it .

Syntax : pwd --version


pwd --help -

Use the --help option to see the pwd command help file and the available options.

Syntax : pwd --help


To learn cd command:https://github.com/muneeb-mbytes/linux_course/wiki/02.-cd-commands