Pwd linux команда расшифровка

Pwd linux команда расшифровка

The pwd utility shall write to standard output an absolute pathname of the current working directory, which does not contain the filenames dot or dot-dot.

OPTIONS

The pwd utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.

The following options shall be supported by the implementation: -L If the PWD environment variable contains an absolute pathname of the current directory that does not contain the filenames dot or dot-dot, pwd shall write this pathname to standard output. Otherwise, the -L option shall behave as the -P option. -P The absolute pathname written shall not contain filenames that, in the context of the pathname, refer to files of type symbolic link.

If both -L and -P are specified, the last one shall apply. If neither -L nor -P is specified, the pwd utility shall behave as if -L had been specified.

OPERANDS


STDIN


INPUT FILES


ENVIRONMENT VARIABLES

The following environment variables shall affect the execution of pwd : LANG Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES . PWD If the -P option is in effect, this variable shall be set to an absolute pathname of the current working directory that does not contain any components that specify symbolic links, does not contain any components that are dot, and does not contain any components that are dot-dot. If an application sets or unsets the value of PWD , the behavior of pwd is unspecified.

Читайте также:  Linux scp копирование файлов

ASYNCHRONOUS EVENTS


STDOUT

The pwd utility output is an absolute pathname of the current working directory:

STDERR

The standard error shall be used only for diagnostic messages.

OUTPUT FILES


EXTENDED DESCRIPTION


EXIT STATUS

The following exit values shall be returned: 0 Successful completion. >0 An error occurred.

CONSEQUENCES OF ERRORS

If an error is detected, output shall not be written to standard output, a diagnostic message shall be written to standard error, and the exit status is not zero.

The following sections are informative.

APPLICATION USAGE


EXAMPLES


RATIONALE

Some implementations have historically provided pwd as a shell special built-in command.

In most utilities, if an error occurs, partial output may be written to standard output. This does not happen in historical implementations of pwd . Because pwd is frequently used in historical shell scripts without checking the exit status, it is important that the historical behavior is required here; therefore, the CONSEQUENCES OF ERRORS section specifically disallows any partial output being written to standard output.

FUTURE DIRECTIONS


SEE ALSO

cd , the System Interfaces volume of IEEE Std 1003.1-2001, getcwd ()

Источник

Зачем нужна команда pwd и что такое текущая рабочая директория

Зачем нужна команда pwd и что такое текущая рабочая директория главное изображение

Из этой статьи вы узнаете, как определить текущую рабочую директорию (current working directory) с помощью команды pwd.

Что такое текущая рабочая директория

Текущая рабочая директория — директория, в которой пользователь работает в данный момент. При взаимодействии с командной строкой вы всегда находитесь внутри директории.

По умолчанию, когда вы запускаете операционную систему Linux, текущим рабочим каталогом является домашняя директория. Изменить рабочую директорию можно с помощью команды cd.

Например, чтобы изменить текущую рабочую директорию на /tmp, используйте такую команду:

Путь к текущей рабочей директории может отображаться в оболочке командной строки.

Команда pwd выводит текущую рабочую директорию. Это одна из базовых и самых популярных команд в Linux. При вызове pwd выводится полный путь к текущей рабочей директории.

Команда pwd встроена в большинство современных командных оболочек, в том числе в Bash. Её поведение отличается от выполнения /bin/pwd. С помощью команды type можно получить все места, где есть pwd:

pwd is a shell builtin pwd is /bin/pwd 

Как показывает вывод, встроенная команда pwd имеет более высокий приоритет по сравнению с /bin/pwd. Поэтому она используется всякий раз, когда вы вводите в командую строку pwd. Если вы хотите использовать файл /bin/pwd, нужно указать в командной строке полный путь до него.

Как найти текущую рабочую директорию

Чтобы понять, в какой директории вы работаете в данный момент, введите в терминале pwd. Вывод может выглядеть так (название директории может отличаться):

Всё, что делает команда pwd — выводит значение переменной окружения PWD. Такой же вывод получится, если ввести в терминале:

получаем текущий рабочий каталог

Команда pwd принимает только два аргумента:

  • -L (—logical) — не разрешать симлинки.
  • -P (—physical) — отображать физическую директорию без симлинков.
Читайте также:  Red dead redemption 2 linux

