I encrypted a device using these directions

sudo dd if=/dev/urandom of=/dev/sdb1
sudo cryptsetup -y -v luksFormat /dev/sdb1
sudo cryptsetup luksOpen /dev/sdb1 $name #change "$name" to any name you wish
#now format
mkfs.ext4 /dev/mapper/$name
sudo mkdir /media/mount_point
sudo mount /dev/mapper/$name /media/mount_point

When I unlock and mount the setup, I can't write or copy anything to it because root is the owner and all permissions are only for root. Can I change this so that I have access to it?

Just to clarify for others as I've stumbled on this question when first searching for it on Google:

Issue: After doing all the necessary setup for a LUKS container file/harddisk that is already mounted with root, a user account has not write privileges to it, only read. (this is the case for most tutorials and instructions above)

Solution:

We need to change the permissions of the newly-minted filesystem that is in the encrypted harddisk/file container.

Using the example in the example where /dev/mapper/$name has already been mounted to /media/mount_point with a command like:

sudo mount /dev/mapper/$name /media/mount_point

Open a terminal in your account and type enter this command:

sudo chown -R yourUserName /media/mount_point

For example if joe has a mount point named myEncryptedHD he should do:

sudo chown -R joe /media/myEncryptedHD

What this does is Joe changes the owner of all files in myEncrypted to joe, and he now has read and write access. Life is good.

If you decide you don't want R/W permissions anymore, just sudo chown -R root /media/mount_point and you'll revoke your rights.

References for chown examples for more complicated permissions handling and a related question on SuperUser with a comment on the answer that also suggests the alternative sudo chmod -R 775 /media/mount_point that will set read write execute permissions on user, group and only read and execute (5) for others. A chmod man page for further info

I believe you can change this. After you get Root Privileges

sudo su

you should use

chmod 777 /directory/of/the/device

I am not sure if the device should be mounted or not before you attempt this.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.