Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I have written a shell script in unix for my personal use. Now I want to make it only execute and not to read/write. Can anybody help me how to set password protect/encript my script.
If any one type vi script.sh, it should ask password, if password match then open an script. otherwise message should say deny.
I have vi editior ony not vim.
Well I am not aware of any tool or a way by which you can password protect a file in linux. However, you can play around with file system rights to restrict the access.
You can chown that file and then change the permission to 700 and that should be it. Remember that root user will be an exception in this case as root can do whatever he wants to do :-)
Yes, scorpioz22 is right it should be 711 if you want others to be able to execute that script. Sorry I didn't look at the part where you said that you want others to execute. Another way to make others to execute that script is setting up uid for that particular file so that other users will be able to run that file as if they are running using your user account.
But I am looking when try todo #vi scritp.sh , it should ask password. if type wrong password , can't use the script using vi mode. they can read using cat. but can't edit.
Now I want to make it only execute and not to read/write. Can anybody help me how to set password protect/encript my script.
You can use shc to compile your script into a binary executable, so it cannot be read.
If there is no package for your distro, you can get the sources from here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.