3

I broke the /home/username/.profile file so now I can't access Ubuntu. How can I reset the .profile file back to its defaults? When I try to write something using root, I get error message that the file is read only. I broke PATH variable to be more accurate.

How can I fix this?

Kevin Bowen
  • 20,055
  • 57
  • 82
  • 84
Alen
  • 1,843

1 Answers1

4

The default PATH variable is defined in /etc/environment. To reset the path variable, open a terminal and execute the following command: . /etc/environment.

That will restore the PATH variable for the current terminal only!

To restore the .profile file copy it from the folder /etc/skel. The /etc/skel folder contains all the files that are copied to the user's home folder when a new user is created.

Also take a look at that answer: When I create a new user, how do I automatically create a .virtualenvs directory in their home directory?

If you are unable to log-in the you have to use a live-cd and then copy the content of the skeleton folder (/etc/skel) into your home directory.

Update:

To access your home or partition using a live-cd you have to mount your harddisk after you bootet up from the live-cd. Open a terminal in the live-cd and type the following:

sudo mkdir -p /mnt/root
sudo mount /dev/sda1 /mnt/root

Now your hard drive is mounted into the folder /mnt/root. Now copy the content of the skeleton folder into your home folder

cp -r /mnt/root/etc/skel/ /mnt/root/home/<your-user-name>/

The -r switch is important to copy the hidden files. Now you can unmount the disk and reboot the system cd && sync && umount /dev/sda1 && reboot (as root)

Good luck!

ortang
  • 2,183
  • 14
  • 13