User avatar
qt3.14
Posts: 6
Joined: Thu Sep 05, 2013 10:00 am

[SOLVED] wrote over /home/pi/.profile accidentally!

Thu Sep 05, 2013 10:07 am

I'm no good at computers... was blindly following instructions to set the time zone when instead of appending to the file I completely wrote over it!
Rookie mistake.
I've already rebooted so I don't suppose I can simply undo this action.

Poked around and couldn't find the file anywhere.
Could someone paste the default .profile file, or upload it? It would be much appreciated.
Last edited by qt3.14 on Fri Sep 06, 2013 1:00 am, edited 1 time in total.

User avatar
rpdom
Posts: 15601
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: wrote over /home/pi/.profile accidentally!

Thu Sep 05, 2013 12:19 pm

When a new user is added to the system the .profile (and a few other files) are copied from default files in /etc/skel/

Just copy the .profile from that directory to /home/pi/ and make sure the owner/group is pi and pi, and the permissions are 644 (-rw-r--r--)

User avatar
qt3.14
Posts: 6
Joined: Thu Sep 05, 2013 10:00 am

Re: wrote over /home/pi/.profile accidentally!

Thu Sep 05, 2013 9:40 pm

Thanks so much! I copied the file over to the desired spot. Excuse my ignorance, but what do you mean about permissions?

flyinghappy
Posts: 115
Joined: Mon Nov 05, 2012 5:31 pm

Re: wrote over /home/pi/.profile accidentally!

Thu Sep 05, 2013 9:45 pm

You want the file to be owned by your user and users group. Best way to do this is to do

Code: Select all

sudo chown pi:pi /home/pi/.profile
that way it can be read by your user.
Pi with ArchLinux running a minidlna/samba home server

User avatar
qt3.14
Posts: 6
Joined: Thu Sep 05, 2013 10:00 am

Re: wrote over /home/pi/.profile accidentally!

Thu Sep 05, 2013 10:36 pm

Thank you for your patience.
To be clear, that command changes the ownership of the file to both the user and the group called "pi", correct?

Would there be a difference between that and

Code: Select all

sudo chown pi: /home/pi/.profile
? (Sorry that this question is now getting a bit off topic, I just want to really learn what I am doing here.)

flyinghappy
Posts: 115
Joined: Mon Nov 05, 2012 5:31 pm

Re: wrote over /home/pi/.profile accidentally!

Fri Sep 06, 2013 12:06 am

yes, there is a difference, in you're version you are making it readable by the user pi, but not the group pi. The : separates user and group so it is kind of like this

Code: Select all

chown user:group /path/to/file
Pi with ArchLinux running a minidlna/samba home server

User avatar
qt3.14
Posts: 6
Joined: Thu Sep 05, 2013 10:00 am

Re: wrote over /home/pi/.profile accidentally!

Fri Sep 06, 2013 12:27 am

I might be greatly misunderstanding, but according to http://www.linfo.org/chown.html it seems like putting a colon after the user's name sets it to both the user specified, and the user's login group.
If a user name or UID is followed directly by a colon or dot but no group name is provided, then the group is changed to that user's login group. Thus, for example, the following would change the ownership of file3 to cathy and would also change that file's group to the login group of the new owner (which by default is usually the same as the new owner):

Code: Select all

chown cathy: file3

flyinghappy
Posts: 115
Joined: Mon Nov 05, 2012 5:31 pm

Re: wrote over /home/pi/.profile accidentally!

Fri Sep 06, 2013 12:44 am

Huh, according to that it is that way. I guess I have just never seen it used that way. Learn something new everyday.

I would still add the group in as users can be in multiple groups and it would make sense to me to make sure you are giving ownership to the correct group. That's just me I guess though.
Pi with ArchLinux running a minidlna/samba home server

User avatar
qt3.14
Posts: 6
Joined: Thu Sep 05, 2013 10:00 am

Re: wrote over /home/pi/.profile accidentally!

Fri Sep 06, 2013 1:00 am

Ah, I understand. Thanks for all your help and understanding.

User avatar
rpdom
Posts: 15601
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: [SOLVED] wrote over /home/pi/.profile accidentally!

Fri Sep 06, 2013 6:46 am

Cool. I wasn't aware about the "user:" format, or the ":group" method, which does the same as chgrp.

Thanks.

Return to “Raspbian”