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.

William Mayfield
  • 11
  • 1
  • 1
  • 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 '21 at 20:24
  • 2
    Seems your filename contains a space so you need to quote it: `chmod +x 'first deploy.sh'. – mook765 Jan 21 '21 at 20:25

1 Answers1

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.

raj
  • 9,367
  • 2
  • 16
  • 42
  • Thank you for your comments. I new to Terminal. Any suggestions for tutorials? – William Mayfield Jan 22 '21 at 22:04
  • Just google for somethig like "basic linux commands tutorial". You can start with Canonical's own tutorial: https://ubuntu.com/tutorials/command-line-for-beginners . Other ones that look good: https://www.softwaretestinghelp.com/linux-commands-tutorial/ , https://www.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 '21 at 22:50
  • How would I correctly set up this line of code? "cd " – William Mayfield Jan 23 '21 at 00: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 ""` or `cd ''` – raj Jan 24 '21 at 11:57
  • Thanks for your help! – William Mayfield Jan 25 '21 at 15:34