How to open a terminal in a specific directory. Open your file manager on the Linux desktop and navigate to the directory you need to work in. Once in that directory, right-click on an empty space in the file manager and then select Open In Terminal.
cd path-to-directory : The command followed by a path allows you to change into a specified directory (such as a directory named documents ). cd .. (two dots). The .. means “the parent directory” of your current directory, so you can use cd .. to go back (or up) one directory.
To change this current working directory, you can use the "cd" command (where "cd" stands for "change directory"). For example, to move one directory upwards (into the current folder's parent folder), you can just call: $ cd ..
Gnome desktop environment makes easy access of application, in order to access the terminal window, press the super key (aka Windows key) and you should see Terminal application listed on the left-hand side application pane if you don't see it listed on here simple start searching for “Terminal” in the search area.
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.
I did this way - with script: open 3 tabs in the same window size 170x40, each "tab" starts in a different directory.
gnome-terminal --geometry=170x40 --working-directory=myfolder1 \
--tab --working-directory=myfolder2 \
--tab --working-directory=myfolder3
Add the following to your ~/.bashrc
cd ~/myfolder
You could use the nautilus-open-terminal extension. This allows you to right-click on a folder in nautilus and open a terminal window with that directory as its working directory.
You can also run a terminal in the normal way, type "cd ", and drag a folder icon from nautilus to the window. This will paste the path of the folder into the command line and you then type return to change to that directory. You can do the same thing with regular files to paste their path and run commands on them.
Actually, this is how I turn it off for everyone by default.
gconftool-2 --direct \
--config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory/ \
--set -- type=bool /apps/nautilus-open-terminal/desktop_opens_home_dir true
There is the option --working-directory
to specify the startup directory of the terminal (no short option form).
The basic approach to open the terminal in /some/dir
is
gnome-terminal --working-directory=/some/dir
but there is a trap...
Assuming we want to start the terminal in the directory ~/dir
.
This does not work:
gnome-terminal --working-directory=~/dir
The command looks perfectly fine according to the option syntax, but the terminal starts in the home directory.
It's because it does not expand the tilde (~
), for confusing reasons - see below.
Thesse do work:
gnome-terminal --working-directory=/home/auser/dir
gnome-terminal --working-directory=$HOME/dir
gnome-terminal --working-directory ~/dir
Note there is no =
in the last variant. Because of this, the ~
is at the start of a shell word, and therefore is handeled by tilde expansion.
The problem is that ~
does not get expanded everywhere, but only in certain places. One of them is in variable assignments, like directory=~/dir
. That's ok, ~
gets expanded to $HOME
, but --working-directory=~/dir
does not expand ~
, because that is not a variable assignment, it only looks very similar.
From GNOME Terminal - Getting Started:
You can also specify a command that runs automatically when you start GNOME Terminal in the profile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With