How to setup a user to specific directory?

So what I have already is a user by the name of “nginx” and I’m wanting to have this go into a certain directory, being on another mounted drive called “devwork” I’m wanting it to have access to basically only need access to that one directory, which will be called website.

So the structure would look like /home/nginx/somethinghere?/devwork/website

Meaning it will also need access to allow the user to run the website and have all the bells and whistles a website would need to do.

However I’m not entirely sure on how I would do this, someone from an earlier topic told me to do this this way:

Continuing the discussion from [Question] Permissions:

Make a dedicated partition on it, a filesystem too ;), and mount it to /home/that_users_name
or
just create one partition
and one dedicated directory on it
and mount that directory to /home/that_users_name
That way, the entire drive capacity is accessible to it
but you can create other directories on that drive and mount them to other places
using the drives capacity for those as well.

But like I said above I have no idea on where I would begin. Since I’m still learning, I talked to a friend of mine and they said it would be hard for me since I’ve not worked with Linux extensively. But they also mentioned to get something like this I would need to work with a program called “gparted”.

I’m honestly looking for someone to point me in the correct direction, since I’m just wanting to make this secure and also just let me and a friend mess around with HTML, CSS and JScript and anything else that may crop up. :slight_smile:

(I also intend in installing Discourse behind nginx for some community stuff.)

Thanks in advance.
~Blood

You need a structured approach.
Before you set up your webserver and such
be clear about where you will put it - and make sure that that location and user account is how you want it.

Where and how is your “devwork” drive mounted currently?

lsblk -lf

mount | grep devwork

or just

mount

It is currently mounted via the lsblk I only figured that out yesterday along with setting up SSH and SFTP.

It is also mounted through this directory.
/home/bloodshotpico/mounts/devwork

~Blood

not enough info to give useful advice
please provide the output of the commands above

lsblk -lf
returns:
sdc1 ext4 1.0 devwork UUID goes here 858.8G 1% /home/bloodshotpico/mounts/devwork

mount | grep devwork
reruns:
[bloodshotpico@BloodDev ~]$ mount | grep devwork /dev/sdc1 on /home/bloodshotpico/mounts/devwork type ext4 (rw,noatime)

~Blood

As it is now, the whole of /dev/sdc1 is only accessible via
/home/bloodshotpico/mounts/devwork

You said you didn’t want to give the whole drive to that.

But you truncated the

lsblk -lf

output
so we still don’t know whether that is the only partition on the drive.

You seem worried about giving away too much information/your UUID’s

lsblk -l

will do.

I see sorry about that, I was unsure if the UUID would get into the wrong hands or not and be used in a malicious way. Can never be too careful with stuff on the web after all. ^.^

NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda    8:0    0 931.5G  0 disk 
sda1   8:1    0 931.5G  0 part /home/bloodshotpico/mounts/storage
sdb    8:16   0 931.5G  0 disk 
sdb1   8:17   0 931.5G  0 part /home/bloodshotpico/mounts/games
sdc    8:32   0 931.5G  0 disk 
sdc1   8:33   0 931.5G  0 part /home/bloodshotpico/mounts/devwork
sdd    8:48   0 232.9G  0 disk 
sdd1   8:49   0   300M  0 part /boot/efi
sdd2   8:50   0 232.6G  0 part /
sr0   11:0    1  1024M  0 rom

Thanks for the help by the way.
~Blood

mark/highlight all of it - not line by line
and format it a s “preformatted text” this button </>
it will then appear here as it appeared on your screen

I just edited it, I probably did it as you were reading it. Discourse formatting be the formatting that is semi-annoying honestly.

I want to use the whole drive as devwork but the nginx account won’t need access to all that storage since it will only be needing to run a webserver.

I have other projects on that drive hence the name, the entire drive is for devwork however there are different dev projects I’m working on, for instance I have game servers on there and I’m going to be setting up some java and maybe python projects later on.

TLDR; Entire drive is used for devwork, but nginx only needs to be in the webside of the drive.

~Blood

Then it seems you are all set - and can turn to setting up your software.
I’ll not be able to help with that apart from pointing at the Arch wiki where probably all of that is described in detail.

Wouldn’t I need to mount the drives above bloodshotpico directory since last time it said I had no access there.

Or am I wrong about that?

~Blood

no

now, the whole of /dev/sdc1 is mounted to /home/bloodshotpico/mounts/devwork

sdc1 8:33 0 931.5G 0 part /home/bloodshotpico/mounts/devwork

You’d need to change the ownership of the “devwork” directory (recursively)
to your user bloodshotpico

You can see and compare:

ls -al /dev/sdc1
ls -al /home/bloodshotpico
ls -al /home/bloodshotpico/mounts
ls -al /home/bloodshotpico/mounts/devwork

First creating the dedicated directory on the drive /dev/sdc1
and changing the ownership of that
then mounting it
was what I tried to suggest.
It should work bot ways.

Can I not make it so every user has access to that mount and then the files they create within that mount are the ones that need the permissions for read and write?

~Blood

of course - just set the permissions accordingly on the “devwork” directory

How is that drive mounted now?
cat /etc/fstab | grep devwork

UUID=UUIDname/home/bloodshotpico/mounts/devwork ext4 defaults,noatime 0 2
That is currently how I have it mounted. :slight_smile:

~Blood

the easy, perhaps least confusing, way is:
unmount the drive
mount it to /mnt
make a directory “devwork” on it
mkdir /mnt/devwork
give that directory the proper permissions
with chown and chmod

unmount the drive from /mnt

mount that directory to
/home/bloodshotpico/mounts
again -
via a modified fstab entry (minus the “devworks” part)

ls -al /home/bloodshotpico/mounts
should then return

/home/bloodshotpico/mounts/devwork
with the proper permissions, the ones that you just set

Okay so currently I’ve mounted the drives to mnt since I’m wanting this for all my drives. (Allowing all users to access them)

However the part I’m confused by is giving them the permissions as I’m not sure what permissions they would need etc.
Along with you saying mount them in mnt and then mount something in /home/bloodshotpico/mounts I’m not sure what would be mounted here sorry?

~Blood

I just edited my post.
The permissions should (probably) be the same as for your $HOME directory /home/bloodshotpico
so that you can access it just as any location inside your $HOME directory

I have no drive to tinker around with to give you the exact commands.
There are posts here on that topic.

Which user would I be changing the permissions for? Would that be all the users I want to allow access to that specific drive or only a certain user?

~Blood