why sudo doesn't work?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers why sudo doesn't work?
# 1  
Old 03-12-2010
why sudo doesn't work?

Code:
[test@manager ~]$ sudo -l
User test may run the following commands on this host:
    (ALL) ALL
[test@manager ~]$ sudo ls /root
anaconda-ks.cfg  Desktop      install.log.syslog                     l.of             page.html  VTune
cpi              ex           intel                                  mpd.hosts        #te.c#     workspace
cpi.c            ex1.c        libxrdisk_1_BPET46J_02_09_14.so.1.0.0  my_page          te.c       x
deli             install.log  list_disk_space_used_by_users.sh       mysqlaccess.log  test       xCATdb-dump
[test@manager ~]$ sudo useradd myuser
sudo: useradd: command not found
[test@manager ~]$

command "sudo ls" works, but why "sudo useradd myuser" doesn't work??
# 2  
Old 03-12-2010
Probably because useradd isn't in your path and has to be called using the full path (eg /usr/sbin/useradd). The reason simply is that sudo doesn't change the environment in any way, it just performs an ID change.
# 3  
Old 03-15-2010
You are correct.
But if I want to use command sudo cd /root ,
how do I use the full path of command cd?
Code:
[test@manager proc]$ whereis cd
cd: /usr/share/man/man1/cd.1.gz /usr/share/man/man1p/cd.1p.gz /usr/share/man/mann/cd.n.gz

I cann't know the full path of cd Smilie


Thanks!
# 4  
Old 03-16-2010
That's because cd isn't a program, but a shell-builtin. Always. It wouldn't be useful as a standalone utility, as it can't change the working directory of any other program.
# 5  
Old 03-19-2010
Just edit .profile and find your path and add /sbin , relaunch a shell and try it again.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exit 1 doesn't work

Hi tail -f $PROGPATH/NBU_pgbaserestore_$1.log | while read LOGLINE do if ] && ! ] then date "+%d.%B.%Y %H:%M:%S" echo "ERROR: NBU" echo "$LOGLINE" TAILKILL=$(pgrep -P $$ -x tail) kill -9 $TAILKILL exit 1 ... (3 Replies)
Discussion started by: kvaikla
3 Replies

2. Shell Programming and Scripting

-ne 0 doesn't work -le does

Hi, I am using korn shell. until ] do echo "\$# = " $# echo "$1" shift done To the above script, I passed 2 parameters and the program control doesn't enter inside "until" loop. If I change it to until ] then it does work. Why numeric comparison is not working with -ne and works... (3 Replies)
Discussion started by: ab_2010
3 Replies

3. HP-UX

Sudo doesn't work

I edited sudoers like this:vi /etc/sudoers subex ALL =(root) NOPASSWD: /usr/ccs/bin/pstack But the respective user still is prompted for password, and even when the right password is used, the command is still not launched.$sudo usr/ccs/bin/pstack 26557 We trust you have received the usual... (5 Replies)
Discussion started by: black_fender
5 Replies

4. UNIX for Dummies Questions & Answers

Why doesn't this work?

find . -name "05_scripts" -type d -exec mv -f {}/'*.aep\ Logs' {}/.LogFiles \; Returns this failure: mv: rename ./019_0120_WS_WH_gate_insideTEST/05_scripts/*.aep\ Logs to ./019_0120_WS_WH_gate_insideTEST/05_scripts/.LogFiles/*.aep\ Logs: No such file or directory I don't know why it's trying... (4 Replies)
Discussion started by: scribling
4 Replies

5. Shell Programming and Scripting

My if statement doesn't work why?

I have the following and for some reason I can't have two options together. I mean if I choose -u and -p it won't work... why? #!/bin/bash resetTime=1 mytotalTime=0 totalHour=0 totalMin=0 averagemem=0 finalaverage=0 times=0 function usage() { cat << EOF USAGE: $0 file EOF } (10 Replies)
Discussion started by: bashily
10 Replies

6. Shell Programming and Scripting

echo doesn't work right

Hi,when I run my first shell script,I got something that doesn't work right. I wrote this code in the script. echo -e "Hello,World\a\n"But the screen print like this: -e Hello,World The "-e" wasn't supposed to be printed out. Can anyone help me out?:wall: Many thanks!:) (25 Replies)
Discussion started by: Demon
25 Replies

7. Shell Programming and Scripting

if condition doesn't work

i want to get the value for column 4rth when i =4. please guide what i am doing wrong. thanks var=`cat file.csv` for i in $var; do { if ; then var4=$var4+$i fi echo $i } done I am geting this error message "0403-009 The specified number is not valid for this command." (8 Replies)
Discussion started by: sagii
8 Replies

8. Shell Programming and Scripting

ls -d doesn't work on Solaris

Hello, the ls -d command to only list directories in a directory doesn't seem to work on Solaris and the man command says to use that combination: ls -d Anyone have the same problem and find a resolve? Thanks BobK (9 Replies)
Discussion started by: bobk544
9 Replies

9. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

10. Shell Programming and Scripting

Why doesn't this work?

cat .servers | while read LINE; do ssh jason@$LINE $1 done exit 1 ./command.ksh "ls -l ~jason" Why does this ONLY iterate on the first server in the list? It's not doing the command on all the servers in the list, what am I missing? Thanks! JP (2 Replies)
Discussion started by: jpeery
2 Replies
Login or Register to Ask a Question