When I write bash script after that I have to set permission. How can we create script with execute permission? Try vi!
Usually that's the way:
vi blaha_zdochni.sh
write script
[slusny_clovek@testing_server_for_mankind ~]$ ll blaha_zdochni.sh
-rw-rw-r-- 1 slusny_clovek zbohom_fico 74 Mar 7 12:22 blaha_zdochni.sh
As you see the file has not execute permission.
There are 2 possibilities
1) use the umask
- but I think this is not a good choice....umask set every new files and directories but we need only script
2) use some "magic" in vi editor:
- edit this script
vi blaha_zdochni.sh
#!/bin/bash
echo I am the best prostitute on the world! Please pay me!
echo What is rm -rf? Can I start this command for my better life?
- set insert mode
- now :w - as write - !set command
:w !chmod 700 /home/betterslovakia/blaha_zdochni.sh
W12: Warning: File "blaha_zdochni.sh" has changed and the buffer was changed in
Vim as well
See ":help W12" for more info.
[O]K, (L)oad File:
- then enter
-then :wq
- check the permissions
- [slusny_clovek@testing_server_for_mankind ~]$ ll blaha_zdochni.sh
-rwx------ 1 slusny_clovek zbohom_fico 188 Mar 7 12:29 blaha_zdochni.sh
-rwx as owrner = 700!
Žiadne komentáre:
Zverejnenie komentára