Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the pwd command in Linux to view the absolute path of the current directory

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to use the pwd command to view the absolute path of the current directory in Linux. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Linux to view the absolute path of the current directory-pwd command

When using Linux, we often go to various directories of the file system. By default, the command prompt only shows us the last level of the current directory, and we cannot know the current absolute path. Using the pwd command, we can view the absolute path of the current directory, which is one of the more commonly used commands in Linux.

Command Overview

Pwd means print working directory in English.

Format of the pwd command: pwd [options]

The path where the command is located: / bin/pwd. All users have permission to execute this command.

Common options:

-L uppercase L Perry PWD is equivalent to pwd-L by default. Whether it is a linked directory or not, it shows the absolute path of the current directory-P uppercase P. when the current directory is a linked directory, it shows the absolute path of the source directory to which the linked directory points.

Example

The default option of the pwd command, which outputs the absolute path of the current directory by default, is also the most frequently used way, as shown below:

[calmsnow@localhost ~] $pwd/home/calmsnow [calmsnow@localhost ~] $cd / etc/init.d/ [calmsnow@localhost init.d] $pwd/etc/init.d

Pwd-P is used to display the absolute path of the source directory to which the linked directory points when the current directory is a linked directory, as follows:

# this is a link directory [calmsnow@localhost /] $ls-l sbinlrwxrwxrwx. 1 root root 8 May 15 10:57 sbin-> usr/sbin [calmsnow@localhost /] $cd / sbin/# is the absolute path to the current directory [calmsnow@localhost sbin] $pwd/sbin [calmsnow@localhost sbin] $pwd-L/sbin# link directory to the absolute path to the source directory [calmsnow@localhost sbin] $pwd-P/usr/sbin

Extension: when the link directory is a multi-layer link directory, pwd-P shows the absolute path of the link directory to the source directory. If you are interested, you can verify it yourself. I will not give an example in this article.

This is how to use the pwd command to check the absolute path of the current directory in the Linux shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report