Password protecting a file in linux

Posted on 2001-06-03
Last Modified: 2012-05-04
Is it possible to password protect a file in Linux ?
By this I mean that when anybody is going to view the file (whatever be the way he choose) it will ask for a password and if valid password is entered it will open the file.
                                 If any body found any hints or any suitable link just help me.
Question by:souvik_mss

Expert Comment

ID: 6152852
I don't know if you can password protect a file, but you can set the permission to deny all from read or write except a spcific group and you can add users to that particular group.

Through the WeB, it is a whole different story and it is EASY,
hope this helps

Author Comment

ID: 6155120
I don't mean to protect file through the web. I am aware about the htaccess and I don't want this. File permission is good but I want to protect the file as it can be done in MS-Word. Even if the person know my login password then also he has to know the file password seperately to open the file.
Thanks for your help.
LVL 10

Expert Comment

ID: 6155264
man crypt
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.


Expert Comment

ID: 6159155
then why not use an archiving program, like tar or zip, etc?  I'm not if tar lets you add passwords to archives, but zip does (see

Accepted Solution

alien_life_form earned 25 total points
ID: 6171075
as mentioned by rbr crypt will let you do what you are
Safer protection may be achieved by using gnupg or pgp.

Though I have never used them to this end, the programs in the openssl suite perform this task in a way that's very similar to what crypt does (so I lump them with crypt
in what follows) but using muche stronger ciphers.

This means you will be able to:

(i) crypt your files with a password of your chosing (crypt) or with your (public) key (pgp/gnupg)

(ii) decrypt your files with the same password as in (i) or with your private key (*pg)

If you are using pgp or gnupg the crypt/decrypt process is authomated so you never need to know which password is being used  - OTOH, if you want to circulate the files you have encrypted, you will have to use a differente technique.

What you do not get is application level support for
your now encrypted files. I believe that the only en-user applications that have widespread  support for encryption are mail readers. (this means you'll have to manually decrypt your stuff before uou can use it.

If this is not acceptable, perhaps using the encryption built in zip eetension, as suggested by a previous poster.

If that is important

Expert Comment

ID: 6464037
LVL 20

Expert Comment

ID: 9868826
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: alien_life_form {http:#6171075}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
qos on linux 3 98
How do I delete this file in Linux 2 456
updating the repos in yum 4 112
WiFi Router device supports GPON! 3 54
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question