Take the 2-minute tour ×
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.

I have written a script abc.sh and saved it in a place called generallstuff. I navigate to this folder with:

cd ~ /generallstuff

when i try to run the script with:

chmod 755 abc.sh

i get the error "no such file or directory"

But the script is in this place, why is this. Previously i had no problem running scripts

share|improve this question
1  
chmod 755 abc.sh does not execute the script but will set the appropriate permissions for the file. When does the error happen? With chmod 755 abc.sh or after you tried to run the script? –  Ulrich Dangel Jun 15 '12 at 1:58
1  
Did you do cd ~/generalstuff instead of cd ~ /generalstuff ? –  warl0ck Jun 15 '12 at 2:56
    
i had forgotten the / in the execute command –  Johnny Williem Jun 15 '12 at 2:59
    
@JohnnyWilliem You mean you left out the / in part in my answer where I mention how to run the script? –  Levon Jun 15 '12 at 3:41
add comment

2 Answers

cd ~ /generallstuff should be cd ~/generallstuff, otherwise you will change into your home directory instead.

share|improve this answer
add comment

Where/When exactly does the error message show up?

A couple of things to check:

(1) The chmod command makes the script only executable, it does not run it. chmod +x abc.sh will make your script executable.

Aside: I much prefer the "human readable" version of the chmod command to the one using octal notation. So for instance:

chmod u+x file means change file for user to executable (or just +x, the user is implied by default).

You can specify group, others in place of u, or combinations. In place of x you can use w, r etc, again in combinations if wanted

Use + to add, - to take away attributes.

See the chmod man page for more information.

(2) Do you have the appropriate shell incantation at the top of your shell file? e.g.,

 #!/bin/bash

(or whichever shell you want)

(3) How are you running it? This way should work:

./abc.sh

(4) Note: Your cd command has a space (' ') between the ~ and /generallstuff .. hopefully that's just a typo in the posting otherwise the command will fail and you wont change directories..

share|improve this answer
    
On chmod: it depends on the initial permissions of the file. Generally a user created file has: -rw-rw-r--. +x will change this to -rwxrwxr-x = 775. 755 is usually seen on non-Linux systems, where the group name is different from user name. Use the stat command to compare numeric and human-readable formats. –  lgarzo Jun 15 '12 at 8:12
add comment

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.