How to display the current working directory in the Linux system?


To print the current working directory, we use the pwd command in the Linux system.

pwd (print working directory) – The pwd command is used to display the name of the current working directory in the Linux system using the terminal. This is a shell building command that is available in most Unix shells such as Bourne shell, ash, bash, kash, and zsh.

Syntax

The general syntax of the pwd command is as follows −

pwd [-LP]

A brief description of options available in the pwd command.

Sr.No.Option & Description
1-L (logical) Display the value of $pwd if it names the current working directory
2-P (physical) Display the physical directory, without any soft link
3--help Displays a help message and then exits.

By default, the pwd works as if -L option was specified.

Exit Status

The pwd command returns true unless an invalid option supplied or the current directory could not be read.

To display the current working directory, we use the pwd command in the Linux/Unix system as shown below.

vikash@tutorialspoint:~ pwd
/home/vikash

To display the physical directory instead of symbolic links or soft links, we use -P option with the pwd command in the Linux/Unix system as shown below.

vikash@tutorialspoint:~ pwd -P
/home/vikash

To display more about the pwd command we use -help option with the pwd command as shown below.

vikash@tutorialspoint:~ pwd --help

After execution of above command. It will be prompt a short description with available options available in the pwd command.

Updated on: 06-Sep-2023

33K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements