0

When I write

cd ~

I get to the /var/www directory.

I would like to get to my home directory at /home/pi when I write cd ~.

Some may argue that an alias would be the solution, but it seems like the RPi thinks that the /var/www is the actual home directory, because it puts all the configuration files in there.

I have the Apache web server installed, its public directory is in the /var/www directory.

How do I change the "tilde" directory to be /home/pi instead of /var/www?

3
  • 5
    if you run "whoami" are you actually the pi user?
    – rob
    Jun 20 '14 at 10:16
  • 1
    Also, what is the result of echo $HOME and/or cat /etc/passwd | grep $(whoami)?
    – Wilf
    Jun 20 '14 at 14:41
  • @rob When i type in whoami I get pi Wilf, when I type in echo $HOME I get /var/www. And when I type in cat /etc/passwd | grep $(whoami) I get pi:x:1000:1000:,,,:/var/www:/bin/bash. By somehow I have made the /var/www directory to my home directory. How can I change it back to /home/pi Jun 21 '14 at 11:14
4

As root, edit /etc/passwd.

The file will be a long list of users (system and real). Towards the bottom, you should see your username. The last column but one, will be your home directory. Here's mine:-

gareth:x:1000:1000:Gareth Williams:/home/gareth:/bin/bash

Where it says /home/gareth above, it (probably) says /var/www on yours.

Also, your home directory must exist on the computer. First check that you have a home directory:-

$ls /home
gareth
$

If your username is there (gareth in my case), than all is well, otherwise make the directory using:-

$/sbin/mkhomedir_helper gareth

Finally, log out and in and everything should be working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.