LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2009, 08:14 AM   #1
elusive_night
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Rep: Reputation: 15
Passwording Specific Files


Hello,

I have a simple n00b question for the community!

Is it possible to password access to a single file?

For example, on my machine I'm running Ubuntu 9.04, with a single user, although in order to modify certain aspects of the system I must use my super-user password (in case others use my pc). So I know my su password. I'm trying to find out if its possible to make my /etc/hosts file passworded by one of my friends, so that I cannot edit the file at all.
Its basically to make sure I dont visit the sites listed with bogus addresses during term-time (I use linux for work, windows for downtime).

Is this possible?

Many thanks,

EN
 
Old 10-04-2009, 08:26 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
You can use
Code:
chattr +i myfile
See
http://www.linuxhowtos.org/Tips%20an...cks/chattr.htm
 
Old 10-04-2009, 09:16 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by repo View Post
You can use
Code:
chattr +i myfile
See
http://www.linuxhowtos.org/Tips%20an...cks/chattr.htm
Interesting, but that doesn't do password-protection, n'est-ce pas?

elusive..;
Here's what Uncle Google found---I haven't looked into it, but it is obviously a hot topic......
http://www.google.com/search?q=linux...S177US235&aq=t
 
Old 10-04-2009, 11:50 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
Quote:
Interesting, but that doesn't do password-protection, n'est-ce pas?
Vous êtes correct monsieur,

But as I understood the question:
Quote:
I'm trying to find out if its possible to make my /etc/hosts file passworded by one of my friends, so that I cannot edit the file at all.
For me someone else made it impossible for him to edit the file, even as root.

Perhaps the OP can shed some light on this :-)
 
Old 10-04-2009, 08:07 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
This is odd
Quote:
Its basically to make sure I dont visit the sites listed with bogus addresses during term-time (I use linux for work, windows for downtime).
1. if they are bogus addresses(!), there's no site to visit
2. /etc/hosts is only relevant to your lan; on the web your ISP's DNS will take you to anywhere you want.
Also, if you know the IP, you don't need the name.
3. If you've got root, chattr won't stop you, for obvious reasons.
4. the only password protections I can think of all involve encryption, which would break the OS ie it HAS to be able to read that file to work.
5. maybe you're thinking if your friend owns the gateway box and locks you out of certain external websites using squid. Potentially this could work internally (LAN) as well if you have to go through that box.

I think we need more clarification from the OP.
 
Old 10-04-2009, 11:50 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by repo View Post
Vous êtes correct monsieur,
J'ai pensee qu'on dit typiquement: "Vous avez raison."

We must stop speaking French before a moderator catches us.....
 
Old 10-05-2009, 01:27 AM   #7
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by elusive_night View Post
Hello,

I have a simple n00b question for the community!

Is it possible to password access to a single file?

For example, on my machine I'm running Ubuntu 9.04, with a single user, although in order to modify certain aspects of the system I must use my super-user password (in case others use my pc). So I know my su password. I'm trying to find out if its possible to make my /etc/hosts file passworded by one of my friends, so that I cannot edit the file at all.
Its basically to make sure I dont visit the sites listed with bogus addresses during term-time (I use linux for work, windows for downtime).

Is this possible?

Many thanks,

EN
Obviously the goal can be achieved by encrypting the file with a password. This circumvents the filesystem protection and user scheme, for just this one file. BUT ... the file will be unreadable by the system and will be of no use. The file /etc/hosts has an important purpose on your system, and encrypting it basically makes it inaccessible.

So I guess I don't understand your question.
 
Old 10-06-2009, 06:36 AM   #8
elusive_night
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by lutusp View Post
Obviously the goal can be achieved by encrypting the file with a password. This circumvents the filesystem protection and user scheme, for just this one file. BUT ... the file will be unreadable by the system and will be of no use. The file /etc/hosts has an important purpose on your system, and encrypting it basically makes it inaccessible.

So I guess I don't understand your question.
Christ I'm so sorry I was intending to post yesterday but completely forgot!

Thats what I was afraid of in regards to encrypting, which seems the only option as far, but I cannot encrypt my hosts file!

What I need is for my hosts file, when opened, to prompt for a password. This password will be known by one of my housemates, not by me. Effectively he will be the only one that can edit my hosts file.

