-5

I have a script called 'Linux.sh'. This script should be executed by every one . it should prompt for password when some one edit it . I have tried by using ' vi -x linux.sh ' to password protect the file but I am not able to execute it. Is there any other solution for this scenario.

Note: this script should be executed remotely from windows box using utilities like mobaxterm

KALAI SELVAN
  • 119
  • 4

1 Answers1

1

There may be a third-party tool for this, but natively Linux doesn't support something like this. However, you can simply prevent any user but the owner from changing the file. Just set the chmod of the script to 755 (full access for the owner, read/execute for all others).

You can compare this to most of the files in "generic" folders like /bin, they all work like this. Most files under /bin have a 755 chmod, allowing the owner (usually root) full access. But as a normal user you cannot edit them. Only the owner (root) can.

To achieve this, logged in as the "owner" of the file, issue a simple:

chmod 755 /path/to/Linux.sh
Oldskool
  • 2,025
  • 1
  • 16
  • 27
  • Well I accept your answer.let me explain my need . let assume the server to be server 1. My home machine is home1. Like that many home machine are there . these home machines are windows. Server is Linux. I need to remotely execute the scripts. No one should be able to modify the script. But everyone should be able to execute it. – KALAI SELVAN Mar 05 '15 at 19:55
  • @KALAISELVAN That doesn't change the answer. As long as the owner of the script is not the user used for the mount/login to your Linux server, there's nothing they can do. – Oldskool Mar 05 '15 at 21:13