CLI How to change folder access permission for particular user
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 .
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$
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.
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.
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.
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.
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.
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:
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.