repair ~./profile file
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!
Related videos on Youtube
moein rahimi
Updated on September 18, 2022Comments
-
moein rahimi over 1 year
I just messed up with
~/.profile
, tried to add something toPATH
, 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 assudo
andls
won't work because~/.profile
is broken. How can I fix that ?-
Videonauth about 8 yearsThat is how the standard
~/.profile
file looks like. -
moein rahimi about 8 yearsok how can i modify profile? to make it like the link
-
John Orion about 8 yearsnot sure if you can delete .profile and have it recreate .. you could try tty1 and try
cp ~/.profile ~/.profile.bak
thenrm ~/.profile
that may at least let you get to a place where you can edit the original and fix the problem
-
-
Jakob Lenfers about 8 yearsYou should be able to cp the file without recovery mode by using the complete path
/bin/cp
. -
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 over 5 yearsPlease edit the answer to add details about how exactly to accomplish this. Thanks, and welcome to Ask Ubuntu!
-
Terrance over 5 yearsWas 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 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