How Do I Run a Program in a Folder in Linux?
Contents

How do I run a program in a different directory in Linux?

Place you program in ~/bin directory (which is a short for /home/yourname/bin ) and you will be able to run your program from any location, because when ~/bin exists bash adds it to the PATH by default (at least on Ubuntu). You will need to create this directory if it doesn’t exist.

How do I run a script from a folder in Linux?

To run executable from any directory:

  1. Make a bin directory under your home directory and mv your executable scripts into it. …
  2. Move your executable scripts in bin direcoty. …
  3. Now add it to your path variable. …
  4. Check if that path is added in path variable. …
  5. Verify if script is running from any random directory.
Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest