Hi Guys: I am trying to add password to my bash script file. So, it should ask for password when anyone try to open that file. (for eg. anyone perform cat or vi command on that file it should ask for password).

Thanks
Sonu

Recommended Answers

All 2 Replies

In general, one does not password protect a file. The way files are protected in Linux is with file permissions. If you set the file to be readable by only the owner and place it in a directory that is private to your account (also with read access turned off) then you and root are the only people who should have access to that file.

It may be that some GUI-based applications will provide this functionality but that does not directly carry over to something like cat or vi.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.