Ubuntu: How do I open a folder using a bash script running terminal


I am trying to open a specific folder that is in a script:

    #!/bin/bash      # Download youtube videos      xterm -e /home/pst007x/Downloads/ youtube-dl https://youtu.be/-pjc1sWw6Dw  

What is happening the terminal is opening, but I am getting permission denied.

Perhaps a stupid question, but how do I run a script to open a terminal in a specific folder?

I have permission to access this folder.



This worked thanks:

xterm -e 'cd /home/pst007x/Downloads/ && youtube-dl https://youtu.be/-pjc1sWw6Dw'  


You need to use the -e option of xterm, and cd to go to the desired directory e.g. cd /foo/bar/. The tricky part is that the command will be run in a non-interactive session of your login shell, so if you want to keep a shell session open, tack the desired shell directly afterwards e.g. opening bash on that directory:

xterm -e 'cd /foo/bar/ && bash'  

If your goal is to run an one-shot command, then just use the command directly (preferably use absolute path if unsure), no need to spawn a shell.


Make sure that your script has execution permission. You can give execution permission by following command.

sudo chmod +x <yourscriptname.sh>  

You can use following command to save to your download folder.

youtube-dl -o /home/pst007x/Downloads/  https://youtu.be/-pjc1sWw6Dw  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »