LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-01-2017, 06:40 AM   #1
trumpforprez
Member
 
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154

Rep: Reputation: Disabled
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.
 
Old 03-01-2017, 06:50 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth? I would say I hope so but I'm not so sure about that... I could just be a figment of your imagination too.
Distribution: Currently OpenMandriva. Previously openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,436

Rep: Reputation: Disabled
Quote:
Originally Posted by trumpforprez View Post
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"

Code:
chmod +x example
Yes it would be more secure if you restricted access (root only) to your new partition.
 
1 members found this post helpful.
Old 03-01-2017, 07:25 AM   #3
trumpforprez
Member
 
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jsbjsb001 View Post
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.
 
Old 03-01-2017, 07:29 AM   #4
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth? I would say I hope so but I'm not so sure about that... I could just be a figment of your imagination too.
Distribution: Currently OpenMandriva. Previously openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,436

Rep: Reputation: Disabled
Quote:
Originally Posted by trumpforprez View Post
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.
 
Old 03-01-2017, 07:40 AM   #5
trumpforprez
Member
 
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jsbjsb001 View Post
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.
 
Old 03-01-2017, 07:59 AM   #6
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth? I would say I hope so but I'm not so sure about that... I could just be a figment of your imagination too.
Distribution: Currently OpenMandriva. Previously openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,436

Rep: Reputation: Disabled
Quote:
Originally Posted by trumpforprez View Post
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.
 
Old 03-01-2017, 08:16 AM   #7
trumpforprez
Member
 
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154

Original Poster
Rep: Reputation: Disabled
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?
 
Old 03-01-2017, 08:19 AM   #8
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 8,906

Rep: Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859Reputation: 1859
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.
Old 03-01-2017, 08:59 AM   #9
trumpforprez
Member
 
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
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
 
Old 03-01-2017, 10:35 AM   #10
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec, CANADA
Distribution: Arch
Posts: 1,234

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by trumpforprez View Post
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 10:40 AM.
 
2 members found this post helpful.
Old 03-01-2017, 11:07 AM   #11
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,652

Rep: Reputation: 362Reputation: 362Reputation: 362Reputation: 362
Because I mount videos in /etc/fstab, I get
Code:
drwxr-xr-x 6 jeremy public 4096 Feb  4 16:16 /mnt/video/
 
Old 03-01-2017, 11:38 AM   #12
trumpforprez
Member
 
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Rickkkk View Post
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.
 
Old 03-01-2017, 11:44 AM   #13
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,652

Rep: Reputation: 362Reputation: 362Reputation: 362Reputation: 362
Yes.
 
1 members found this post helpful.
Old 03-01-2017, 12:25 PM   #14
trumpforprez
Member
 
Registered: Nov 2016
Location: UK
Distribution: Debian Jessie
Posts: 154

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by JeremyBoden View Post
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).
 
Old 03-01-2017, 12:51 PM   #15
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec, CANADA
Distribution: Arch
Posts: 1,234

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by trumpforprez View Post
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 12:53 PM.
 
2 members found this post helpful.
  


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
How can i give permission for AD OU keysys Linux - Networking 4 12-23-2012 12:34 AM
Installed slackware-try to access FAT32 file partition-permission denied-? linus72 Slackware 10 03-23-2009 09:23 AM
Give the root Permission to other user for manage File/Directory shipon_97 Linux - Newbie 2 01-28-2007 12:46 PM
how to give 'guest' rwx permission on a file/directory RH9Linux Linux - Software 3 06-27-2005 09:59 PM
How to give permission to /home partition Micro420 Linux - General 3 05-09-2005 06:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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