17

I'm working on a bash script that appends to /etc/profile, but instead of appending, I accidentally wrote over it, losing all of its content.

How can I restore the file? Is there a system default profile that I can copy to restore my /etc/profile?

I did search here but being new to Ubuntu, I don't know if the posted /etc/profile content I see in other questions is the default content.

3
  • 1
    grep /etc/profile /var/lib/dpkg/info/*.postinst shows /var/lib/dpkg/info/base-files.postinst, which in turn has a function copying profile from /usr/share/base-files to /etc/passwd (among other such files).
    – muru
    Mar 20, 2018 at 8:30
  • 2
    Testing a script on your own OS, as root is not a good idea. You should use a VM (so you can just take a snapshot, and if anything goes wrong you just restore the snapshot), or at the very least backup your files before running it.
    – Bakuriu
    Mar 20, 2018 at 18:20
  • Why was this reopened? The duplicate covers cases where a copy of the original config file exists elsewhere on disk.
    – muru
    Nov 6, 2023 at 7:58

1 Answer 1

29

There is a copy of the system default profile in /usr/share/base-files

0

You must log in to answer this question.

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