0

I'm a new user to Linux and been practicing using creating/using scripts in bash.

I found a script to add new users automatically but when I try to run the script in root, I keep getting the same error message :'No such file or directory'. the message snippet is as follows:

student@Ubuntu1410:/$ chmod +x /home/student/Scripts/adduser.sh
student@Ubuntu1410:/$ ./adduser.sh
bash: ./adduser.sh: No such file or directory
student@Ubuntu1410:/$
  • Can we see the contents of the script? Where have you saved the script? have you used `cd` to go to that directory? – Tim Jun 28 '15 at 11:01

1 Answers1

0

If your script is in /home/student/Scripts/ then start it from there.

cd /home/student/Scripts
./adduser.sh

Or with path

sh /home/student/Scripts/adduser.sh

I do not know what the script is. It probably will need sudo.

Pilot6
  • 88,764
  • 91
  • 205
  • 313
  • Thanks Pilot6I navigated to my Scripts directory and then used sudo ./adduser.sh and it worked perfectly – shuggs81 Jun 28 '15 at 11:44
  • @shuggs81 Just so you know for the future, there's a way to show your current location in the filesystem next to the [command line prompt](http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html). The dot slash literally means run executable that is in the current working directory. Now, if you also [add that Scripts folder to your $PATH variable](http://askubuntu.com/q/60218/295286), you can run scripts in that folder from anywhere. – Sergiy Kolodyazhnyy Jun 28 '15 at 17:58
  • @Pilot6 good job noticing that the user wasn't in the right directory right away ! +1 – Sergiy Kolodyazhnyy Jun 28 '15 at 17:58
  • @shuggs81 If the answer solves your problem, the appropriate thing to do is accept the answer. It creates clarity the answer worked for you. – Jacob Vlijm Jun 29 '15 at 10:10