LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 08:44 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
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, 09:01 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
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, 10:26 AM   #3
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

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

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, 09:05 AM   #5
prh47
LQ Newbie
 
Registered: Jun 2011
Distribution: Zorin Linux
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



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 05:41 AM
[SOLVED] sudo ... command not found PlatformIndependentBoy Linux - Server 7 08-06-2010 12:44 PM
why sudo root command not found? vitalstrike82 SUSE / openSUSE 5 11-07-2007 08:29 PM
/usr/sbin/sudo: line 1: root: command not found saheelahamed Linux - Software 2 08-02-2007 07:14 AM
sudo: readme : command not found vishal.thorat Linux - Security 3 07-17-2003 05:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:29 AM.

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
Open Source Consulting | Domain Registration