Home > System Tutorial > LINUX > Interpret the use of pwd and dirs directory viewing commands in Linux

Interpret the use of pwd and dirs directory viewing commands in Linux

WBOY
Release: 2024-02-14 21:51:02
forward
478 people have browsed it

Linux system is an operating system based on files and directories, which allows users to create, modify, delete files in different directories. However, when you switch between multiple directories, do you feel lost and don't know what directory you are currently in? The Linux system provides two simple and convenient commands that allow you to quickly locate the current working directory, namely pwd and dirs. This article will introduce the use of pwd and dirs directory viewing commands in Linux, including the meaning, format, parameters, examples, etc. of the commands.

Interpret the use of pwd and dirs directory viewing commands in Linux

pwd displays the current directory

-L, –logical
Show current directory
-P, –physical
Display the actual physical address of the current directory
–help help
–version version

example:

code show as below:

[root@rudder home]# pwd #显示当前目录
/home
[root@web mail]# pwd -P #目录是软连接,显示实际物理地址
/var/spool/mail
[root@web mail]# pwd -L #-L显示,逻辑地址
/var/mail
Copy after login

dirs: Display records in the directory stack

Syntax: dirs [-clpv] [ N] [-N]

Parameters:
n Based on the current directory, display the nth directory from the left.
-n takes the current directory as the basis and displays the nth directory from the right.
-l displays a complete record of the directory.

example 1

code show as below:

[root@rudder home]# dirs 
/home


Copy after login

Example 2

code show as below:

[root@localhost zhangy]# dirs #显示目录栈
/home/zhangy /usr
[root@localhost zhangy]# dirs -1
/home/zhangy 
[root@localhost zhangy]# dirs +1
/usr
Copy after login

This article introduces the use of pwd and dirs directory viewing commands in Linux, including the meaning, format, parameters, examples, etc. of the commands. By understanding and mastering this knowledge, we can better use the pwd and dirs commands to quickly locate the current working directory, thus improving work efficiency and accuracy. Of course, there are many other directory viewing commands in Linux systems, which require us to continue to learn and try. I hope this article can bring you some inspiration and help.

The above is the detailed content of Interpret the use of pwd and dirs directory viewing commands in Linux. For more information, please follow other related articles on the PHP Chinese website!

source:lxlinux.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template