Isso depende do que você está fazendo. Primeiro de tudo, $PWD é uma variável de ambiente e pwd é um shell embutido ou um binário real:
$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
Agora, o bash builtin simplesmente imprimirá o valor atual de $PWD , a menos que você use o -P flag. Conforme explicado em help pwd :
pwd: pwd [-LP]Print the name of the current working directory.
Options:
-L
print the value of
$PWDif it names the current working directory-P
print the physical directory, without any symbolic links
By default, ‘pwd’ behaves as if ‘-L’ were specified.
O pwd binary, por outro lado, obtém o diretório atual através do getcwd(3) chamada do sistema que retorna o mesmo valor que readlink -f /proc/self/cwd .
Para ilustrar, tente mudar para um diretório que seja um link para outro:
$ ls -l
total 4
drwxr-xr-x 2 terdon terdon 4096 Jun 4 11:22 foo
lrwxrwxrwx 1 terdon terdon 4 Jun 4 11:22 linktofoo -> foo/
$ cd linktofoo
$ echo $PWD
/home/terdon/foo/linktofoo
$ pwd
/home/terdon/foo/linktofoo
$ /bin/pwd
/home/terdon/foo/foo
Assim, em conclusão, em sistemas GNU (como o Ubuntu), pwd e echo $PWD são equivalentes, a menos que você use a opção -P , mas /bin/pwd é diferente e se comporta como pwd -P .
Fonte link