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.

I've tried

gnome-terminal -x 'cd /path/to/dir'

and

gnome-terminal -e 'cd /path/to/dir'

but both give me errors when the new terminal opens. How do I get a new terminal to start in a specific directory?

share|improve this question
add comment

7 Answers 7

up vote 18 down vote accepted

Use

gnome-terminal --working-directory=/path/to/dir
share|improve this answer
add comment

Add the following line to the end of your ~/.bashrc:

cd ~/public_html
share|improve this answer
    
Thank you. :) Handy file there. :D –  MEM Apr 22 '11 at 15:51
add comment

You can:

  1. Edit/create the file ~/.bashrc and add this line at the end of the file:

    alias cdx='cd /path/to/myfolder'
    

    Save the change and logout/login. When you execute the command "cdx" it will take you to the specified folder.

  2. You can create a shortcut/link that will execute this command:

    • If you use gnome-terminal (ubuntu):

      gnome-terminal --working-directory="/full/path/to/myfolder"
      
    • If you use lxterminal (Lubuntu):

      lxterminal --working-directory="/full/path/to/myfolder"
      
share|improve this answer
add comment
sudo apt-get install nautilus-open-terminal 

Restart nautilus and then right click at any directory and select "Open in a Terminal".

share|improve this answer
add comment

you can add nautilus-script like that

Create empty file named as "Open Terminal Here" in

~/.gnome2/nautilus-scripts/

directory.

Open it and write these lines inside.

#!/bin/bash

gnome-terminal

Make it executable, and right click at any directory in nautilus and select "Scripts > Open Terminal Here" from menu.

share|improve this answer
add comment
gnome-terminal --working-directory=/path/to/dir

as

root45 answered

or u can do like this also

if you start gnome-terminal like "gnome-terminal --working-directory=myfolder" it will start with the working directory at ~/myfolder. so you could add a new entry to your menu to use that command instead of the other one.

share|improve this answer
    
This is not true all the time, if the environment is not set to open the terminal in the users ~ then this will not have the desired effect, you will need to use the full path to the folder. Its correct on the current context, but not all the the time. –  Bruno Pereira Nov 11 '11 at 12:57
add comment

Open "~/.bashrc" Scroll to the bottom and add a change directory command Example: cd ~/myfolder

Then save and exit. The "~" will take you to your home folder (/home/loginname)

Each time you launch your terminal it reads the .bashrc file so you could also put search paths ETC.....,, in it.

share|improve this answer
add comment

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.