USB drive auto-mounted by user but gets write permissions for root only

Solution 1:

A possible reason could be that you formatted/created the storage disk with a tool with root privilege and so the file-system created was owned by the root.

Let's have a look at the o/p of your ls commands:

$ ls -ld /media/adam/WDPassport2T
drwxr-xr-x 4 root root 4096 Jan 15 16:57 /media/adam/WDPassport2T
$ ls -l /media/adam/WDPassport2T
total 20 
drwxr-xr-x 2 root root 4096 Jan 15 16:57 backuppc 
drwx------ 2 root root 16384 Jan 15 15:37 lost+found

The file-system is owned by the root, as indicated by ls -ld for your mount WDPassport2T and the permission string drwxr-xr-x shows the owner root has the RW permissions while, the members of group root along with the world/others will only have R-permission.

To solve you could change the permissions with chmod or just change the ownership recursively, and this is what I've shown below:

sudo chown <username>:<groupname> -R /path/to/target

which in your case would be:

sudo chown adam:adam -R /media/adam/WDPassport2T/

Now if you need, you may also set the permissions with chmod:

find /media/adam/WDPassport2T/ -type f -execdir chmod 666 -Rv {} +

(which gives owner, group and the world RW permissions for all the files in the target.)

find /media/adam/WDPassport2T/ -type d -execdir chmod 777 -Rv {} +

(which gives owner, group and the world RWX permissions for all the directories in the target.)

Reference:

Official Ubuntu Documentation: File Permissions

Solution 2:

Have you tried re-formating the drive with your own permissions?

First, check your user id:

sudo id -u red

It should give "1000"

Next, unmout the drive in filemanager.

Be careful, you will lose all your data with the next comand

sudo mkfs.ext4 /dev/sdx1 -E root_owner=1000:1000

Mount the drive and you should be able to write files and folders

Solution 3:

Most partitioning & formatting tools (like Gparted) requires the root privileges.

File systems like ext4, ext3 stores file ownership information with the pen drive itself. (But the ntfs, fat32, fat16 does not have a security like that)

In this case you have to change the permission by using the following command in the terminal.

chown -hR nobody:nogroup /media/adam/WDPassport2T/

by setting the user as "nobody" & the group as "nogroup" it will fix the similar issues with permissions / ownership when plugged the disk into another box.

for more info see the manual page for chown command (use "man chown" )