shell,

Display current directory from the CLI

Jun 22, 2023 · 1 min read · Post a comment

Trying to get the current working directory is a good starting point for debugging purposes at least whenever you are ssh-ed into a CI/CD server agent or likewise. So here’s the tip.

Prerequisites

  • Shell environment

Solution

If you are running any shell environment such as bash, shell, zsh, or even powershell, run:

pwd

However, if you are trying to print the current dir from Windows CMD, you have to run cd instead which is a bit confusing since the same command in other shell environments will take you to your home directory, being equivalent to: cd ~.

Conclusion

In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.