repair ~./profile file

11,977

You can first try to just copy the default .profile from the original copy found in /etc/skel/:

First, it is recommended to make a backup of your profile first just in case (Thank you wjandrea):

/bin/cp ~/.profile{,.bak}

Then you can copy the default from the /etc/skel

/bin/cp /etc/skel/.profile /home/<username>/

If for some reason that does not work, you can follow the next part to replace your .profile from its original contents:

Boot your system to Recovery Mode first so that you have root capabilities to your system.

A .profile file is stored in the /etc/skel/ directory that you can copy to your home folder.

cp /etc/skel/.profile /home/<username>/

then set the permissions and ownership on the file so it matches your username:

chmod 600 /home/<username>/.profile
chown <username>:<username> /home/<username>/.profile

replacing <username> with your username that you created.


Hope this helps!

Share:
11,977

Related videos on Youtube

moein rahimi
Author by

moein rahimi

Updated on September 18, 2022

Comments

  • moein rahimi
    moein rahimi over 1 year

    I just messed up with ~/.profile, tried to add something to PATH, but looks like there was a syntax error in my code and now the login screen functionality won't work and I can use ctrlshiftf1 tty to login but essential commands such as sudo and ls won't work because ~/.profile is broken. How can I fix that ?

    • Videonauth
      Videonauth about 8 years
      That is how the standard ~/.profile file looks like.
    • moein rahimi
      moein rahimi about 8 years
      ok how can i modify profile? to make it like the link
    • John Orion
      John Orion about 8 years
      not sure if you can delete .profile and have it recreate .. you could try tty1 and try cp ~/.profile ~/.profile.bak then rm ~/.profile that may at least let you get to a place where you can edit the original and fix the problem
  • Jakob Lenfers
    Jakob Lenfers about 8 years
    You should be able to cp the file without recovery mode by using the complete path /bin/cp.
  • Terrance
    Terrance about 8 years
    @JakobLenfers Good point. I will add that to my answer. I will leave the recovery mode just in case someone may not know paths where utilities are located. =)
  • wjandrea
    wjandrea over 5 years
    Please edit the answer to add details about how exactly to accomplish this. Thanks, and welcome to Ask Ubuntu!
  • Terrance
    Terrance over 5 years
    Was your answer based off my answer above? In the Recovery Mode I linked in my answer it says on step 8 to remount the drive as read write with mount -o remount,rw /. Did you miss that step?
  • farshad hasanpour
    farshad hasanpour over 5 years
    @Terrance Unfortunately, I didn't read the link about Recovery mode in your answer. I used the graphical interface using a bootable USB flash but later I updated my answer about how to do it using the terminal and without using recovery mode