1

It's that simple:

root@server [/etc]# touch /etc/bashrc
touch: cannot touch '/etc/bashrc': Permission denied

OS: Linux

Distro: CentOS

Release: 5.3

Extras: cPanel installed

Any ideas?

3
  • Have you managed to get into some unusual situation where root isn't root? Do you have a uid of 0?
    – Cascabel
    Aug 9, 2010 at 16:51
  • Voting to close as this is non-programming related
    – t0mm13b
    Aug 9, 2010 at 16:51
  • Is selinux enabled?
    – user52692
    Oct 18, 2010 at 9:53

4 Answers 4

1

Check if you have i attribute on the file:

# lsattr /etc/bashrc
----i------------e- /etc/bashrc

If yes, remove it:

# chattr -i /etc/bashrc
0

1) ls -l /etc/bashrc will show you attributes of the file, maybe its read-only even for root ?

2) Or it could be SELinux that prevents you from "writing" to the file.

0

The file could be also immutable. That would be odd. This is a sign of something wrong or pretty unusual.

0

See the solution.

Finally I got the solution. Its the SELinux mode issue. First I check current SELinux mode.

getenforce Here is: Enforcing So it needs to be Permissive.

setenforce [Enforcing|Permissive|1|0] To make changes persistent through a system reboot, edit the 'SELINUX=' line in /etc/selinux/config for either 'enforcing', 'permissive', or 'disabled'. For example: 'SELINUX=permissive'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .