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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
|
03-01-2017, 05:40 AM
|
#1
|
Member
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154
Rep:
|
How to give file permission to a new partition
I have created a new 200gb partition on my hard disk to store a bunch of movies. I used Gparted to do this. My OS is Debian Jessie.
However I now need to assign permissions to root for rwx access. Although the partition mounts once I input my root password (using the GUI), I still can't transfer files to that partition. Can someone please advise what the command is for rwx access?
I believe it's chmod and chown but I can't understand the difference between 'permission' and 'ownership'.
If I restrict access to the partition for root only is that more secure? However I'm the only user on my PC anyway so would it be easier to simply give rwx access to the partition as 'user'?
Thank you in advance.
|
|
|
03-01-2017, 05:50 AM
|
#2
|
Senior Member
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
|
Quote:
Originally Posted by trumpforprez
I have created a new 200gb partition on my hard disk to store a bunch of movies. I used Gparted to do this. My OS is Debian Jessie.
However I now need to assign permissions to root for rwx access. Although the partition mounts once I input my root password (using the GUI), I still can't transfer files to that partition. Can someone please advise what the command is for rwx access?
I believe it's chmod and chown but I can't understand the difference between 'permission' and 'ownership'.
If I restrict access to the partition for root only is that more secure? However I'm the only user on my PC anyway so would it be easier to simply give rwx access to the partition as 'user'?
Thank you in advance.
|
The folder that you would mount your new partition to, would be the folder you would set permissions on, for that partition.
The chmod command changes file and folder permissions and therefore, is the one you would use to change them with.
For example, the following would add "execute" permission to a file named "example"
Yes it would be more secure if you restricted access (root only) to your new partition.
|
|
1 members found this post helpful.
|
03-01-2017, 06:25 AM
|
#3
|
Member
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154
Original Poster
Rep:
|
Quote:
Originally Posted by jsbjsb001
The folder that you would mount your new partition to, would be the folder you would set permissions on, for that partition.
|
Thank you. When I mount the partition it appears as:
Code:
/media/trumpforprez/movies
So do I now use the chmod command on the 'movies' folder as that is the partition? (i.e. not the 'trumpforprez' folder).
Also, is the command therefore:
Code:
chmod rwx /media/trumpforprez/movies
Also, 'movies' is the label I've assigned to the partition. If I didn't assign a label to it, then would the partition appear as its UUID? Just wondering.
|
|
|
03-01-2017, 06:29 AM
|
#4
|
Senior Member
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
|
Quote:
Originally Posted by trumpforprez
Thank you. When I mount the partition it appears as:
Code:
/media/trumpforprez/movies
So do I now use the chmod command on the 'movies' folder as that is the partition? (i.e. not the 'trumpforprez' folder).
Also, is the command therefore:
Code:
chmod rwx /media/trumpforprez/movies
Also, 'movies' is the label I've assigned to the partition. If I didn't assign a label to it, then would the partition appear as its UUID? Just wondering.
|
No, you need to create a folder on your / (root partition) for your new partition, like, for example /movies And then you would set permissions on the "movies" folder in that case.
The /media folder is for removable devices (USB sticks, etc), that you plan on removing at some point.
|
|
|
03-01-2017, 06:40 AM
|
#5
|
Member
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154
Original Poster
Rep:
|
Quote:
Originally Posted by jsbjsb001
No, you need to create a folder on your / (root partition) for your new partition, like, for example /movies And then you would set permissions on the "movies" folder in that case.
The /media folder is for removable devices (USB sticks, etc), that you plan on removing at some point.
|
Yes, but when I use the GUI to open the partition, it will open the partition at:
Code:
/media/trumpforprez
Also, if I create a folder on my root partition will this mean the new 'movies' partition will always automatically mount when booting? I wanted to avoid this as I won't always use the partition.
|
|
|
03-01-2017, 06:59 AM
|
#6
|
Senior Member
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
|
Quote:
Originally Posted by trumpforprez
Yes, but when I use the GUI to open the partition, it will open the partition at:
Code:
/media/trumpforprez
Also, if I create a folder on my root partition will this mean the new 'movies' partition will always automatically mount when booting? I wanted to avoid this as I won't always use the partition.
|
Yes, that's because you are mounting it like it's a USB stick.
First step, create a folder as mentioned above and then add your new partition to fstab, pointing to the folder you have created, for your new partition.
And then you can use chmod and chown (or the GUI) to set the permission's on it, you would like.
The chown command, changes ownership of said file/folder.
|
|
|
03-01-2017, 07:16 AM
|
#7
|
Member
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154
Original Poster
Rep:
|
Quote:
First step, create a folder as mentioned above and then add your new partition to fstab, pointing to the folder you have created, for your new partition.
|
I think this will automatically mount the new partition every time when booting the OS.
However I wanted to mount the partition only on a few occaisons.
But if I do mount it occaisonally, how can I then assign rwx permission to root?
|
|
|
03-01-2017, 07:19 AM
|
#8
|
LQ Guru
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,774
|
If you do not want to automatically mount the 'movies' partition, you can put an entry in the /etc/fstab file for that partition with the 'noauto' option. The link below has some detailed info on the fstab entries. Scroll down the page to the 'Options' section.
https://help.ubuntu.com/community/Fstab
Is this a Linux filesystem on the partition? Also, what exactly are the owner:group and permissions now? You can get that with the command:
ls -ld /media/username/movies
|
|
2 members found this post helpful.
|
03-01-2017, 07:59 AM
|
#9
|
Member
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154
Original Poster
Rep:
|
Quote:
Originally Posted by yancek
If you do not want to automatically mount the 'movies' partition, you can put an entry in the /etc/fstab file for that partition with the 'noauto' option. The link below has some detailed info on the fstab entries. Scroll down the page to the 'Options' section.
https://help.ubuntu.com/community/Fstab
|
I see. So if I create a file called /movies as a mount point and I know the UUID for the new partition, then I would put the following in etc/fstab:
Code:
UUID=f354c845-f1dc-4df2-8e27-c231xxxx4be /movies ext4 noauto
Is this correct?
Also, what is the command to assign rwx permission to root for the new partition?
Quote:
Is this a Linux filesystem on the partition? Also, what exactly are the owner:group and permissions now? You can get that with the command:
ls -ld /media/username/movies
|
Yes, the filesystem is ext4.
The output for ls -ld is:
Code:
ls -ld /media/trumpforprez/movies
drwxr-xr-x 3 root root 4096 Mar 1 10:49 /media/trumpforprez/movies
|
|
|
03-01-2017, 09:35 AM
|
#10
|
Senior Member
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364
|
Quote:
Originally Posted by trumpforprez
I see. So if I create a file called /movies as a mount point and I know the UUID for the new partition, then I would put the following in etc/fstab:
Code:
UUID=f354c845-f1dc-4df2-8e27-c231xxxx4be /movies ext4 noauto
Is this correct?
Also, what is the command to assign rwx permission to root for the new partition?
Yes, the filesystem is ext4.
The output for ls -ld is:
Code:
ls -ld /media/trumpforprez/movies
drwxr-xr-x 3 root root 4096 Mar 1 10:49 /media/trumpforprez/movies
|
root already has rwx permissions to your current mount point and the fstab entry you are planning to use will also give those permissions to root for your new mount point. If you are really planning to use the drive only as root, you're set. Personally, I would avoid using root for anything but system maintenance tasks and would set permissions up for which ever user account you usually use. For example :
# chown -R user:user /movies
.... to give the ownership to your own user account and group (replace the word user by the name of your user id)
# chmod -R 0775 /movies
.... to give your user id and group rwx privileges to /movies and everyone else read and execute (r_x)
Cheers,
Last edited by Rickkkk; 03-01-2017 at 09:40 AM.
|
|
2 members found this post helpful.
|
03-01-2017, 10:07 AM
|
#11
|
Senior Member
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,950
|
Because I mount videos in /etc/fstab, I get
Code:
drwxr-xr-x 6 jeremy public 4096 Feb 4 16:16 /mnt/video/
|
|
|
03-01-2017, 10:38 AM
|
#12
|
Member
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154
Original Poster
Rep:
|
Quote:
Originally Posted by Rickkkk
root already has rwx permissions to your current mount point
|
This is the bit that confuses me. I created a partition in ext4 format on my hard disk. This partition is storage space for media files.
I then used the GUI to open up the partition and a dialog box asked for root password. This leads me to think that I now have access to the new partition as root.
But when I try to move media files onto the new partition (using the GUI - not terminal) it won't do it.
However if I use the terminal as root, I can copy files onto the new partition.
So this means root has rwx access to the new partition when using the terminal but not when using the GUI (xfce).
Quote:
and the fstab entry you are planning to use will also give those permissions to root for your new mount point. If you are really planning to use the drive only as root, you're set.
|
So if put the UUID of the partition in /etc/fstab then I can use the GUI to transfer files to that partition?
Of course, I can already do this function using the terminal.
|
|
|
03-01-2017, 10:44 AM
|
#13
|
Senior Member
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,950
|
Yes.
|
|
1 members found this post helpful.
|
03-01-2017, 11:25 AM
|
#14
|
Member
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154
Original Poster
Rep:
|
Quote:
Originally Posted by JeremyBoden
Yes.
|
Ok, thanks for that.
But it can be frustrating when we come across inconsistencies like this (i.e copying files works via command line but not via the GUI).
|
|
|
03-01-2017, 11:51 AM
|
#15
|
Senior Member
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364
|
Quote:
Originally Posted by trumpforprez
This is the bit that confuses me. I created a partition in ext4 format on my hard disk. This partition is storage space for media files.
I then used the GUI to open up the partition and a dialog box asked for root password. This leads me to think that I now have access to the new partition as root.
But when I try to move media files onto the new partition (using the GUI - not terminal) it won't do it.
However if I use the terminal as root, I can copy files onto the new partition.
So this means root has rwx access to the new partition when using the terminal but not when using the GUI (xfce).
So if put the UUID of the partition in /etc/fstab then I can use the GUI to transfer files to that partition?
Of course, I can already do this function using the terminal.
|
Here's what I think it happening:
- You created the partition with root, so it is owned by root (confirmed by your ls -l output as mentioned in my previous post)
- You currently have no fstab entry specifying the appropriate options, so when you use the GUI tool in xfce to access the partition, you are asked for the root password. This is as expected.
- The GUI then dutifully "opens" the partition. What has actually happened here is that you have mounted the partition as root.
- When you try to actually write to the now root-mounted partition with the xfce GUI, you are attempting to do that under your regular user id session (assuming you're not logged in as root). Again, that you are not permitted to do this is normal.
So by changing the ownership and permissions as described above, and properly mounting the partition via an fstab entry, you should no longer run into these issues. There are also options that can be used when manually mounting a partition that will give certain or all users rwx permissions, but in your situation, I don't see that as the most efficient solution.
Finally, the reason you are able to write to the partition using terminal commands and not with the GUI, is probably because your are issuing those terminal commands as root (or using su or sudo ...) but as mentioned earlier, your are using the GUI under your session user id.
Hope this helps to explain things. Cheers !
Last edited by Rickkkk; 03-01-2017 at 11:53 AM.
|
|
2 members found this post helpful.
|
All times are GMT -5. The time now is 05:24 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|