0

When I want to execute a binary file or program which is named as vtmc.ubu.ifc, I have to use the terminal to go to that bin folder where the program exists and have to execute the program by ./vtmc.ubu.ifc.

How can I run the program without having to go to that folder, just by using the command like vtmc.ubu.ifc, similar to programs like vmd, xmgrace etc opens just by typing vmd or xmgrace in the terminal.

Elder Geek
  • 36,023
  • 25
  • 98
  • 183

2 Answers2

4

You can edit the ~/.bashrc or ~/.profile file to add the directory where your program is located like this (note here that this is editing the .bashrc script which is a script executed by bash every time an interactive bash shell is started):

  1. open a terminal
  2. gedit .bashrc
  3. go to the end of the file an add:

    export PATH=$PATH:"directory of the program"
    
  4. save the file and quit gedit

  5. type into your terminal: . .bashrc - in the future you don't need to do that; it is only to make your changes usable in the current terminal session

N.B. In order to add the program to the PATH env var of other users, edit the /home/USERNAME/.bashrc script of each user. And to make the program executable in a root shell make the same modification to the /root/.bashrc script.

Zanna
  • 70,465
0x0C4
  • 713
1

There are two methods that I know to accomplish what you are up to more easily:

1st Method (Easiest)

Going to the place where the application is by window explorer like Nautilus (the default window explorer) and then right-click and open terminal at that location and then run the application through the terminal

2nd Method (Recommended)

Add the application path into environment variable or PATH variable.

The official way of adding a path into $PATH is by creating a file (called a bash file and mostly ends with .sh for distinguishing purpose only) in the /etc/profile.d/ and in that file, update the $PATH by export command.

For example, in order to add Android Studio application path into path variable ($PATH), follow the steps bellow:

  1. Go to /etc/profile.d/

  2. Create a text file using nano or vim or sublime and name it "my_android_studio.sh"

  3. Add following code block to the file and then save the file:

    #!/bin/bash
    ANDROID_HOME=/opt/android_studio/android-studio/bin
    ANDROID_SDK=~/Android/Sdk/platform-tools
    export PATH=$PATH:$ANDROID_HOME:$ANDROID_SDK
    

That's it! From now on, you could just run the application using the application's name.

αғsнιη
  • 35,660
Shobeira
  • 153