New hard drive permissions

Blade

New Member
Joined
May 9, 2018
Messages
6
Reaction score
5
Credits
0
I just installed a SSD hard drive in my PC and configured it with gParted. After mounting it I accessed the drive and all
the permissions are set to root. I can't remember if I use chmod or chown to change them over to me, as well a drawing a blank on the correct syntax for the command.
I remember starting with "sudo" then the correct command, followed I think by "sdb", and at that point it all goes blank.
It's years since I had to do any kind of CLI relating to drives, and my memory isn't what it used to be.
 


Hi @Blade and welcome to linux.org :)

(Wizard appears in a puff of smoke, dodges Blade just in time, invents new dance manoeuvre)

I'll be in and out today, so someone else may end up helping you, but I'll outline what I am looking at. Someone may have a better idea.

First up - what Linux Distro are you using on the main drive eg Ubuntu, Linux Mint, other? This, so that if we need to modify a command line syntax we can.

I would then be looking at your providing outputs for the following. Read a little further before trying them:

Code:
lsblk
sudo blkid
mount -l
ls -l /media
touch /media/yourusername/checkwrite
ls -l  /media/yourusername

blkid should be the only one requiring sudo.

If you are using eg Arch or Arch-based (eg Manjaro), or RPM-based such as Fedora, the lines featuring "media" might need to be prefaced by "/run/", that is

Code:
ls -l /run/media

Subject to those outputs, I would be looking to have you run "chown" to get permissions sorted for a session, and then likely add a line to your /etc/fstab file featuring UUID, to make the changes permanent.

I'll be back when I can.

Chris Turner
wizardfromoz
 
G'day Chris,
Another Aussie here, based in Canberra (No Canberra bashing please).

Linux Distro is: Ubuntu 16.04 LTS, and preparing to upgrade to 18.04 LTS once I get
this drive sorted out.

Cheers
Luke

Requested info:

luke@Quad-Core:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 462G 0 part /
└─sda2 8:2 0 3.8G 0 part [SWAP]
sdb 8:16 0 223.6G 0 disk
└─sdb1 8:17 0 223.6G 0 part
sr0 11:0 1 1024M 0 rom
luke@Quad-Core:~$
luke@Quad-Core:~$ sudo blkid
[sudo] password for luke:
/dev/sda1: UUID="721df058-4ed1-458f-b686-8b0ce0e28af7" TYPE="ext4" PARTUUID="000ece2b-01"
/dev/sda2: UUID="0df25f58-5430-4e3b-9c63-433cf8ced3a4" TYPE="swap" PARTUUID="000ece2b-02"
/dev/sdb1: UUID="3e55eacf-e466-4a05-8498-b823b5aafc5e" TYPE="ext4" PARTUUID="5e2c0b3a-01"
luke@Quad-Core:~$
luke@Quad-Core:~$ sudo mount -l
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=1969992k,nr_inodes=492498,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=404620k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=404620k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
luke@Quad-Core:~$ ls -l /media
total 4
drwxr-x---+ 3 root root 4096 May 10 08:07 luke
luke@Quad-Core:~$
luke@Quad-Core:~$ touch /media/luke/checkwrite
touch: cannot touch '/media/luke/checkwrite': Permission denied
luke@Quad-Core:~$ sudo touch /media/luke/checkwrite
luke@Quad-Core:~$
luke@Quad-Core:~$ ls -l /media/luke
total 4
-rw-r--r-- 1 root root 0 May 10 12:12 checkwrite
drwx------ 2 root root 4096 Sep 15 2016 Ubuntu 16.04 LTS amd64
luke@Quad-Core:~$
 
G'day Luke, regrets on the delay, busy as a blue-arsed fly until the weekend. ;)

Thanks for that output. I've got about an hour up me sleeve until I have to start cooking tea, and I'm just going to switch into my /dev/sda12, which is where my 'Xenial' Unity lives, I am guessing you are using that rather than the MATE DE (Desktop Environment), correct me any time I am wrong. Back soon.

Wizard
 
Luke try this

Code:
sudo chown $USER:$USER /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e

followed by

Code:
ls -l /media/luke

and print us the output of that last command.

Cheers

Wizard
 
Wizard,
Yes, just running a standard install of Xenial.
System did not like me using the UUID as an identifier in Terminal, so I tried /dev/sdb1 instead.

Output:
luke@Quad-Core:~$ sudo chown luke:luke /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e
[sudo] password for luke:
chown: cannot access '/media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e': No such file or directory
luke@Quad-Core:~$ sudo chown luke:luke /dev/sdb1
luke@Quad-Core:~$ ls -l media/luke
ls: cannot access 'media/luke': No such file or directory
luke@Quad-Core:~$ ls -l /dev/sdb1
brw-rw---- 1 luke luke 8, 17 May 10 08:07 /dev/sdb1
luke@Quad-Core:~$ sudo chown luke:luke /dev/sdb1
luke@Quad-Core:~$ ls -l /dev/sdb1
brw-rw---- 1 luke luke 8, 17 May 10 08:07 /dev/sdb1
luke@Quad-Core:~$

