LinuxCommandLibrary

pwdx

Identify process's current working directory

TLDR

Print current working directory of a process

$ pwdx [process_id]
copy

SYNOPSIS

pwdx pid [pid ...]

PARAMETERS

pid
    The process ID(s) of the process(es) whose working directory should be displayed.

DESCRIPTION

The pwdx command is a simple utility used to determine the current working directory of one or more running processes. It takes process IDs (PIDs) as arguments and displays the corresponding directory path for each specified PID. It's a valuable tool for system administrators and developers troubleshooting applications or investigating process behavior. pwdx uses the /proc filesystem, a pseudo-filesystem that provides an interface to kernel data structures. It relies on reading the 'cwd' symbolic link located under /proc/[pid]/ to get the directory. It can be helpful for debugging process-related issues. Note that you need appropriate privileges (usually root or same user as the process) to inspect the working directory of other processes.

CAVEATS

If the specified PID does not exist or if you do not have the necessary permissions to access the process's information, pwdx will output an error message.

EXAMPLES

  • To find the working directory of process with PID 1234:
    pwdx 1234
  • To find the working directories of processes with PIDs 1234 and 5678:
    pwdx 1234 5678

SEE ALSO

ps(1), lsof(8), proc(5)

Copied to clipboard