Trying to modify /etc/bash.bashrc
I get an error:
$ echo "my edit" >> /etc/bash.bashrc
bash: /etc/bash.bashrc: Permission denied
ls -ll /etc/bash.bashrc
shows:
-rw-r--r-- 1 root root 1975 2011-05-18 19:54 /etc/bash.bashrc
How could I modify /etc/bash.bashrc
?
Don't change the owner. Don't chmod it. Just use sudo. Open it with sudoedit if you need to do complicated things.
By the way, you can make changes for one user by just editing ~/.bashrc without requiring any special permissions.
You need superuser permissions to edit the file.
To become the superuser, type in
sudo -s
then enter your password. After you log in, then try your command, and it will work.You've probably discovered by now that there are many ways to do this. But I think this one is the most elegant of all. (It often involves the least typing, too, when everything is said and done.)
See
man tee
if you're interested in the technical details of how this works.In general:
To do the work of
echo some-text > some-file
asroot
, run:To do the work of
echo some-text >> some-file
asroot
, run:Do the changes you want. Save it (Ctrl+X) and confirm with
y
and Enter.