LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 12-09-2006, 04:59 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
how to restrict one particular user to access one particular folder?


Hallo,

It looks easy but I dont know.
I just would like one special user cannot access one folder, but the other users can. I want all other users but this person can access this folder.

chmod / chgrp / chown are usually good to use, but I can only with that exclude all users to access the folder.

If someone know how, that could be helpful !

thank you
 
Old 12-09-2006, 06:53 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
This sort of thing is normally done by using groups. First create a group for the special folder. Then add all of the users to that group except the one user to exclude. Then make the folder owned by the group and remove access for "other". Here is an example where there are user accounts user01, user02, and user03. We want to exclude user02 from the special folder. All user accounts already belong to the users, video, and disk user groups.
Code:
groupadd specialfolder
usermod user01 -G specialfolder,video,disk
usermod user03 -G specialfolder,video,disk
chown root:specialfolder /specialfolder
chmod 770 /specialfolder
That's how I would do it.
 
Old 12-09-2006, 08:03 AM   #3
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
thank you

it worked !!

I did:
Code:
addgroup xeratul special
chgrp special /folder/
chgrp special /folder
chmod 770 /folder
cool !!!!!!!!
 
Old 12-09-2006, 11:05 AM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
I made a mistake

hwo to remove someone from the group ?
removeuser user specialgroup dont exist ...

I am looking ...
 
Old 12-09-2006, 11:23 AM   #5
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by stress_junkie
This sort of thing is normally done by using groups. First create a group for the special folder. Then add all of the users to that group except the one user to exclude. Then make the folder owned by the group and remove access for "other". Here is an example where there are user accounts user01, user02, and user03. We want to exclude user02 from the special folder. All user accounts already belong to the users, video, and disk user groups.
Code:
groupadd specialfolder
usermod user01 -G specialfolder,video,disk
usermod user03 -G specialfolder,video,disk
chown root:specialfolder /specialfolder
chmod 770 /specialfolder
That's how I would do it.
btw, I got:

#usermod user -G video,floppy,cdrom
usermod: user video,floppy,cdrom does not exist
 
Old 12-10-2006, 09:19 AM   #6
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Sorry. I put the wrong syntax for usermod. The user account name goes after all of the parameters. The usermod command has the same syntax and parameters as the useradd command.
Code:
usermod -G specialfolder,video,disk user01
usermod -G specialfolder,video,disk user03
You remove accounts from a group membership by using the usermod command and the -G parameter, then just leave the group out of the list that you write. So if a user account named user01 belongs to the video, disk, and cdrom groups, and you want to remove the cdrom group you would enter the following command.
Code:
usermod -G video,disk user01

Last edited by stress_junkie; 12-10-2006 at 09:20 AM.
 
Old 02-06-2007, 01:01 PM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Can someone explain me ??



Code:
addgroup xeratul special
chgrp special /folder/
chmod 770 /folder
->Give xeratul the acess to /folder !! (that s working great)


Code:
with having /folder owned  user/group by special already
addgroup xeratul special
chown g+rx /folder -R
chmod 770 /folder
->Give xeratul NO acess to /folder !! (that s not working )

Is it normal ?? Why chgrp is a necessity ?
(normal?)

Thank you for this very noobs simple questions !



=========
EXTRABONUS Question:
If I reinstall the Linux box, can I copypaste to the new installation the follwing files:
group,passwd,shadow ?

Last edited by Xeratul; 02-06-2007 at 01:07 PM.
 
  


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
VSFTPD - restrict user access? v00d00101 Linux - Security 2 08-09-2011 02:35 PM
samba : access denied for some user in same NT group on a folder mtrento Linux - Networking 0 06-27-2005 10:01 AM
where a service should place a folder so every user can have read/write access. shahidawan Linux - Security 3 05-07-2005 01:25 PM
restrict user to folder disorderly Linux - Security 5 03-02-2005 09:49 PM
can you restrict ftp USER access to certain ips? linuxboy69 Linux - Software 2 02-26-2004 04:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:13 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