LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 07-17-2006, 04:11 AM   #1
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Rep: Reputation: 31
whereis cd? sudo doesn't find cd


Hi!
I'm using Fedora 4. sudo doens't find the command cd. When I use cd as a simple user, no problem, when I use it as sudo: doesn't find it. when I do whereis cd, I get:
Quote:
cd: /usr/share/man/man1p/cd.1p.gz /usr/share/man/man1/cd.1.
gz
and doing find / -name cd doesn't help either.
Where is my cd command? How can I make my sudo find it?

Thanks.
 
Old 07-17-2006, 05:06 AM   #2
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Using the command "type", you can find that cd is a shell builtin command. Eg:
Code:
$ type cd
cd is a shell builtin
I hope this helps
--Ian
 
Old 07-17-2006, 05:11 AM   #3
tets
LQ Newbie
 
Registered: Aug 2005
Location: Prague, Czech Rep.
Distribution: Funtoo, Gentoo, Debian, Ubuntu
Posts: 24

Rep: Reputation: 15
Start new shell:
sudo sh

or
sudo sh -c "cd /somedir; do something"

Tets :-)
 
Old 07-17-2006, 05:15 AM   #4
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Sorry, I missed the bit about sudo not finding the cd command.

You shouldn't need to use sudo to simply change directory. You should be able to change directory as a normal user, and then use sudo to do whatever you need to do from within that directory.

If you use the command "sudo -s", you get a new shell with root privilleges.

I hope this helps
--Ian
 
Old 07-17-2006, 05:19 AM   #5
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
That's because cd is not the name of an executable, it's a directive to the shell to change directory. If you have a look at this man page, you can see it's part of the command that's built into BASH.

As you can only use sudo to execute one command at a time, doing sudo cd xxxxx wouldn't be of any use because as soon as the cd command ended it would drop back out of the sudo shell back into your BASH shell and your directory wouldn't have changed.

What are you trying to do?
 
Old 07-17-2006, 07:07 AM   #6
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Original Poster
Rep: Reputation: 31
Thanks for the answers. "sudo sh" or "sudo -s" will help me.
Quote:
Originally Posted by IBall
You shouldn't need to use sudo to simply change directory. You should be able to change directory as a normal user, and then use sudo to do whatever you need to do from within that directory.
I would need "sudo cd" do enter the /root directory as a normal user. But "sudo -s" is actually quite confortable, I just try to be root as little as possible.
 
Old 07-17-2006, 11:38 AM   #7
michapma
Member
 
Registered: Oct 2003
Location: Zürich
Distribution: Debian
Posts: 537

Rep: Reputation: 39
Quote:
Originally Posted by xpucto
Thanks for the answers. "sudo sh" or "sudo -s" will help me.

I would need "sudo cd" do enter the /root directory as a normal user. But "sudo -s" is actually quite confortable, I just try to be root as little as possible.
I don't remember, but perhaps you can list the contents of /root as a normal user; then you can just use sudo for whatever other commands you need.

I'm less careful, I just use su and then log back out as soon as I'm done. Someday I'll figure out groups and sudo and learn how to create a special account (say sysadmin) for sudo activities, so that I can "su sysadmin" and then use its sudo powers, so that my normal user has nearly no sudo powers. For that extra layer of paranoia.
 
  


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
Restricting Editing in Sudo (Advanced Sudo Question) LinuxGeek Linux - Software 4 11-04-2006 04:20 PM
LXer: Locate, Find, and Whereis LXer Syndicated Linux News 0 03-28-2006 04:06 PM
sudo apt-get install acroread returns "Couldn't find package acroread" swiadek Ubuntu 3 02-13-2006 11:52 AM
whereis AcidRip installed it can't find it lagu2653 Linux - Software 11 11-06-2005 11:44 AM
where to find freeware.sudo touny AIX 2 07-17-2005 09:41 PM


All times are GMT -5. The time now is 02:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration