View Full Version : [SOLVED] cd commande not possible as su

August 29th, 2010, 06:54 AM
After installing 10.4 I want to check that some file is present under a su directory but the cd command doesn't work after "sudo".

The problem is the same for both 32 bits and 64 bits versions.

Need help.

August 29th, 2010, 09:37 AM
Please post the exact commands and the output from the system.

August 29th, 2010, 12:40 PM
Here what I get

jaaf@jaaf-desktop:~$ sudo cd /usr
[sudo] password for jaaf:
sudo: cd: command not found

August 29th, 2010, 01:51 PM
But is
cd /usr not enough?

August 29th, 2010, 03:08 PM
In such a case yes.
I just wanted to demonstrate that the cd command was not found.
In reallity I wanted to access a directory I have no permission for.

sudo cd /var/lib/nxserver/home to check for the presence of a file

jaaf@jaaf-desktop:~$ cd /var/lib/nxserver/home
bash: cd: /var/lib/nxserver/home: Permission non accordée

jaaf@jaaf-desktop:~$ sudo cd /var/lib/nxserver/home
[sudo] password for jaaf:
sudo: cd: command not found

August 29th, 2010, 03:14 PM
In fact I came to this because

From https://help.ubuntu.com/community/FreeNX

Now, we need to transfer the key to the client machine so that it can be imported in the FreeNX client application. First copy the key to your home directory on the server machine:

sudo cp /var/lib/nxserver/home/custom_keys/client.id_dsa.key ~/

jaaf@jaaf-desktop:~$ sudo cp /var/lib/nxserver/home/custom_keys/client.id_dsa.key ~/
cp: impossible d'évaluer «/var/lib/nxserver/home/custom_keys/client.id_dsa.key»: Aucun fichier ou dossier de ce type


jaaf@jaaf-desktop:~$ sudo cp /var/lib/nxserver/home/custom_keys/client.id_dsa.key ~/
cp: impossible to evaluate «/var/lib/nxserver/home/custom_keys/client.id_dsa.key»: No file or folder of this type

and what to think about this?

jaaf@jaaf-desktop:~$ which cp
jaaf@jaaf-desktop:~$ which cd
jaaf@jaaf-desktop:~$ cd Documents
jaaf@jaaf-desktop:~/Documents$ cd ..
jaaf@jaaf-desktop:~$ sudo cd Documents
sudo: cd: command not found

August 29th, 2010, 04:03 PM
That's because "cd" is not a program, it is a command that is built-in to the shell (so there is no executable file named "cd" anywhere). And by some reason you can't use sudo to run a built-in command... That's just the way it is.
The only way for you to cd as superuser is to switch to a root shell first:

sudo -i
cd /whatever/wherever/And don't forget to exit the root shell when you are done with what you're doing:


But your main problem is that you are trying to copy a file that does not exist (/var/lib/nxserver/home/custom_keys/client.id_dsa.key)...

August 29th, 2010, 04:34 PM
Thank you very much.
I feel better now as I discover something I ignored (I means build-in commands and sudo -i).

You are right as for the rest.