Results 1 to 4 of 4

Thread: editing ~/.bashrc in /etc

  1. #1
    Join Date
    Jul 2019
    Beans
    11

    editing ~/.bashrc in /etc

    Hi,

    I would like to edit the ~/.bashrc in /etc but when I close the file it only has save as option or the changes will be discarded within some second ... Do I need to open the file with SUDO, if yes then how ?

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: editing ~/.bashrc in /etc

    First, you need to understand what ~/.bashrc means. ~/ == $HOME == /home/engrpeterjohn (probably). The HOME environment variable it set by the login process based on the entire for the specific userid in the password record.

    Code:
    getent passwd engrpeterjohn
    is the command to see the password entry for 1 userid.
    ~/.bashrc == $HOME/.bashrc == /home/engrpeterjohn/.bashrc
    That is not /etc/.bashrc. No way, no how.

    If you want to modify any files or directories outside YOUR home, then you need to understand that Linux is multi-user from the ground up. Permissions matter. There are lots of permissions tutorials which you can look up and follw, but just know that every process running and every file and every directory on every Unix-like OS runs with an effective owner, and effective group. This is critical to the security of the system and if you forget it, bad things are likely.

    BTW, you probably want to edit the /etc/bash.bashrc file. I would suggest that this is a very bad idea, especially when you don't understand the other things listed above. If you mess up this file, you may prevent all userids from logging in. It could cause what is known as a login-loop.
    Last edited by TheFu; July 19th, 2019 at 02:26 PM.

  3. #3
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,824
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: editing ~/.bashrc in /etc

    ~ is short for your home directory, so ~/.bashrc is a file in your home directory, not in /etc. Are you editing some other file in /etc? You need root permissions to edit most files there. Some options:
    Code:
    # for terminal-based text editors like nano or vim:
    sudo nano /etc/file
    # for GUI text editors like gedit of mousepad, to prevent root-owned config files in your home directory:
    sudo -H gedit /etc/file
    # sudoedit has some extra safety belts and will use a default text editor:
    sudoedit /etc/file

  4. #4
    Join Date
    Jul 2019
    Location
    Earth
    Beans
    43

    Re: editing ~/.bashrc in /etc

    OP: are you talking about the .bashrc in /etc/skel?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •