Here is the complete solution to fix the unexpected error cp – cannot create regular file : permission denied even when the user is logged into ubuntu or other linux server as root.
[root@server]# sudo cp /home/login.css /usr/local/itplore/htdocs/admin/design/img
cp: cannot create regular file ‘/usr/local/itplore/htdocs/admin/design/img/login.css’: Permission denied
[root@server]# sudo cp -f /home/login.css /usr/local/itplore/htdocs/admin/design/img
cp: cannot remove ‘/usr/local/itplore/htdocs/admin/design/img/login.css’: Permission denied
Solution to fix the error ‘cp – cannot create regular file : permission denied’
First you need to know whether you are a superuser or user with root level permission.
Check if you are really superuser with:
whoami
if the output is root
, then you are superuser and you can make the copy of the file with:
cp -f /home/login.css /usr/local/itplore/htdocs/admin/design/img
otherwise you have to use sudo
:
sudo cp -f /home/login.css /usr/local/itplore/htdocs/admin/design/img
However in the above actual case the user is logged in as root, but cannot copy. So in this case you can skip the above steps and try the below steps.
- the directory has the immutable flag enabled. check with
lsattr
. - the directory is mounted with read-only permissions: type in terminal:
cat /proc/mounts
(ormount
orcat /etc/mtab
)and check the output, if directory is mounted read-only.
If you are in the first case, change the directory attributes with chattr
;
- remove immutable flag on file or directory
chattr -i <file/dir>
- adding immutable flag on file or directory again
chattr +i <file/dir>
Quick Fix: cp – cannot create regular file : permission denied
Follow the procedure for a quick fix for the permission denied issue like this “cp – cannot create regular file : permission denied”. More details are given above. Let’s solve it fast.
If you take the actual case as an example, then try the following as superuser or root.
chattr -i /usr/local/itplore/htdocs/admin/design/img/
chattr -i /usr/local/itplore/htdocs/admin/design/img/login.css
sudo cp -f /home/login.css /usr/local/itplore/htdocs/admin/design/img
If you’re in the latter case, edit the file /etc/fstab
as given above on this page.
If this helps to solve your permission denied issue, please share it.
Screenshot Image of Ubuntu Linux Cloud Server Admin Root Login
Note: The above given screenshot is taken as a sample for Ubuntu Linux Cloud Server Root (Admin) Login done by me. The client who own this cloud server has not subscribed for monthly maintenance service or any other updation service. That’s why there are many updates available on the server. I also offer cloud server installation for a onetime payment fee. You can subscribe to my monthly maintenance plans for better server security and performance. Please contact me for more info.
Comments and Discussions