Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I start my terminal the current working directory is always "/". I want it to start from "/home/<username>" i.e. my home.

Any solution for this?

share|improve this question
    
i'm thinking this has something to do with the environment your window manager is setting up for you. i'm having the same problem now and haven't yet figured out the root cause. –  Eric Johnson Jan 4 '11 at 15:27
    
I think the terminal program usually asks the parent process what directory is the current working directory. I have this problem with xterms launched by keyboard shortcut from the window manager. It doesn't happen with gnome-terminal and it doesn't happen if I start in xterm from the command line. But I haven't figured out a solution to this... –  Eric Johnson Jan 4 '11 at 15:45
    
@SIDD: This sounds more like a bug report (it should be your home directory, unless it has been intentionally changed. Please file a bug on Launchpad. How are you starting the Terminal when you see the issue? What version of Ubuntu. Is it a key-sequence (eg. Ctrl-Alt-t)? Is it a menu? Is it something else? BTW, just typing cd on its own without any arguments should take you to your home directory—if that's not working, it could be indicative of the problem. Please include this in the bug report and link the bug number back here to help other people that are following along. –  sladen Feb 5 '12 at 19:10

4 Answers 4

up vote 7 down vote accepted

When you open up a new terminal, the current working directory should be your home folder.

nevon@loltop:~$ echo ${PWD}
/home/nevon

That said, if this is not the case for you, I suppose you could append the following to the end of your .bashrc file:

cd /home/username
share|improve this answer
4  
It may worth to note that ~ is the abbreviation for your home dir. –  Javier Rivera Aug 6 '10 at 16:43
1  
I verified that terminal was opening into root directory - "pwd" command. But after appending "cd"(changes directory to home) to .bashrc, as indicated by Tommy did the job. Thanks. –  SIDD Aug 6 '10 at 16:50

I added --working-directory=~/ to the command executed by my keyboard shortcut in order to fix this.

share|improve this answer

If the initial working directory for a terminal is not your home directory you are likely to have a serious configuration problem. Check the following:

grep $USER /etc/passwd # Should show /home/youruser before the shell location

Check your home dir permissions/owner:

ls -ltrd $HOME # You must be the owner

Make sure you are not doing a 'cd' on your shell startup scripts:

~/.profile ~/.bashrc
share|improve this answer
6  
João is right: you shouldn't work around an obvious misconfiguration, but try to find the source of the problem. –  loevborg Aug 6 '10 at 17:18
    
I executed above commands. Here are the results: "sidd:x:1000:1000:Sagar,,,:/home/sidd:/bin/bash" "drwxr-xr-x 55 sidd sidd 4096 2010-08-17 13:51 /home/sidd" Any conclusion? –  SIDD Aug 17 '10 at 8:23

I would also check the configuration of the user account. Probably the home directory configuration of the user is set to "/" and not "/home/<username>".

share|improve this answer
    
It is /home/<username>. I verified using "cd" command which always sets current working directory as home of that user. –  SIDD Aug 6 '10 at 17:13
    
Then there is something else odd there. If the home directory is set correctly for the user, you should not need to manually set your home directory in the .bashrc file to automatically start in your home directory. –  txwikinger Aug 6 '10 at 17:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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