LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 01-06-2011, 09:44 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,277

Rep: Reputation: 49
sudo cd /root gives 'sudo: cd: command not found'.


Kernel 2.6.21.5, Slackware 12.0

Hi:
Code:
# cat /etc/sudoers
root   ALL = (ALL) ALL
pete   ALL = (ALL) NOPASSWD: ALL
Code:
pete$ ls /root
permission denied
pete$ sudo ls /root
loadlin.txt loadlin.zip
pete$ cd /root
-bash: cd: /root: Permission denied
pete$ sudo cd /root
sudo: cd: command not found
pete$
On the other hand
Code:
pepe$ echo $SHELL
/usr/bin/bash
pepe$ sudo echo $SHELL
/usr/bin/bash
So, I do not understand why the notification "sudo: cd: command not found", considering cd is a bash built-in command. Any suggestion will be welcome.
 
Old 01-06-2011, 10:01 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,652

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
Precisely because "cd" is a shell builtin and not a binary, and sudo is not bash (nor even a shell). So sudo can't find any "cd" command. That's how it works, so you'll need to find some way around using "sudo cd", like by using complete paths in your commands or just doing "sudo bash".
 
1 members found this post helpful.
Old 01-06-2011, 11:26 AM   #3
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,038

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Try:
Code:
sudo -i
cd  /
cd  /root
ls
exit
 
1 members found this post helpful.
Old 01-06-2011, 12:51 PM   #4
siranjeevi
Member
 
Registered: May 2010
Location: India
Posts: 73

Rep: Reputation: 7
Not sure about Slackware but for Ubuntu you can use

sudo su
cd /root
 
1 members found this post helpful.
Old 03-03-2012, 10:05 AM   #5
prh47
LQ Newbie
 
Registered: Jun 2011
Posts: 6

Rep: Reputation: 2
Thanks

Thanks for the help. That did the trick for me on Linux Mint.

Quote:
Originally Posted by siranjeevi View Post
Not sure about Slackware but for Ubuntu you can use

sudo su
cd /root
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo slackpkg = command not found gabrielmagno Slackware 10 06-22-2013 06:41 AM
[SOLVED] sudo ... command not found PlatformIndependentBoy Linux - Server 7 08-06-2010 01:44 PM
why sudo root command not found? vitalstrike82 Suse/Novell 5 11-07-2007 09:29 PM
/usr/sbin/sudo: line 1: root: command not found saheelahamed Linux - Software 2 08-02-2007 08:14 AM
sudo: readme : command not found vishal.thorat Linux - Security 3 07-17-2003 06:56 PM


All times are GMT -5. The time now is 03:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration