[sudo-users] sudo & cd command from rksh

Todd C. Miller Todd.Miller at courtesan.com
Thu Jul 27 13:01:38 EDT 2006


You cannot use the "cd" command with sudo since "cd" is a construct
of the shell.  While some OSes include a "cd" command it can't
really do anything since it is not possible to change the current
working dir of the parent process.  Basically, it will change the
current working directory and then exit, leaving you right where
you started.

What you probably want to do is to write a simple shell script
that does the cd and the commands you need done and give the
user sudo access to that script.

- todd



More information about the sudo-users mailing list