I've been doing a fair bit of research on this matter, and as of yet of what I have seen it does not seem possible to do this. Encryption is defiantly the best method, but not possible in this case.

chrism01: In response to your questions, in this case I will be on the university campus. In my hosts file I setup each domain which I should not be able to access with the IP of 0.0.0.0, so my OS resolves each of the those domains to that address. Works well, I had no idea that it would include top-level and sub domains!
Fortunately in my house our router is in my room, so I'm king of the house internet ^^
The case is that I want to be in my lectures, getting amazingly bored, and as so often happens decide to go on miniclip or facebook or something of the such, drawing my attention away from the lectures droning voice. By blocking these sites stop me from being able to do that. Of course, what stops me from just editing the hosts file and removing those domains entries? Nothing! Thats where the problem lies.

If only I knew how to code in anything but HTML CSS & Javascript, would definatly be good to knock something up!

Whats the primary coding language Linux uses? Is it Python? Is it possible to be able to create a script which passwords a specified file? If it is, I'll get on the case!

Thank you so much for your responses, once again the Linux community comes to the aid of its new users.
 
Old 10-06-2009, 08:20 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Well, as mentioned, as far as your machine goes, it's not possible.
You've got root and you can't encrypt /etc/hosts without breaking the system.
If you were on a landline and had to go through a proxy (as I said) then you could get your friend to own the proxy and lock you out.
If you are using wireless from the lecture and using a random wireless port/server, then you're just going to have to learn some self-discipline.
You could go old school and not take your laptop, take a pen & paper like I had to.
 
Old 10-06-2009, 09:43 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Maybe worth having a look at ;}

http://thomer.com/lockout/



Cheers,
Tink
 
Old 10-07-2009, 07:04 AM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,649

Rep: Reputation: 391Reputation: 391Reputation: 391Reputation: 391
Quote:
Originally Posted by pixellany View Post
J'ai pensee qu'on dit typiquement: "Vous avez raison."
You are right, "vous êtes correct" is understandable but not idiomatic French. As we are in this topic, the first part of your sentence can also be improved: "J'ai pensee ..." should have been "J'ai pensé que l'on disait" but you really meant "Je pense que l'on dit typiquement". Unfortunately that doesn't sounds like typical French either. I would have simply written: On dit plutôt: « Vous avez raison. »

Quote:
We must stop speaking French before a moderator catches us.....
I hope him/her to pardon our French ...
 
Old 10-07-2009, 07:34 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
@Tinkster: now that looks interesting. You can still do a reboot, but at least it makes you think a bit more.
TBH though, I'd recommend the OP learn some self-discipline as well; he/she is going to need it later in life.
 
Old 10-07-2009, 07:57 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by chrism01 View Post
@Tinkster: now that looks interesting. You can still do a reboot, but at least it makes you think a bit more.
TBH though, I'd recommend the OP learn some self-discipline as well; he/she is going to need it later in life.
True. But it's a nice tool to enforce it ;}

Not that I've ever used it - I just remembered seeing it when
I stumbled over Thomers homepage looking for vi stuff ages
ago, and having a good laugh.
Not so much about the tools' intended purpose, but because I
though the use of language, and his geeky humour were fab.
 
Old 10-08-2009, 03:03 AM   #14
elusive_night
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
You could go old school and not take your laptop, take a pen & paper like I had to.
Ne'er have I heard such blashpemy! As I'm sure as it is with most people on this forum, I can type faster than I write.

But on a lighter note, Lockout looks pretty much what was needed. Helpful, dangerous with the possibility of messing up my os with a large serving of humor on the website; perfect mix? I think so!

And the French is absolutely fine, but next time try using it backwards with every fourth letter presented in Binary; that'll make things interesting.

Will be testing Lockout on a crappy lappy of mine to make sure its configurable without fucking everything up the arse.

Many thanks,

EN
 
  


Reply


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
How to copy a specific no of files from a group of files biswa_nayak Programming 2 05-11-2008 01:21 PM
Compare files in specific directory to files on CD szim90 Linux - Newbie 3 02-10-2007 09:39 PM
LXer: Passwording a file using Apache LXer Syndicated Linux News 0 08-10-2006 12:54 PM
Passwording GRUB? Kyl3 SUSE / openSUSE 2 08-19-2005 06:41 PM
Passwording individual files SuSE05 Linux - Software 4 04-20-2005 07:14 AM


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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration