Recently, I beefed up my development workstation by adding more RAM and two additional internal Hard Drives.
The installation was a breeze and thanks to KDE Partition Manager, partitioning and mounting the new Hard Drives was not a problem either.
Everything seemed to be working fine. The new Hard Drives showed up in Dolphin (KDE’s File Manager) and they automatically remounted when the system was rebooted.
It seemed like everything was good to go.
Today, I went to copy a file from my Downloads directory to one of the new Hard Drives and got the “Access Denied could not write to” error.
Wondering how this could be, I opened Konsole (KDE’s Terminal). With just a few keystrokes, I found out what was wrong.
I issued this command:
[sourcecode language=”bash”]USER@HOSTNAME:~$ ls -l /media/[/sourcecode]
…and quickly, I was provided the following information:
[sourcecode language=”bash”]
drwxr-xr-x 3 root root 4096 2012-01-25 09:41 43adf619
drwx—— 15 USER USER 16384 2012-01-27 10:44 BD7C-A31D
drwxr-xr-x 3 root root 4096 2012-01-25 09:42 c5020186
[/sourcecode]
This told me all I needed to know.
I know that every directory and every file has nine permissions associated with it. The first and third lines represent my new Hard Drives and the permissions are wrong.
The nine permissions are made up of the following permission types:
- r (read)
- w (write)
- x (execute)
…granted to each of the following three categories:
- u (user/owner)
- g (group)
- o (other/world)
So, when I see something like:
[sourcecode language=”bash”]
drwxr-xr-x
[/sourcecode]
I start by separating out the sections of information, in my mind.
drwxr-xr-x should be thought of like this {d} {rwx} {r-x} {r-x}
- d = item is a Directory
- rwx = (first three positions after “d”) means the user or owner can Read, Write and Execute
- r-x = (second three positions after “d”) means the group can Read and Execute
- r-x = (final three positions after “d”) means other or world can Read and Execute
When I partitioned and mounted these new Hard Drives, my USER account wasn’t configured as the owner. ROOT was the user/owner. So, only ROOT would have the ability to Read, Write and Execute.
I need the ability to write in order to copy a file to one of the new Hard Drives.
To change this I issued a chmod command.
In general, the format of the chmod command is chmod {userclass} {operation} {permission}
{userclass}
- u (user/owner)
- g (group)
- o (other/world)
- a (all – user, group and other)
{operation}
- + (Add permission)
- – (Remove permission)
- = (Assign permission regardless of previous setting)
{permission}
- r (read)
- s (Set user or group ID – Don’t worry about this for now)
- w (write)
- x (execute)
To give everyone strong>Read, Write and Execute permissions, including myself, I issued the following commands:
[sourcecode language=”bash”]
USER@HOSTNAME:~$ cd /media
USER@HOSTNAME:~$ sudo chmod -R a+rw 43adf619
USER@HOSTNAME:~$ sudo chmod -R a+rw c5020186
USER@HOSTNAME:~$ ls -l
[/sourcecode]
Now I see what I’m looking for:
[sourcecode language=”bash”]
drwxrwxrwx 3 root root 4096 2012-01-25 09:41 43adf619
drwx—— 15 USER USER 16384 2012-01-27 10:44 BD7C-A31D
drwxrwxrwx 4 root root 4096 2012-01-27 14:45 c5020186
[/sourcecode]
Now, I see:
[sourcecode language=”bash”]
drwxrwxrwx
[/sourcecode]
If I separate the sections of information again, drwxrwxrwx is {d} {rwx} {rwx} {rwx}
- d = item is a Directory
- rwx = (first three positions after “d”) means the user or owner can Read, Write and Execute
- rwx = (second three positions after “d”) means the group can Read, Write and Execute
- rwx = (final three positions after “d”) means other or world can Read, Write and Execute
Now I can save my file to the drive of my choice without the “Access Denied could not write to” error.