LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 05-22-2001, 05:28 AM   #1
souvik
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, 09:19 AM   #2
manolakis
Member
 
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
Quote:
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
Quote:
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, 10:30 AM   #3
Habitual
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, 01:35 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
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.
 
  


Reply



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 05:57 PM
Password Protect Folder?? sall Linux - Software 5 07-18-2005 06:58 AM
Password protect a website J_K9 Programming 5 07-07-2005 08:12 AM
Password protect directorys? xconspirisist Linux - Security 3 12-31-2004 08:26 PM
how to protect a file with password bobgodwinx Linux - Security 7 07-20-2004 08:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:52 AM.

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