Jump to content

(LINUX) My drive is controlled by root and I cant access it, how do I change the control back to user?

I was trying to format drives (in EXT4) so I could use them to install Steam games on it, but after the format they show up with a key icon in GParted, and I can't write to them, how to fix?

Link to comment
Share on other sites

Link to post
Share on other sites

It's normal that drives are "owned" by root. You can have user access by mounting the drive in the file tree, say /media/steam, then use the chown command to change the ownership of the directory to your regular user. You also need to make sure the top directory has full access, using the chmod command.

 

chmod 777 /media/steam
chown <user:group> /media/steam

Next, edit your /etc/fstab to include the directory

 

/dev/<mountpoint> /media/steam ext4 defaults 0 1

Make sure /dev/<mountpoint> points to the correct drive, you can use UUID as well (in fact, it's even better, for reasons beyond this question). Do not omit the digits at the end, it designates if, when and how often the drive is checked (file check), the value of 1 means it's checked every boot. Valid values are 0, 1 and 2, with 0 meaning never and 2 every other boot. For your Steam drive, you want full drive integrity at all times.

"You don't need eyes to see, you need vision"

 

(Faithless, 'Reverence' from the 1996 Reverence album)

Link to comment
Share on other sites

Link to post
Share on other sites

If I remember correctly the key icon just indicates the partition is mounted and cannot be modified until it is unmounted.

 

You can, as root, change the owner of the devices mount point. Weather or not you should or just create a sub-directory and give yourself ownership of that is debatable.

 

Either way become root and run for example:

chown username:username /path/to/folder

If you'd like me to give you a better example of this command I can.

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, Dutch_Master said:

It's normal that drives are "owned" by root. You can have user access by mounting the drive in the file tree, say /media/steam, then use the chown command to change the ownership of the directory to your regular user. You also need to make sure the top directory has full access, using the chmod command.

 

chmod 777 /media/steam
chown <user:group> /media/steam

Next, edit your /etc/fstab to include the directory

 

/dev/<mountpoint> /media/steam ext4 defaults 0 1

Make sure /dev/<mountpoint> points to the correct drive, you can use UUID as well (in fact, it's even better, for reasons beyond this question). Do not omit the digits at the end, it designates if, when and how often the drive is checked (file check), the value of 1 means it's checked every boot. Valid values are 0, 1 and 2, with 0 meaning never and 2 every other boot. For your Steam drive, you want full drive integrity at all times.

what does media/steam and <user:group> mean? im new to linux

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Windows7ge said:

If I remember correctly the key icon just indicates the partition is mounted and cannot be modified until it is unmounted.

 

You can, as root, change the owner of the devices mount point. Weather or not you should or just create a sub-directory and give yourself ownership of that is debatable.

 

Either way become root and run for example:

chown username:username /path/to/folder

If you'd like me to give you a better example of this command I can.

how to become root?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, OmegaDaBoi said:

how to become root?

That can vary based on your Linux distro but usually

sudo -i

get's it done. You have to enter your password from there.

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, OmegaDaBoi said:

what does media/steam and <user:group> mean? im new to linux

So anything starting with / is file path, '/' is your root filesystem, so the mount command suggested means you'd find the files on the drive in the /media/steam directory.

 

I'll do you a quick "file permissions" intro:

  • Files have 3 attributes that can be set: read write and execute*
  • File have 3 places these permission can be set: for the file owner (user), for members of the files group (group), for others (everyone)

The command `chown` changes the ownership of a file (either the user, the group or both), before the : is the owner, after the is the group.

The command `chmod` changes the permissions of the file.

As an example, I've installed some game on steam, but steam has installed them owned by me (user1) and in my group (the group named user1), but I want my son (user2) to have access. There are two ways to do this, I can add permission to the 'others' section of the files permissions, but this is less than optimal as my daughter (user3) is too young to play these games, and she'd get access too.

So instead I make an "adultgames" group and add user1 and user2 to it, then change the group owner of the game

chown :adultgames /games/SomeGame --recursive

Then because you need write access to make the game run, give write access to the "group" in the file permissions

chmod g+w /games/SomeGame --recursive

So the option we are passing to chmod is [someone][give or remove][permission], in this case [group][give][write] or [g][+][w].

There are 3 someones owner=u group=g others=o, or just 'a' for all 3, it's + for give permission and - for remove permission, and 3 permission read=r write=w and run=x. SO if I wanted to remove run permission for 'others' my chmod option would be 'o-x'

 

Hope that makes sense.

 

*Yes yes, sticky bits, (s,g}uid, but they are not for this simple example.

Link to comment
Share on other sites

Link to post
Share on other sites

On 6/29/2022 at 4:05 PM, OmegaDaBoi said:

what does media/steam and <user:group> mean? im new to linux

so

sudo = superuser do this thing

chown = change owner

user = your username

:

group = your users group (usually the same as your username)

/filepath/to/your/drive

 

Full example

sudo chown 10leej:10leej /mnt/games

 

Now for you drive, you do need too until it before you can use it. Gparted won't do this the right way.

For list our all you drives with

lsblk -f

 

If a drive is mounted youll see a file path to the right. Usually drives are called /dev/sda or /dev/sdb for device, SATA disk

 

so now that you know your drives identity you need to now mount it. In this case pick an empty folder and run with it. I prefer to mount drives into /mnt, so first Im going to make a folder in there for future expandability. to do that we need root because /mnt is outside of our users folder in /home

sudo mkdir /mnt/games

 

now we caniunt the drives partition with... the mount command

sudo mount /dev/sda1 /mnt/games

 

Now so we can write to it, we need to own that folder, because twchnically it belomgs to root not the user, so we need to chown or change owner, the -R persists down the folder tree so youll own everything from that point and beyond.

sudo chown -R username:usersgroup /mnt/games

 

Now you can test it with a gentle touch  if it doesnt spit back "permission denied" it works

touch /mnt/games/test

 

 

NEVER CHMOD 777 ANYTHING EVER

777 allows anyone, from anywhere, to do anything. Never do this

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×