28

I've recently installed Ubuntu 11.10 on my laptop, but I can't do anything with my 1.5TB external drive, and my 500GB because I don't have write permission. Are there any specific commands I can use in the terminal to set the read/write permissions?

The external is NTFS, and the 500GB is ext4.

10 Answers 10

20

If you don't mind the security problems you can do a recursive chmod in order to change the permissions of all the files.

cd /media/your_external_drive
sudo chmod -R -v 777 *

Also if your files were created in another OS like windows they will have different ownership you can do the same as above to change the ownership of the files

cd /media/your_external_drive
sudo chown -R -v your_username:your_username *

Thats the way I solved a similar problem for my friend after migrating from windows and also after migrating from Linux Mint to Ubuntu.

  • 1
    I used this after formatting an old hard drive using GParted. – johntait.org Jan 1 '14 at 2:48
  • 2
    Don't mark all your files as executable. See below. – danijar May 16 '16 at 16:15
  • 2
    To only give yourself permission for the drive, but not for all of its contents, use: sudo chown -v your_username:your_username /media/your_external_drive – dremodaris Dec 3 '16 at 22:24
  • 9
    Please don't recommend 0777 a.k.a. “please-hack-my-system-and-destroy-my-data” permissions for no apparent reason! There's almost never a reason to do that because it can be avoided with more sensible modifications like changing (group) ownership. −1 – David Foerster Oct 21 '17 at 22:00
19

for your 500 GB hard-drive (ext4) filesystem, you need to give the write and execute permission on /media/username/your_drive partition:-

sudo chmod ugo+wx /media/username/your_drive

Brief Explanation:-

sudo :- it will elevate your priviledges to execute the command.

chmod:- command to change the permissions

u :- user

g:- group

o :- other

/media/username/your_drive :- partition

For your NTFS partition please follow fossfreedom's advice.

Hope this is helpful.

  • It might be a good idea to omit the o – Richard Border Jun 25 '17 at 21:30
  • This works, but cannot do ls inside that disk. – loretoparisi Nov 5 at 9:06
10

To fix read/write issue ntfs, just install these packages:

sudo apt-get install ntfs-config ntfs-3g

when installed, in the dash, type in and run: ntfs-config enter your password when prompted, and then you can enjoy read/write support for ntfs file systems.

  • 2
    this fixed my problem in Ubuntu 14.04 LTS – psychok7 Apr 27 '14 at 22:11
4

Don't mark all your files as executable as some answers suggest. Use 755 for directories and 644 for files. This will set the x bit for directories in order to list their contents but not for files.

find /path/to/drive \( -type d -exec chmod 0755 -- {} + \) -o \( -type f -exec chmod 0644 -- {} + \)

Link to the original answer on StackOverflow: How to set chmod for a folder and all of its subfolders and files in Linux Ubuntu Terminal?.

  • @DavidFoerster Hi, thanks for the edit. This seems like a rather big change. Maybe it should be another answer instead? – danijar Jun 23 '17 at 18:12
  • Tell you what: I'll meet you in the middle and change the find command so that it does exactly the same as your two find command but with only one pass through all directories. – David Foerster Jun 23 '17 at 18:38
  • Sure. You can also add the alternative below, I think it's a very practical command. – danijar Jun 23 '17 at 18:53
0

I was having a hard time solving the problem and this solution worked for me

  1. install physical storage device manger:

    sudo apt-get install pysdm 
    
  2. Open storage device manger:

    sudo pysdm 
    
  3. Choose your required drives

  4. Press assist
  5. Uncheck open as read only
  6. Check owner user of file system and write your username
  7. Press ok and apply
  8. Remount the drive

Note: if you can't change files to binary executables, go to special files and check permit execution of files as binaries, and go to step 7

  • 2
    i installed pysdm before. Today, after a year or so i am trying to install pysdm again. I am getting Unable to locate package pysdm – Rakib Apr 16 '13 at 6:02
  • Same here. It must not be available anymore. – Michael Dorst Mar 5 '15 at 17:33
