1

I read in Stack Exchange that the message I am getting, "No such file or directory” refers to not being in the directory where the file I need resides. The article suggested using “cd" to change the directory. I did and ran the “chmod +x first deploy.sh”. The result was: chmod: first: No such file or directory” the next line contained: “chmod: deploy.sh: No such file or directory”

Next I went to: "sudo chmod +x deploy.sh”. received the request for my password, I entered my administrator password and received: “chmod: deploy.sh: No such file or directory.

2
  • What is "first" in this context? Guessing: it is part of the file name and you missed a character (like first_deploy.sh ) You can use auto-complet: so type chmod +x fi and the press TAB. It will fill in the remainder of the file name. If the missing char is a space it will also escape it
    – Rinzwind
    Jan 21, 2021 at 20:24
  • 2
    Seems your filename contains a space so you need to quote it: `chmod +x 'first deploy.sh'.
    – mook765
    Jan 21, 2021 at 20:25

1 Answer 1

2

In all Linux commands, a space is treated as a separator that separates command arguments. So if you try to do chmod +x first deploy.sh the command understands that you want to change permissions on two files: first and deploy.sh. I guess none of these files exists, so you get "No such file or directory" error.

Whenever you want to use a file name that contains spaces, you need to quote it, that is, enclose in either single or double quotes, like: chmod +x "first deploy.sh". You may also quote the space itself, preceding it with a backslash: chmod +x first\ deploy.sh.

Personally I would suggest avoiding filenames with spaces and changing the file name to first_deploy.sh - it will be easier to use. It's a common convention to use underscores in filenames that consist of multiple words.

5
  • Thank you for your comments. I new to Terminal. Any suggestions for tutorials? Jan 22, 2021 at 22:04
  • Just google for somethig like "basic linux commands tutorial". You can start with Canonical's own tutorial: ubuntu.com/tutorials/command-line-for-beginners . Other ones that look good: softwaretestinghelp.com/linux-commands-tutorial , guru99.com/must-know-linux-commands.html . You can also ask separate question here about recommended command line tutorial and see what people will recommend.
    – raj
    Jan 22, 2021 at 22:50
  • How would I correctly set up this line of code? "cd <path to \scripts\macos folder>" Jan 23, 2021 at 0:20
  • What are the < and > characters in the above line? Are they a literal part of the file/directory name? Anyway, quoting should still work: cd "<path to \scripts\macos folder>" or cd '<path to \scripts\macos folder>'
    – raj
    Jan 24, 2021 at 11:57
  • Thanks for your help! Jan 25, 2021 at 15:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .