2

For exercise - I removed execute permission for others from /bin/pwd:

$ chmod o-x /bin/pwd $ ls -l /bin/pwd -rwxr--r-- 1 root root 26568 Apr 28 2010 /bin/pwd 

and as logged as matt I cannot execute /bin/pwd as expected:

$ /bin/pwd $ -bash: /bin/pwd: Permission denied 

but sudden it can be executed if not absolute:

$ pwd /home/matt 

Why? Thank you!

1 Answer 1

2

pwd is a shell built-in. You can see that with

$ type pwd pwd is a shell builtin 

pwd is a built-in in most shells. One reason for that is that it's a very simple command that's used fairly frequently (and running a built-in is faster than spawning an external process). Another reason is that it allows the shell to track symbolic links, so that cd /foo/bar; pwd shows /foo/bar even if bar is a symbolic to /wibble (in bash and many other shells, you can use pwd -P to show /foo/bar and pwd -L to show /wibble; the default is controlled by the -o physical option).

1
  • Thank you!!! I didn't know that pwd is a built-in! Wow! Commented Sep 8, 2011 at 21:46

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.