I then went into the file manager and sdb1 wasn't mounted and permissions were still showing as root.
So I mounted the drive and tried the command again, with no change to permissions when checked in file manager.

Cheers
Luke
 
Haha you're too bright for your own good, and I mean that nicely. :)

If I say "type in /media/yourusername" or "/media/<yourusername>", that's when you can type in "/media/luke".

But when I say

$USER:$USER

... I mean literally that. It is a scripting protocol.

So see how you go with (& my comment is preceded by a #)

Code:
sudo chown $USER:$USER /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e

# followed by

ls -l /media/luke

Cheers

Wiz
 
I have my odd moments of brilliance :p

Output from Terminal:
luke@Quad-Core:~$ sudo chown $USER:$USER /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e
[sudo] password for luke:
luke@Quad-Core:~$ ls -l /media/luke
total 8
drwxr-xr-x 3 luke luke 4096 May 9 13:46 3e55eacf-e466-4a05-8498-b823b5aafc5e
-rw-r--r-- 1 root root 0 May 10 12:12 checkwrite
drwx------ 2 root root 4096 Sep 15 2016 Ubuntu 16.04 LTS amd64
luke@Quad-Core:~$

When checking permissions with file manager, they're still showing as belonging to root.

Cheers
Luke
 
Afternoon all, from sunny but windy Stanthorpe SE QLD, we had our first frost a couple of days ago, with more to come, and I see you will be getting some too, Luke :p. So I'm warming my hands around a hot coffee and I'll get typing.

Luke that looks promising, and I'll let you in on a secret, at #2 I asked too soon for you to create that file checkwrite, I was one level too high and that is why you had to use sudo (good call, too).

So if you'll bear with me again, try the following and report the output:

Code:
touch /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e/checkwrite2

# followed by

ls -l /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e

In my environment, I have an external HDD where I have created a 100 GiB partition, and created the checkwrite file, and my output looks like this:

chris@XenialUnityStudy:~$ touch /media/chris/e28f64e0-8be0-4931-adfd-06822caad794/checkwrite
chris@XenialUnityStudy:~$ ls -l /media/chris/e28f64e0-8be0-4931-adfd-06822caad794
total 16
-rw-rw-r-- 1 chris chris 0 May 12 11:45 checkwrite
drwx------ 2 root root 16384 May 11 11:40 lost+found
chris@XenialUnityStudy:~$

Following that, we can look at

...they're still showing as belonging to root.

... and at the end of the exercise we can do a little housekeeping involving just one command to clean up.

Cheers

Wizard
 
This thread looks very interesting.
I’m watching it thoroughly.
Once you will solved it, I have some questions.

C u around.
 
Hi Wizard,
Windy, cold & wet describes today quite well. Had to go out in it but, kept it as short as possible.
My Fraudband (NBN) has been playing up almost since it was connected, The speed changes almost daily.
Earlier to day I recorded my fastest ever download speed through Speedtest.net and now I'm back to dial-up
speeds (again), this on a supposed 50/20 plan, and I'm the one who has to do a bunch of testing so the
NBN "engineers" can sort out what's going on.
Anyways...
Output was:
luke@Quad-Core:~$ touch /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e/checkwrite2
touch: cannot touch '/media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e/checkwrite2': No such file or directory
luke@Quad-Core:~$ ls -l /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e
ls: cannot access '/media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e': No such file or directory
luke@Quad-Core:~$ ls -l /media/luke
total 4
-rw-r--r-- 1 root root 0 May 10 12:12 checkwrite
drwx------ 2 root root 4096 Sep 15 2016 Ubuntu 16.04 LTS amd64
luke@Quad-Core:~$

It doesn't seem to like me using the UUID for some reason.

I've got to do the testing tomorrow to try and get my fraudband sorted out, so may be a bit slow on replying.

Cheers
Luke
 
By George, I do believe I've got it now :) ("About bloody time!" they chorus)

(Wizard appears in a puff of smoke and turns the dissenters into toads)

...No such file or directory

Is because your SSD is not mounted when you attempt this exercise, even though it will show in your File Manager. You could mount it by either GUI or CLI methods:
  1. GUI - open Nautilus (your File Manager in Ubuntu Unity, Ubuntu renamed it "Files" with the introduction of Unity DE around 2011), find your SSD in the left-hand pane and click it, an "up elevator" button will appear beside it.
  2. CLI - we won't do here, for now, because it will return an error (whether using /dev/sdb1 or /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e). This is because there is no entry yet in your fstab (file system table) referencing the drive. If you go to Terminal (Ctrl-Alt-t) and type and enter
    Code:
    cat /etc/fstab
    you will see what I mean.
We will add the necessary line to fstab when we have your permissions sorted out. If you are going to use the SSD perhaps as your main system venue in future, you will want it to automount, that is, mount at startup, and we will include that in fstab.

So for now, just click in Files and get that elevator button :D

Once you have done that... you had said earlier about "files" still showing as belonging to Root, and you had that line in #8

drwx------ 2 root root 4096 Sep 15 2016 Ubuntu 16.04 LTS amd64

Other than the checkwrite file I mistakenly got you to put into /media/luke , is there other material in the drive?

I'll continue to outline the next step while waiting on that information.

STEP - FIXING THOSE DRATTED PERMISSIONS

If all is good, you will type and enter

Code:
sudo chown -R $USER:$USER /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e

... note the "-R" this is for recursive, which means it will start at the top of the drive and also work through any folders, subfolders and files.

It's not something we want to do necessarily if there are system files or dependencies which may be compromised.

At the end of the process, you will be able to go into Files and right-click anything and check on permissions and find everything is owned now by you.

You will also be able to, from your usual prompt at /home/luke, perform such feats of legerdemain as

Code:
touch /media/luke/3e55eacf-e466-4a05-8498-b823b5aafc5e/checkwrite2

with impunity.

See how you go with the above, and if it works OK, we'll sort out fstab, and if your SSD supports TRIM, we'll write that into fstab as well.

@CptCharis :) Capta, if all goes OK with the OP's exercises, we'll get to your questions soon.

