Shared server guidance · Question & answer

How do I check which directory I am in on a Linux server?

Use pwd to display the working directory of the remote shell. A path beginning with / is absolute; a relative path is interpreted from your current directory. The directory on your Windows computer is separate from the directory shown after an SSH login.

BeginnerLinux VPS and dedicated servers with GNU utilities
Go to the answer

Before you start

  • An authorised SSH session on the Linux server.

Instructions

1. Confirm the remote location

Run these commands after SSH has opened the Linux shell. The physical-path form resolves symbolic links, which helps when a deployment directory is reached through a link.

Remote Linux shell
pwd
pwd -P

Compare the logical location with the resolved filesystem path; neither command changes files.

2. Move using an explicit path

Use your own home directory for practice. Quote paths containing spaces, and check the location again before running a command that creates or removes anything.

Remote Linux shell
cd "$HOME"
pwd
ls -ld -- . ..

cd changes only this shell’s working directory. A single dot means the current directory; two dots mean its parent.

Check the result

  • pwd prints the expected remote absolute path, and ls identifies the current directory without changing its contents.

Troubleshooting

The directory differs between terminals
Each SSH session has its own working directory. Set it explicitly in every session or script.
pwd and pwd -P differ
A path component is a symbolic link. Use the resolved target when diagnosing ownership or a missing mount.

Official references

Use the documentation for your installed version when a flag, service name or platform feature differs.