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
WBOYforward
2024-02-14 21:51:02465browse

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

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


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

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!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete