Permissions – Getting Access Denied When Trying to Copy & Paste Files

permissions

I am new to Ubuntu so please forgive my inexperience.

I am running Ubuntu Desktop 16.04.1 and I am set up as an administrator, I am the only user so I believe therefore I should be a root user.

However, when I try to copy a file from the root /var/www/html and paste it in /var/www/ directory, using any file management software (i.e. File manager, Files, Dolphin, etc.), I get the error message: Access denied. Could not write to.

Why can I not write to these directories?

Could this be because I have the automatic login option turned on?

Best Answer

You're not the root user. In some Linux distros, you are root by default and have to set up other users (because being root is bad practice for security reasons) yourself. In Ubuntu, the user you create during installation is a user with rights to run all commands using the sudo program.

This means you can do pretty much anything you want, but you need to use sudo to elevate permissions temporarily when you want to do something that requires root permission, such as writing to system directories of which your user is not the owner. The sudo program allows you to run commands as root

Therefore, to copy a file to a directory you don't own and that does not have permission for you to write to, you could run (in a terminal, open one with Ctrl+Alt+T)

sudo cp /path/to/file /path/to/destination

Or to use a graphical browser:

sudo -i      # to open a root shell
nautilus     # or caja or dolphin or whatever program you use

do your thing, and when done, enter

exit

in the terminal, to drop privileges.

Related Question