Cheers all

Wizard
 
Last edited:
@CptCharis - Capta, greetings.

The OP (original poster) was having problems with his NBN - Australia's National Broadband Network - if those probs are an issue it may take a while for us to hear back from him. Of course, he may actually have a life outside of computers, and Linux (what, who said that? :eek:).

In any event, I am about to wrap up for this evening, but if your questions are directly related to the subject matter, by all means post them here :p.

... and Luke, when you get the chance to give us your feedback on how you are doing, you have our undivided attention. :)

Cheers all

Wizard
 
Good morning Chris

Yeap I have some questions, rised up, as I read the entire corespondance.

While I run some of the suggested commands I realized that my HDD is under root permissions and not under my user account and as far as I understand this is by default from OS.
So why dear Luke wants to change the permissions to his personal account. I mean what is the advance in this ?

Secondary I would like to ask you, file “checkwrite” didn’t exist, you created with touch command, is that correct?
Why you did that what you want to achieve ?

That’s for now, I have to let baby retch
 
While I run some of the suggested commands I realized that my HDD is under root permissions and not under my user account and as far as I understand this is by default from OS.
So why dear Luke wants to change the permissions to his personal account. I mean what is the advance in this ?

I'll try to answer this part, if I can. Let's compare to Windows for a moment. In Windows, you have an Administrator account (like root) that is seldom used. And you have a primary user (maybe more) that is the "usual" user.... and this user has Administrator privileges at all times (can install software, etc). This is a security risk, and it is a big difference between Windows and Linux. With Windows, if the user stumbles into some malware or a virus and allows it to run or download, it has all the capability of an Administrator to do all kinds of damage. With Linux, this risk is minimized by not letting random apps on the web run while a regular user is surfing... they must get root/sudo permission... and that is often enough to wake up the user that there is a problem and to be careful.

If you run your system as root much of the time, you put yourself at risk much like the Windows users. Yet some systems, like Kali, are generally meant to be run as root. This is another reason that Kali is NOT good for beginner Linux users, but they often may not realize this potential problem.

As far as the HDD is concerned, root is typically required to mount/unmount the drive (though that may be transparent to you)... but if you are running your system as a regular user, then the files you create will belong to you, not to root. And even though some files may be "owned" by root, if they are needed by a regular user, they may be available with the proper permissions.

I hope that makes sense....

Cheers
 
Nicely put Homer :D. I was hoping to get this up in time for Capta to read over his kagianas and whole wheat bread, but I got sidetracked as usual :p

QUESTION 1
So why dear Luke wants to change the permissions to his personal account. I mean what is the advance in this ?

A lot of this depends on what purpose Luke has in mind for the SSD. If he wanted to use it as a data storage facility, and/or for backup, housing certain applications &c, then he might want total access as regular user. I require this from my external HDD, a 3TB Adata powered USB 3.0 unit.

But that is not an SSD (Solid State Drive).

Where a User has an existing HDD and then installs an SSD alongside it (rather than replacing it), the most common goal is to install an OS (in this case his Linux) onto it, then clear the HDD and use it for data storage or other purposes. This is of particular use to those with large video, photographic, or music collections.

Where a User is a dualbooter, or wishes to dualboot eg Windows and Linux, it may be that the OS which he prefers to run faster will get installed on the SSD, and the less-important one on the HDD.