По умолчанию pwd ведёт себя так, как будто применена опция -L.

Чтобы понять, как работает аргумент -P, создадим директорию и симлинк, указывающий на эту директорию.

mkdir /tmp/directory ln -s /tmp/directory /tmp/symlink 

Когда вы зайдёте в директорию /tmp/symlink и введёте команду pwd, вывод будет таким:

То есть текущей рабочей директорией становится /tmp/symlink. Если ввести команду pwd -P, вывод будет таким:

Симлинк (англ. Symlink, symbolic link) — символическая ссылка. Этим термином обозначают файл, в котором содержится абсолютный или относительный путь к другому файлу или директории.

То есть получаем директорию, на которую указывает симлинк.

Заключение

Текущая рабочая директория — директория, из которой вы вызываете команды в терминале. Чтобы отобразить текущую рабочую директорию, нужно использовать команду pwd. Если у вас остались вопросы, добро пожаловать в комментарии.

Источник

Linux pwd Command

The pwd is a helpful command for Linux users who are inexperienced and might get lost in the middle of directories.

The pwd is an abbreviated form of “Print Working Directory,” or we can call the Current Work Directory. It displays the name of the current directory with the root path.

It is the most frequently used built-in shell command by Linux system administrators.

PWD Syntax

The Syntax of pwd Command is:

PWD Commands

Here are a few most commonly used commands of pwd. Let’s check how they work in Linux System:

Display Current Directory

As my current working directory is the home directory, so it will print the home directory in the terminal.

To display the current working directory in Linux, use the command:

PWD Flags

The pwd command accepts two flags:

1. pwd –L
The -L flag is used to print symbolic links; in other words, in Linux, it points towards the file or folder where you are currently working in.

Let’s check its functionality:

Create a symbolic link in a home directory named Linuxhint and move the present directory to the newly created one.

Now, use the given command to check if it’s working:

2. pwd –P:
The -P command is used to print the actual path without any symbolic link.

pwd Version

The pwd command comes pre-installed. You can check the pwd version through the command-line by given command:

pwd -a

The following command will help you to display the list of all locations having executable name pwd:

Читайте также:  Linux rename directory and directories

pwd Help

When you use the help command, it will show you pwd command options.

To get it, use mentioned command in the terminal:

Echo $PWD

To store the path of the current directory, the echo $PWD command is used. It functions the same as the pwd –L command:

PWD and OLDPWD command

To get current and previous directory using one command, type:

Conclusion

We have seen a brief explanation of the pwd command and its examples. The pwd command is a widely used shell built-in command in Linux systems. It displays the current working directory on which the user is working.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.

Источник

Команда pwd Linux

Команда pwd — это очень простая утилита, которая позволяет вывести в терминал путь к текущей папке. Каждая программа при запуске получает текущую папку в которой будут выполнятся все операции с её файлами если для них не указан другой путь. Все относительные пути тоже будут отсчитываться от этой папки.

При запуске терминала текущей папкой считается домашний каталог пользователя. Если программу запускать из определенной папки, то ее текущей папкой будет та папка, из которой ее запустили.

Команда pwd в Linux

Синтаксис команды очень простой:

Вот основные опции, которые вы можете использовать для настройки вывода утилиты:

  • -L, —logical — брать директорию из переменной окружения, даже если она содержит символические ссылки;
  • -P — отбрасывать все символические ссылки;
  • —help — отобразить справку по утилите;
  • —version — отобразить версию утилиты.

Дальше рассмотрим несколько примеров работы с командой. Для того чтобы просто посмотреть текущую папку Linux достаточно выполнить pwd без параметров:

Также у команды есть одна опция -P. Если по пути к текущей папке есть символические ссылки, то утилита покажет полный путь без учета символических ссылок:

В большинстве командных интерпретаторов pwd — это встроенная команда. Поэтому интерпретатору не нужно вызвать внешнюю утилиту и выполнение когда работает очень быстро.

Чтобы узнать текущую папку в скрипте не обязательно использовать эту команду. Достаточно обратится к переменной окружения PWD:

Но также можно записать результат выполнения команды pwd linux в переменную:

Выводы

Команда pwd Linux используется достаточно редко, намного чаще нам нужно менять текущую папку. Для этого применяется команда cd. Как видите, все очень просто.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

Оцените статью
Adblock
detector