You are not logged in.

#1 2009-12-03 18:26:26

marwooj
Member
Registered: 2009-08-21
Posts: 23

cannot cp as root

I cannot copy file while logged in as root
what is going on?

[root@hostp ~]# cp /etc/resolv.conf_bak /etc/resolv.conf
cp: cannot create regular file `/etc/resolv.conf': Permission denied
[root@hostp ~]# who
who     whoami  whois
[root@hostp ~]# whoami
root
[root@hostp ~]# ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 50 2009-09-22 11:34 /etc/resolv.conf

Offline

#2 2009-12-03 18:33:33

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: cannot cp as root

A few possibilities, in decreasing order of likelihood:
- Some process has a lock on that file ("fuser /etc/resolv.conf" to check)
- Your hard drive is full and you're getting strange errors as a result ("df -h" to check)
- `cp' is setuid to someone other than root ("ls -l /bin/cp" to check)
- /etc/resolv.conf is write-protected ("lsattr /etc/resolv.conf" to check)

Offline

#3 2009-12-03 18:42:08

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: cannot cp as root

Check dmesg for possible hard disk errors.

Offline

#4 2009-12-03 18:42:12

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: cannot cp as root

post the output of

df -hTl

maybe your /etc/ is a partition mounted read-only, or your entire drive is actually in read-only mode.

also check

ls -l /etc/resolv.conf_bak /etc/resolv.conf

Last edited by quarkup (2009-12-03 18:43:07)


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#5 2009-12-03 18:47:38

marwooj
Member
Registered: 2009-08-21
Posts: 23

Re: cannot cp as root

damn man you are fast smile

[root@hostp ~]# lsattr /etc/resolv.conf
----i---------- /etc/resolv.conf

How to role it back ? with chattr I guess

Offline

#6 2009-12-03 18:48:35

marwooj
Member
Registered: 2009-08-21
Posts: 23

Re: cannot cp as root

damn men smile

I like this forum

Offline

#7 2009-12-03 19:12:11

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: cannot cp as root

Weird, I wonder how that got set.  Anyway, "chattr -i /etc/resolv.conf" as root should do it.

Offline

Board footer

Powered by FluxBB