Luke mentioned earlier about planning to install Ubuntu 18.04 'Bionic Beaver' once he got the permissions on the new SSD sorted out. Without knowing whether Luke plans to upgrade from within his existing 16.04 'Xenial Xerus' *, or whether he plans to install the Beaver on the SSD as a fresh, clean install, I have simply addressed his permissions questions.

* For those who wish to upgrade their existing Ubuntu to the Beaver:
  • If you are a User of 17.10 'Artful Aardvark' you can likely upgrade now
  • If you are a User of 16.04 'Xenial Xerus' you will not be able to upgrade until 18.04.1 is released, expected late July, unless you "force" the upgrade
For both categories, recommended reading is here.


QUESTION 2
Secondary I would like to ask you, file “checkwrite” didn’t exist, you created with touch command, is that correct?

That is correct.

I chose "checkwrite" as an arbitrary choice simply to test the write permissions after creation. With ""touch", don't use "test" as a name, as there is already a test command in Linux.

Checkwrite is an empty file (the type of file that touch creates), until you use a command line text editor such as nano, vi/vim &c to add input.

WIZARD'S RECOMMENDED READING ON THE ABOVE, IN-HOUSE

https://www.linux.org/threads/command-chmod.291/

https://www.linux.org/threads/file-permissions-chmod.4124/

https://www.linux.org/threads/file-permisions-chown.4125/

https://www.linux.org/threads/more-useful-commands.4131/#post-10993

https://www.linux.org/threads/lfcs-editing-and-creating-files-with-nano-and-touch.12476/


The first two articles by our intrepid leader, Admin @Rob share an amount of the same material, but both have been accessed by Members recently, who all commented favourably, I think.

A note on the last article by @Jarret B , which is great for featuring both touch and nano - if you use nano as follows:

Code:
sudo nano -m <filename>

(I use the -m switch frequently) ... you lose the ability to block text for cutting/copying/pasting. For that, do it without the -m.

BEFORE I GO (you wish)

Capta, there is something that is worth mentioning, for you, Luke and The Viewers, if you are unaware of it:

You are mainly in a Linux Mint environment, and in Mint, the FMs (File Managers - Cinnamon's Nemo, MATE's Caja, Xfce's Thunar, and (under certain conditions) KDEs Dolphin) allow for right-clicking a folder or file and "Open as Root" or "Open as Administrator" (in Xfce's case "Root Thunar").

GNOME's Files/Nautilus does not allow for that, unless perhaps with a plugin or extension.

So Users of Ubuntu 16.04 Unity (a variant of GNOME) through to and including 18.4 "Desktop" (GNOME, Ubuntu-style) are at a disadvantage if they wish to use the GUI to assume SuperUser or Root privileges. Alternative is to use Ubuntu MATE, as shown with mine below.

eClnf1e.png


SCREENSHOT 1 - FILE MANAGER PRIVILEGES UNDER UBUNTU MATE

Cheers

Wizard
 
WOW ... that's really sweet :)

You are always welcome, my friend. "Brothers in Arms" was a term you used not so long ago, and we are all Brothers (& Sisters) in Arms under Linux.

Cheers Mate

Chris Turner
wizardfromoz
 
Nicely put Homer :D. I was hoping to get this up in time for Capta to read over his kagianas and whole wheat bread, but I got sidetracked as usual :p

Hahahaha @wizardfromoz

I read many times till understand what do you mean, I didn't expect for you to be familiar with kagianas!!!:D
 
G'day Wizard,

"I'm baa..aack" :D:D:p

I just mounted the drive in the file manager and, when I checked the permissions, success.
All permissions are set to me as having full access on all three "levels".
Objective attained, thank you very much Wizard.

My NBN issue still remains unresolved. I have a 50/20 connection that will go from having a
download speed around 40Mbps to > 1Mbps (sometimes as low as 0.3Mbps). When I changed
over to this plan, I was told I could expect speeds around 44Mbps but, the fastest I've recorded
was 41.56Mbps (fastest Upload was 19.61Mbps, which is an almost perfect result). I have been
using https://www.speedtest.net for all my testing, and since I'm logged in, it records & keeps
all results. The last two times I had my speed "crash", I had a <40Mbps speed test and 6-9 hours
later I'm connecting at >1Mbps. I do a modem reboot (which takes about five minutes all up)
without any change to my speed. Rebooting the modem, usually around 5-6 days later, gets me
back to between (approx.) 23Mbps and 40Mbps, with the speed fluctuating randomly during
the day.

Maybe it's time to contact the TIO.

I'm still narcoleptic which makes planning my day a very "fluid" exercise, and that pretty well
sums up my life at the moment. When I log back in here later today, I'll make sure to mark this
as "Solved".

Cheers
Luke
 

Members online


Latest posts

Top