Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with sudo...

0 views
Skip to first unread message

Robert Mitchell

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to
I am trying to set up sudo. It works fine unless I type:

sudo cd

or sudo cd ~username

The cd command does not work with sudo. Does anyone know why?
Thanks


Thad Floryan

unread,
Sep 30, 1998, 3:00:00 AM9/30/98
to

It works fine; the "problem" is that "cd" is not a useful program
to execute via sudo (unless, perhaps, you want an implicit automount).

Point being: whatever it is that's being executed by sudo, when it's done
you're restored to where/what you were prior to issuing the sudo.

Note that the "cd" executed by sudo is not the shell's builtin cd, it's
[typically] the /bin/cd program (on Solaris 2.6).

Watch this:

sirius bash 20690/20692> pwd
/home/thad
sirius bash 20690/20692> which cd
/bin/cd
sirius bash 20690/20692> /bin/cd /tmp
sirius bash 20690/20692> pwd
/home/thad
sirius bash 20690/20692> cd /tmp
sirius bash 20690/20692> pwd
/tmp

Thad

AutoBahn

unread,
Sep 30, 1998, 3:00:00 AM9/30/98
to
The reason 'sudo cd' doesn't work so well is simple. sudo is designed to
execute commands as root and exit once the command is finished. If you
execute 'sudo cd' to a directory you don't have permission to enter as
yourself, it kicks you back to the prior directory after executing the cd.
Your WERE in the directory, it just doesn't allow you to stay in it.


Thad Floryan wrote in message <6us8n9$3tr$7...@nntp2.ba.best.com>...

0 new messages