Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: sudo: cd: command not found

  1. #1
    Join Date
    Sep 2007
    Location
    over there
    Beans
    2,521
    Distro
    Ubuntu

    sudo: cd: command not found

    Looky here:

    Code:
    t0p@deimos:~$ cd /etc/chatscripts
    bash: cd: /etc/chatscripts: Permission denied
    t0p@deimos:~$ sudo cd /etc/chatscripts
    [sudo] password for t0p: 
    sudo: cd: command not found
    t0p@deimos:~$ sudo -s
    root@deimos:~# cd /etc/chatscripts
    root@deimos:/etc/chatscripts#
    How come 'sudo cd' doesn't work?
    "All people are scum. No matter what they look like." ~ Spider Jerusalem, Transmetropolitan #4



  2. #2
    Join Date
    Jan 2008
    Beans
    4,757

    Re: sudo: cd: command not found

    cd isn't a command.

    It's a builtin.

    Type in
    Code:
    help
    For a list of other builtins that won't work with sudo.
    Last edited by ibuclaw; October 14th, 2009 at 08:56 PM.

  3. #3
    Join Date
    Sep 2007
    Location
    over there
    Beans
    2,521
    Distro
    Ubuntu

    Re: sudo: cd: command not found

    Thanks.

    Tell you what though, that does seem to be a bit of a boo boo. Ubuntu encourages use of sudo rather than logging in as root. Yet sudo will not work with these builtins.

    Why won't sudo work with builtins? Actually, that should read as: Why don't the writers of sudo want it to work with builtins?
    "All people are scum. No matter what they look like." ~ Spider Jerusalem, Transmetropolitan #4



  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: sudo: cd: command not found

    Quote Originally Posted by t0p View Post
    Thanks.

    Tell you what though, that does seem to be a bit of a boo boo. Ubuntu encourages use of sudo rather than logging in as root. Yet sudo will not work with these builtins.

    Why won't sudo work with builtins? Actually, that should read as: Why don't the writers of sudo want it to work with builtins?
    Exactly what would you expect from sudo cd /root?

  5. #5
    Join Date
    Jun 2007
    Location
    Paraparaumu, New Zealand
    Beans
    Hidden!

    Re: sudo: cd: command not found

    Quote Originally Posted by sisco311 View Post
    Exactly what would you expect from sudo cd /root?
    +1
    I would have thought that ordinairily something like sudo cd ... wouldn't be necessary.
    Forum DOs and DON'Ts
    Please use CODE tags
    Including your email address in a post is not recommended
    My Blog

  6. #6
    Join Date
    Oct 2004
    Location
    Kingston, On
    Beans
    Hidden!

    Re: sudo: cd: command not found

    Quote Originally Posted by t0p View Post
    Thanks.

    Tell you what though, that does seem to be a bit of a boo boo. Ubuntu encourages use of sudo rather than logging in as root. Yet sudo will not work with these builtins.

    Why won't sudo work with builtins? Actually, that should read as: Why don't the writers of sudo want it to work with builtins?
    As your user, you cannot change into that directory. As root you can. Using sudo, you escalate your privileges to be able to do that, but once that command finishes, you are back to your regular privileges. But as your user with regular privileges you are not allowed to cd there...

    The current behavior is correct.
    I lost a "z". Anyone seen it around here?

  7. #7
    Join Date
    Aug 2009
    Beans
    27

    Re: sudo: cd: command not found

    Actually it should read like this: when you do "sudo <whatever>" you are launching an *executable* called " whatever" as another user (that's what sudo does anyway). However, "cd" is not an executable - it is a built-in shell command. You are NOT launching an executable, you are telling the shell to perform some action, in this case, change the current working directory -> not the same thing! Try "help" - you will see some more of those built-ins.

    Anyway, you don't need to log in as root at all. You know, that you can do "sudo sh" to get into a root shell (again, not the same thing as logging in as root at all), right?

  8. #8
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: sudo: cd: command not found

    Well, you can run bult-in commands with sudo

    Code:
    [sisco@acme xtmp]$ pwd  # admin user
    /home/sisco/xtmp
    [sisco@acme xtmp]$ sudo -i cd /root  # as root cd to /root
    [sisco@acme xtmp]$ pwd  # admin user
    /home/sisco/xtmp

  9. #9
    Join Date
    Jun 2007
    Location
    Paraparaumu, New Zealand
    Beans
    Hidden!

    Re: sudo: cd: command not found

    Quote Originally Posted by tinivole View Post
    cd isn't a command.

    It's a builtin.
    In MS-DOS-speak, it's a built-in command, not an external command.
    Forum DOs and DON'Ts
    Please use CODE tags
    Including your email address in a post is not recommended
    My Blog

  10. #10
    Join Date
    Dec 2009
    Beans
    8

    Re: sudo: cd: command not found

    Hey,

    Try
    Code:
    $sudo su -
    cd command your way back to the desired location, and then cd to the directory of want.

    When finished ruining/fixing the system, type "su {username}" to return to your user (without root privileges, where {username} is the username).

    g000we

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •