Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Two scenarios here.

Sudo rights are given for a particular group.

a. A new user is created and is assigned to the group. b. Using this user, when we execute commands via shell script it is unable to execute any of the commands (eg., mkdir), it displays 'command not found' error. but

a. When same command is executed in an open terminal it does execute and creates directories. Any idea about the same would be greatly helpful.

Let me know if you need more information on this.

share|improve this question
    
Why do you mention sudo? Sounds like a problem with the PATH to me. –  strugee Oct 25 '13 at 6:59

1 Answer 1

Try adding the full path to the binary in your script; execute it with: /bin/mkdir You can find the full paths to commands using which followed by the command. It will then return the full path of the command e.g:

$ which mkdir
/bin/mkdir

You could also set PATH for the environment in which the script is run by using export. To do this in the script add a line similar to this: export PATH=$PATH:/bin:/usr/bin:/path/to/whateverelse in the beginning of your script.

See http://www.cyberciti.biz/faq/unix-linux-adding-path/ for details.

Personally I would recommend just using the full path to binaries though.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.