Linux Basics Command (3) PWD command

Source: Internet
Author: User
Tags file system

Linux uses the PWD command to view the full path of the current working directory. Simply put, every time you operate on a terminal, you have a current working directory.

When you are unsure of the current position, you use PWD 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:

Usually without any arguments

If the directory is a link:

Format: Pwd-p shows the actual path rather than using the connection path.

4. Common examples:

Example 1: View the full path to the default working directory with the PWD command

Command:

Pwd

Output:

[Root@localhost ~]# pwd

/root

[Root@localhost ~] #

Example 2: Use the PWD command to view the specified folder

Command:

Pwd

Output:

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

[Root@localhost soft]# pwd

/opt/soft

[Root@localhost soft]#

Example three: When a directory connection link, Pwd-p displays the actual path instead of using the connection path; pwd shows the connection path

Command:

Pwd-p

Output:

[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:

-L directory connection link, output connection path

-P Output Physical path

Output:

[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]#

Instance five: The current directory is deleted, and the PWD command still displays that directory

Output:

[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 ~]#

View a full set of articles: Http://www.bianceng.cn/OS/Linux/201301/35075.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.