Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Make Symlink to folder on USB stick to be owned by www-data group

I have a website hosted locally on an Apache2 at my Ubuntu machine, (Kubuntu 20.04). There are some audio files on a folder at a USB stick at the path /media/MyUserName/KINGSTON/audio while the public web folder that I want to create the Symlink on it is /home/MyUserName/www/site/web

In other words, I want to create a symlink to audio at web.

I have tried:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

# on /home/MyUserName/www/site/web ...

ln -s /media/MyUserName/KINGSTON/audio audio

The symbolic link has been created successfully. However, the audio folder is not accessible by the web server, so I have tried to change the group of the symlink at the web folder to be www-data by:

sudo chgrp www-data audio

However, I got the following error:

chgrp: changing group of ‘audio’: Operation not permitted

I also tried to execute the chgrp from the USB stick path @ /media/MyUserName/KINGSTON but I got the same error.

How could I make this symlink accessible by the web server? or How to change its group?

Update

Yesterday I used the following command to mount the USB stick to a local directory and then creating the Symlink to that local directory. It worked fine and I could able to allow Apache access to that directory. However, after restarting today, the issue returned to its original state.

sudo mount -t vfat -o rw,uid=www-data,gid=www-data /dev/sdc1 /home/MyUserName/kingstone

Also today the usb stick becomes /dev/sdb1 instead of /dev/sdc1. So I had to modify it in the command above.

Now the question is: How could I mount that USB stick automatically to /home/MyUserName/kingstone?

>Solution :

See man fstab and your current file /etc/fstab for more details.

The first field is where to use

UUID=...

The second field describes the mountpoint

The third field describes the filesystem

The fourth field is where to put the options, separated by commas, corresponding to your mount command line

rw,uid=www-data,gid=www-data

The fifth field for an external drive (your USB stick) can contain a zero: 0

The sixth field for an external drive (your USB stick) can contain a zero: 0 but if you want it to be checked regularly, you can put 2 there (and use tune2fs to set the checking interval if an ext4 file system).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading