LinuxQuestions.org
Visit Jeremy's Blog.
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 07-17-2008, 06:23 AM   #1
sfkong
LQ Newbie
 
Registered: Oct 2005
Location: London
Posts: 9

Rep: Reputation: 0
Question CLI How to change folder access permission for particular user


What command exactly should i type to give only a particular user on linux to have read/write access to the /var folder?

Here's the Scenario:

List of user on linux system:
root
UserA
UserB

I only want to give UserA the ability to create new folders in the /var and /usr folder. UserA will be able to create new folder (e.g. called 'SHAREFILES'), and save/del/manipulate the files in folder 'SHAREFILES'.

Access permission to /var and /usr for UserB remain unchange, UserB cannot write or make changes to /var and /usr.


------------------------------------------------------------
NOTE: you'll probably ask me why i want to access /var and /usr folder. it's because the way the system was configured/partition/mounted, /var and /usr folder have been allocated plenty of disk space available, which will not be used. And /home folder is currently running out of space, so it is just a temporary unconventional way to have extra space to save files, as re-allocation of the free disk space is a bit complicated or maybe require reinstallation. I don't want to touch it as i am afraid of screwing up the system .

Thanks in advance.
 
Old 07-17-2008, 06:36 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
The root user can create a subdir in /var (e.g. wim_files) and set the permissions for the subdirectory so that a specific group (wim) can read, write and execute. You might have to create the group and make wim a member of it (might already be the case if your distro creates a group for each user) and you should be there.

Code:
wim@webserver:~$ ls -ld /var/wim_files
drwxrwx--- 3 root wim 4096 2008-07-17 12:32 /var/wim_files/
wim@webserver:~$ cd /var/wim_files/
wim@webserver:/var/wim_files$ ls -l
total 4
-rw-r--r-- 1 wim wim    0 2008-07-17 12:30 abc.txt
drwxr-xr-x 2 wim wim 4096 2008-07-17 12:32 def/
wim@webserver:/var/wim_files$
 
Old 07-17-2008, 10:25 PM   #3
sfkong
LQ Newbie
 
Registered: Oct 2005
Location: London
Posts: 9

Original Poster
Rep: Reputation: 0
Would it be the same if i use 'chown' command?

Say i login as Root, then create a subdir in /var (e.g. UserA_Files), then use the following command:

Code:
chown -R UserA:UserA /var/UserA_Files
Is this OK and work the same?
 
Old 07-18-2008, 12:02 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
In my opinion /var belongs to root and therefore I would use the chgrp command.
As you can see from the codeblock that I gave, anything under /var/wim_files 'automatically' belongs to wim.

At this moment I don't see a need for the -R option unless you already have files and directories in there.

It's your system, so try it.
 
Old 07-18-2008, 12:48 AM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Let me be a little stronger in making a point. Do not change system file and directory permissions, without knowing very well what you are doing. They have been established over a very long time, by many people. If you think you need to change them, you are almost assuredly taking the wrong approach, and might as well throw security, permissions, and ownership out the window.

What problem are you actually trying to solve?
 
Old 07-18-2008, 01:44 AM   #6
sfkong
LQ Newbie
 
Registered: Oct 2005
Location: London
Posts: 9

Original Poster
Rep: Reputation: 0
Ok. Thanks. Finally worked it out. Here's a report if it helps anyone else.

I use Fedora 8.

I login to root, mkdir new folder, then chgrp to the group i wanted. But it still didn't allow me to write to the folder, probably cos the owner is still root. Then i tried also chown UserA as well. And now finally I can write to the folder.

Thanks.
-------------------
EDIT:

Hi. Mr. C, Sorry Missed your post.

Yeah, that was what i was afraid that i would mess up the system.

What i wanted to do is to create a folder in /var and /usr, which is own by UserA, where only UserA have write access to it, so UserA can temporary use it to store some files, as /home is outta disk space, but there's plenty of diskspace in /var and /usr, because of the way they are mounted.

Last edited by sfkong; 07-18-2008 at 01:47 AM.
 
Old 07-18-2008, 02:25 AM   #7
faheem anwar
LQ Newbie
 
Registered: Jul 2008
Posts: 1

Rep: Reputation: 0
what is the
CREATE MODE
DIRECTORY MODE
AND
CHMOD
 
Old 07-18-2008, 02:38 AM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Let me suggest that you create a subdirectory, in each of /var/ and /usr as you need. Inside those directories, create directories for each user that requires additional storage.

mkdir /var/space1/joe
mkdir /usr/space2/sam

and

chown joe:joesgroup /var/space1/joe
chown sam:samsgroup /usr/space2/sam
chmod 700 {usr,var}/space[12]/{joe,sam}

This gives joe and sam the ability to do what they please inside the directories, but not affect anything directly in /usr and /var, and you don't pollute /usr and /var with more directories should you need additional per-user storage. You can create symlinks in each user's home that points to the space for that user as an aid.

ln -s /var/space1/joe ~joe/space
ln -s /usr/space2/sam ~sam/space

One technique when a home file system is full is to actually move the user's home directory to a file system with more space, and then just create a symlink in /home to the new location:

Last edited by Mr. C.; 07-18-2008 at 02:39 AM.
 
Old 07-18-2008, 07:27 AM   #9
FranDango
Member
 
Registered: Jun 2008
Posts: 101

Rep: Reputation: 15
I would add as root a new directory in either /usr (preferably) or /var and name it 'home2' or something like that. You can then link home2 into /home, or do the same for all new user directories withinin home2.

When creating new user accounts you can define the location of that user's home directory. It doesn't always have to be /home, so you can set /usr/home2 directly.

Linux Archive

Last edited by FranDango; 09-20-2008 at 06:09 AM.
 
Old 07-20-2008, 09:23 AM   #10
sfkong
LQ Newbie
 
Registered: Oct 2005
Location: London
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks so much Mr. C, that's exactly the details and explanation i required. And if you don't mind, can I pm you if I run into anymore question in the future I am sure you know the answer to them all.

Thanks as well FranDango for the info.

Last edited by sfkong; 07-20-2008 at 09:24 AM.
 
Old 07-20-2008, 01:34 PM   #11
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
You're welcome.

I think many people will be helpful, and often better than I can. How about asking your questions online here, and if they are not getting answered (to your satisfaction), then you can drop a PM. This way, everyone gets a learning opportunity.
 
  


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
user permission help, can not chmod files and folder niitpro Linux - Newbie 1 03-05-2008 12:41 PM
Change owner, group and permission settings on file and folder creation?? helptonewbie Linux - Newbie 9 12-17-2007 04:03 PM
Folder permission Change error diogod28 Linux - Security 6 10-07-2007 05:35 AM
Folder Access Problems: Permission Denied piva.francesco Linux - Software 3 03-28-2006 01:11 AM


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