top of page

¿Como ejecutar nuestra aplicación globalmente en Linux?


Long time ago we make a simple application of a calculator using tkinter in python in Linux,

then we learned to make an executable application with pyinstaller. Now let's go to learn to use some commands in Linux for suscribe an application into new folder in environment variables.


¿What is $PATH?

Linux have some global variables for to program scripts in #Bash, #Zsh or any #Shell, some examples are: $0 that save the first argument that would be the application name, $HOME that save the personal user folder route, but also exist the environment variable $PATH, that saves many routes were Linux can execute applications, each route es separated by ":" character. To know which are these routes we can execute the command printenv or use the echo command to see these routes.

echo $PATH # Muestra el valor de la variable global PATH

# output /home/usuario/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/darkcom/.local/bin/

The executable files that are into this folder routes will can be run in a shell no matter the current location. simply enough to give execution permissions to our application and move it to any contained within the paths of the environment variables $PATH, but if you want add a new folder out of environment variables contained in $PATH?


Add a folder to $PATH

if you need create a new folder, you use the #export command to create, in the next example let's go to create a folder called #bin into user folder.


export PATH="$HOME/bin:$PATH"
# export sirve para registrar una variable
# PATH= es nuestra variable
# $HOME/bin es la ruta que queremos registrar
# :$PATH es la variable global donde anexaremos la ruta

The problem is that the variable is temporally registered while is active te session, when you close the terminal, the changes saved will restored.


Register a variable temporally.


In user folder in Linux, there are hidden folder and files, press CTRL+H in #Thunar application to see files. Exist a file called .bashrc or .zshrc, edit the file and write:


En la carpeta de usuario en Linux, hay carpetas y archivos ocultos, para poder visualizarlos presionamos Ctrl+H en la aplicación #Thunar, ya tendrán que ver como se visualiza en otros administradores de archivos.

export PATH="$HOME/bin:$PATH"

To check that it works, open a terminal and write your application name like a command and it will run.


Not being more see you in a next post.

6 views0 comments

Recent Posts

See All
bottom of page