0

I had the same problem and solved it with nautilus as root.

if nautilus is not installed:

sudo apt-get install nautilus

Before running nautilus make sure the partition or hard disk is mounted.

Run nautilus as root with

sudo nautilus

Your partition or hard disk should appear on the left.

Right click on it -> select "Properties"

In the new window that appears, select the "Permissions" tab. From here you can change the owner if you need to, as well as the permission for a certain user, root, or others.

  • Welcome to Ask Ubuntu! I recommend to edit this answer to expand it with specific details about how to do this. (See also How do I write a good answer? for general advice about what sorts of answers are considered most valuable on Ask Ubuntu.) – David Foerster Jun 23 '17 at 11:52
0

Using Terminal (Use this when you are currently logged in Ubuntu):

  1. Quickly open the terminal or press CtrlAltT

  2. First you need to find out the partition’s name which you want to access, run the following command:

    sudo fdisk -l 
    
  3. Then run this command in your terminal, to access your drive in read/write mode.

    mount -t ntfs-3g -o rw /dev/sda1 /media/<YOUR-Partition-name>
    

    OR Run this command (if the previous didn’t work)

    sudo ntfsfix /dev/<YOUR-Partition-name>
    
  • Welcome to Ask Ubuntu! This looks like a copy-paste of this web page. When providing answers, please provide them in your own words. Also, please provide attribution to the sources you used. – S.L. Barth - Reinstate Monica Oct 16 '18 at 10:00
0

I look around the forum for answers.

I have 3 users, "user1" ,"user2", "user3":

  • user1 : is sudo user with most of the access
  • user2 : is also sudo user with less access
  • user3 : is just another user with no sudo access

Im trying to give access to partitions 1 and 2 to user1, user2 and user3 . The owner of the partition is root. the partitions are mounted at

/media/user2/1
/media/user2/2

Note : I tried to mount the partition using

sudo mkdir /media/IntHDD170
sudo mkdir /media/IntHDD171

Which created the directory to mount the partitions.

  • (I dont know this worked or not)

Step 1:

  • Used nautilus as root.
  • if nautilus is not installed: sudo apt-get install nautilus
  • Before running nautilus make sure the partition or hard disk is mounted.
  • Run nautilus as root with

    sudo nautilus
    
  • Your partition or hard disk should appear on the left.

    Right click on it -> select "Properties"

    In the new window that appears, select the "Permissions" tab.

  • Kept the owner as "root" and group as "user1" with read and write access for both owner and group.

From here you can change the owner if you need to, as well as the permission for a certain user, root, or others.

Note: The user1 ,user2 and user3 did not get access to the partitions yet

Step 2: Added User2 and user3 to group "user1".

usermod -aG user1 user2
usermod -aG user1 user3

Step 3:

Did

chmod -R 777 /media/user2/1
chmod -R 777 /media/user2/2
  • opened

    sudo nano /etc/fstab
    
  • Went to the last line entered:

    LABEL=/dev/sda3  /media/$USER/1  auto  nosuid,nodev,nofail,x-gvfs-show 0 0
    LABEL=/dev/sda4  /media/$USER/2  auto  nosuid,nodev,nofail,x-gvfs-show 0 0
    
  • Saved and Exited

    Note: Now i am able to read and write files to the partitions 1 and 2.

  • Only issue is, if i have logged into user1 , then try to access partition 1 from user2 , it is not accessible.

I do a reboot:

 sudo reboot 

And access partition 1 from user2.

I don't know if this is the right way to do it. Just combined many responses and did. Somehow its working.

0

Just in case!

I had this problem in a dual boot (Mint + W10) when windows didn't close down properly. I tried all the combinations to get rw permissions. Finally,

sudo mount -a

let me know the problem.

Going back to windows and turning off the pc did the job. Rights where restored! The fstab entries are written using ntfs-config.

0

I formatted my extended partition using GParted and the resulted drive had only root level access. In order to grant access to my username, I executed below command.

sudo chown -v username:username /media/username/disk-name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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