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

Analysis on the use of pwd Command in linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "case analysis of the use of pwd commands in linux". The editor shows you the operation process through the actual case, and the operation method is simple, fast and practical. I hope this article "case analysis of the use of pwd commands in linux" can help you solve the problem.

Use the pwd command in linux to see the full path to the "current working directory". To put it simply, every time you operate on the terminal, you will have a current working directory.

When the current location is uncertain, pwd is used to determine the exact location of the current directory within the file system.

1. Command format:

Pwd [options]

2. Command function:

View the full path to the current working directory

3. Common parameters:

Normally, there are no parameters.

If the directory is a link:

Format: pwd-p shows the actual path instead of using the link path.

4. Common examples:

Example 1: use the pwd command to view the full path of the default working directory

Command:

Pwd

The copy code is as follows:

[root@localhost ~] # pwd

/ root

[root@localhost ~] #

Example 2: use the pwd command to view the specified folder

Command:

Pwd

The copy code is as follows:

[root@localhost ~] # cd / opt/soft/

[root@localhost soft] # pwd

/ opt/soft

[root@localhost soft] #

Example 3: when a directory connects to a link, pwd-p shows the actual path instead of using the link path; pwd shows the connection path

Command:

Pwd-p

The copy code is as follows:

[root@localhost soft] # cd / etc/init.d

[root@localhost init.d] # pwd

/ etc/init.d

[root@localhost init.d] # pwd-p

/ etc/rc.d/init.d

[root@localhost init.d] #

Instance 4:/bin/pwd

Command:

/ bin/pwd [options]

Options:

Output the connection path when the-l directory connects to the link

-p output physical path

The copy code is as follows:

[root@localhost init.d] # / bin/pwd

/ etc/rc.d/init.d

[root@localhost init.d] # / bin/pwd-- help

[root@localhost init.d] # / bin/pwd-p

/ etc/rc.d/init.d

[root@localhost init.d] # / bin/pwd-l

/ etc/init.d

[root@localhost init.d] #

Example 5: the current directory is deleted, but the pwd command still shows that directory

The copy code is as follows:

[root@localhost init.d] # cd / opt/soft

[root@localhost soft] # mkdir removed

[root@localhost soft] # cd removed/

[root@localhost removed] # pwd

/ opt/soft/removed

[root@localhost removed] # rm.. / removed-rf

[root@localhost removed] # pwd

/ opt/soft/removed

[root@localhost removed] # / bin/pwd

/ bin/pwd: couldn't find directory entry in ".." With matching i-node

[root@localhost removed] # cd

[root@localhost ~] # pwd

/ root

[root@localhost ~] #

This is the end of the content of "case Analysis of the use of pwd commands in linux". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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

Development

Wechat

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

12
Report