Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-22-2001, 06:28 AM   #1
LQ Newbie
Registered: Apr 2001
Location: Calcutta, India
Posts: 16

Rep: Reputation: 0

Is it possible to password protect a file that I want to ?
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 allow.
If any body found any hints or any suitable link just help me.
Old 11-06-2015, 10:19 AM   #2
Registered: Nov 2006
Distribution: xubuntu
Posts: 418

Rep: Reputation: 31
I am not the best linux engineer but I believe that you can do that by using the chown command.
Chown is used to change the ownership of a file or directory to a specific user. In your case you can
chown root file
which will give the ownership of the file to the superuser. Setting the case that your file is a textfile you can view this file using the following command
sudo cat file
When you execute this command you will be prompted for the root password in order to view the file.

Hope this helps.
Old 11-06-2015, 11:30 AM   #3
LQ Guru
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM 17.1
Posts: 5,001
Blog Entries: 9

Rep: Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212
Depends where this file is.
chown root <file> works as manolakis has said.

Being able to see there is a file at say /home/souvik/secret
does not mean that user fred can open it, read it, or anything other than "see" the file where it is at.
Old 11-06-2015, 02:35 PM   #4
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 2,648

Rep: Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755
Well, what platform? BS2000, for example, supports file-passwords (3pwd/file: read/write/execute), but it won't ask for it: if you have specified the password before the operation you can read/write/execute the file, otherwise not.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protect folder? sall Linux - Security 4 07-18-2005 06:57 PM
Password Protect Folder?? sall Linux - Software 5 07-18-2005 07:58 AM
Password protect a website J_K9 Programming 5 07-07-2005 09:12 AM
Password protect directorys? xconspirisist Linux - Security 3 12-31-2004 09:26 PM
how to protect a file with password bobgodwinx Linux - Security 7 07-20-2004 09:47 AM

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration