Is there a way to create a file to be stored on the desktop - which when clicked will startup lxterminal in a specific directory?

I have four programs I am running in lxterminal and want to be able to click on four files on the desktop which will startup an instance of lxterminal in a specific directory without having to do

cd /home 
cd xxx

You need to use the --working-directory option. So

lxterminal --working-directory=/path/to/dir

will open the terminal with the current directory set to/path/to/dir.

Regarding having clickable files the open lxterminal in different working directories, create four different (executable) scripts, which open lxterminal in the required directories and save them to your desktop. So

lxterminal terminal --working-directory=/path/to/dir1


lxterminal terminal --working-directory=/path/to/dir2

and so on.

See the the lxterminal man page.

To make the script executable, there is no need for a specific file extension, although .sh is sometimes used1. Use the command chmod. Run chmod 755 <scriptname>, or chmod +x <scriptname> on the scripts. So, if the path to your script is /home/pi/Desktop/myscript run

chmod +x /home/pi/Desktop/myscript

1 Note that the extension .sh will not make the file excutable, it is merely a sometimes used convention, to denote that the file contains a (sh) script.

| improve this answer | |
  • what file name extension would I save the file as for it to be recognized as an executable? – Tinkerer Jul 19 '15 at 16:37
  • --working-directory seems to only work with absolute path. So, use --working-directory=/home/your_username/path/to/dir but not --working-directory=~/path/to/dir. – Olexiy Oct 28 '17 at 6:22

Adding onto the previous answer...

I found that the extra "terminal" in the sh file was causing failure. In my case (with raspbian Stretch from June of 2019) I needed a file like this:

lxterminal --working-directory=/path/to/dir

Also, I will reiterate the other comment that this requires absolute path. You have to include the /home and user to open the terminal in a folder for a given user. For example:


Lastly, you can avoid the prompt that asks you if you want to execute or execute in terminal by triggering this script from a desktop shortcut. You make an empty file on the desktop and then populate with some stuff. There are many tutorials online but here is an example:

[Desktop Entry]

This example will open the script OpenMyPreciousFilesInTerminal.sh that is on the desktop. But, you can put your sh script anywhere you'd like which will keep your desktop cleaner...

| improve this answer | |

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.