Originally Posted by sherimm
I have a created a file and i want to make that file as password protected in linux.
Is there any option or command available in unix where we can make a file password protected.
thanks in advance
Linux supports file user-level security, so you can do this using the file system security.
Each file has a user and group assigned to it. Set up a group of users (in /etc/group) with all the users you want to be able to access the file listed, and use chgrp to change the file's group ownership to that group, then you just remove read, write and execute flags from the file for everyone with:
chmod o-rwx <filename>
Then if you want others to be able to access it on a case-by-case basis, then give them sudo privileges to run 'less', by editing /etc/sudoers. They can then read the file, if they must, by:
sudo less <filename>
They need to enter their password to access the file, and you get a message in the log that they've done it.