Give permission of execute to some files at a time

Hello world, I try to give permission to execute to some files as program.
All files begin for "UBU", are .sh and are in the same folder call "myworks".
I found this instruction but not works. Please, help.

#!/bin/bash
chmod u+x UBU*.sh

Thanks very much.
Asis

Hi Asis,

check these:

#!/bin/bash should indeed be the first line of the script.
Make sure that there ar no empty lines or other characters preceeding it.

chmod u+x should indeed be run after you saved your script.
(it should not be a line in the script)

Your script will only run if you call it when one of these rules are met:

  1. you give the complete path to the script e.g: /home/asis/scriptdir/script.sh
    or
  2. your current working directory is the script directory and you call your script by preceeding it with a dot-slash combi e.g: ./script.sh
    or
  3. your script is in a directory in the search path, then you can use the bare script name e.g: script.sh

Hope this helps :slight_smile:

Thanks very much, but I am so dummy.
Now, after read you, my script is:

#!/bin/bash
chmod u+x UBUfijo.sh
sleep 2
chmod u+x UBUale.sh
sleep 2
chmod u+x UBUclic.sh
sleep 2
chmod u+x UBUbucle.sh
sleep 2

But not works :frowning:
All the .sh are in the same folder called "myworks".
Please a bit more of help.
Thanks
Asis

yes but first answer these questions for me:

  1. what exactly do you expect the above mentioned script to do ?

  2. Why do you have chmod inside the above mentioned script ?

  3. Why do you think that your UBU scripts don't have permissions ?
    (you possibly have set them multiple times by now)

  4. Have you checked the permissions after you changed them ?
    ls -l UBU*

  5. Have you actually tried to run your UBU files or have you only played around with chmod ?

  6. have you made the above mentioned script executable too ?

Thanks. I try to save time. I mean, every time I have to run any script, I have to go to Properties > Permission > give permission to run as program.
I change the scripts almost every day so, I have to go one by one with the "give permission to run as program"
As I don't understand too much, I thought there is a possibility to run JUST one script with the "Properties > Permission > give permission to run as program" and then, semi-automatically, have all the others scripts prepare to run.
Thanks very much for help a Dummy like me :slight_smile:
Asis

Thanks. I try to save time. I mean, every time I have to run any script, I have to go to Properties > Permission > give permission to run as program.

You only have to give permission once, not every time.

I change the scripts almost every day so, I have to go one by one with the "give permission to run as program"

You only have to give permission once, not every time. It stays executable even if you change the file.

As I don't understand too much, I thought there is a possibility to run JUST one script with the "Properties > Permission > give permission to run as program" and then, semi-automatically, have all the others scripts prepare to run.

Yes, and that script needs permission too ofcourse :wink:

No, you don't need that script.
You only need to set the permission once. No need to do it every time.
Permissions are permanent, until you change them yourself.

You can do that from the commandline with chmod u+x UBU*.sh
Explanation about chmod: man chmod

You can check permission with ls -l UBU*.sh
If you see something like:
-rwxrw-r-- 2 asis asis 4096 nov 8 15:22 UBUfijo.sh
-rwxrw-r-- 2 asis asis 4096 okt 7 13:17 UBUale.sh
-rwxrw-r-- 1 asis asis 292 jan 26 2021 UBUclic.sh

it means that its permission is set executable ( you must see an 'x' in the first field)

Thanks very much. More explains by my side: I do the changes in the files by remote: I do in my computer and go to the other computer, I use Google remote desktop to "visit" the other computer. That's why lost the permission every time and have to redo.
So, I think I need the magic-script to do it once.
I hope I explain correct.
Thanks very much for help me.
Asis

ooppppsss reading slowly, you have reason and solve my dude in just two steps:

  1. Open from the folder the terminal
  2. chmod u+x UBU*

and done :slight_smile: So, thanks very very very much for your help. Solved in a quickly way.
Have a nice and sunny day.
Asis