Help answer threads with 0 replies.
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: 464

Rep: Reputation: 37
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 Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
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: 4,245
Blog Entries: 1

Rep: Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596
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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:52 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
Open Source Consulting | Domain Registration