I had an old laptop. When it got complaint I removed its hard drive and started using it as external hard disk. It has an 80 GB of memory allocation for the windows C drive partition. But now i don't need that partition anymore. But the problem is I am not able to access that drive to paste files into it. How can I make read and write permission to this drive using terminal?
If you want to gain ownership of a drive you can use the chown command:
This gives the user ownership over the drive without allowing permission to unauthorized users and
-R
makes this command recursive so that ownership also applies to all of the existing individual files on the drive as well and not just the drive itself.You can also use
-R
to makechmod
recursive as well.1. Ok technique for files ON an external drive, but the correct technique for files you just copied onto your computer FROM an external drive
This works: recursively (
-R
) change theusername
(the part before the colon:
) andgroupname
(the part after the colon:
) to your username:BUT, the problem with this is that it makes the external disk difficult to share between multiple usernames and/or on multiple computers, because each person on each system who needs access to these files must either have the same
username
, or must be part of the samegroupname
. Having the same username only works if it is the same person, so that doesn't always make sense. Having the same groupname is okay if it is consistently the same people using the drive, and they all add themselves to the same group with:BUT, if the groupname doesn't exist on one system, and just shows up as a number, such as
5000
, when you look at it withll
(ls -alF
), then you can't easily add yourself to the same group becauseusermod -a -G 5000
produces this error:2. Sometimes better for files ON an external drive
So, that leads us to this solution: just give full permissions to these files to everyone:
BUT, that also marks ALL files as executable, which doesn't really make sense. You don't want to arbitrarily mark every single file as executable, as that can pose a security risk, and also be annoying when every time you double-click a text file to open and edit it, it asks you if you'd like to run/execute it.
3. Better still #1 (or best, if you DO need write permissions for everyone) for files ON an external drive
So, that leads me to my recommendation: give full permissions to everyone (
-a
, or 'a'll), but only set the executable bit (ie: use+X
, NOT+x
) if it is either a directory, OR already set for one or more of "user", "group", or "other", like this:man chmod
says about the capitalX
versus lower-casex
option:4. Better still #2 (or best, if you do NOT need write permissions for everyone, ie: if read is enough) for files ON an external drive
BUT, even better still, if you can get away with it: if you don't really need guaranteed write permissions for everyone, just ensure you have at least read permissions for everyone on the drive, like this:
Then, apply permissions
-R a+rwX
only AFTER copying the files to your local machine from the external drive:References:
chmod
to find a bunch of my personalchmod
examples here] eRCaGuy_dotfiles/git & Linux cmds, help, tips & tricks - Gabriel.txtRelated
The drives will be located in
/media/username
folder. Goto that directory using cd command. And then on terminal777 assigns read,write and execute permissions to all users.