Add a Personal /opt/ Directory for Installing Applications
Install applications for a single user, using an /opt/ directory inside of the home directory.
You may not have access to /opt/ in the main filesystem. Or maybe you want to install an application for only one user. Whatever the case, this is one way to do it. At the end of this, you will have an application installed locally for one user.
Create the file structure
In your home directory (i.e. ~/ or /home/your-username), create .local/opt and .local/bin directories.
1
2
mkdir ~/.local/bin
mkdir ~/.local/opt
Your system will look for executable files to treat as commands in ~.local/bin/. All of the application files will live in ~/.local/opt/.
Move the application to your opt directory
The opt directory is where build files for an application live. Note that .deb or .rpm files will not work since those are package files.
Download the build files or build the application yourself. In my case, I downloaded a compressed archive of the build files for HeidiSQL (i.e. build-qt5-v12.15.1.1.tgz) and extracted the archive. I ended up with a directory called heidisql-qt5. Then I moved that directory inside of my personal opt directory as shown below.
1
2
# Move the application directory inside of your opt directory.
mv ~/Downloads/heidisql-qt5 ~/.local/opt/
Make it usable on the command line
For this to run like any other app in your terminal, you need to update your $PATH.
Create a symlink
Create a symbolic link (symlink) in your ~/.local/bin/ directory to the executable file.
1
ln -s ~/.local/opt/heidisql-qt5/heidisql ~/.local/bin/heidisql
Update your $PATH
For that symlink to be of any use, your computer needs to look in ~/.local/bin/ for executable files. Add or update your ~/.bash_profile file with a text editor. Add the following lines that will check if ~/.local/bin exists and then add it to your $PATH.
1
2
3
4
# For apps added in ~/.local/opt/
if [ -d "$HOME/.local/bin" ]; then
export PATH="$PATH:$HOME/.local/bin"
fi
Once you save the file, you should be able to run source ~/.bashrc for the updates to be recognized. In some cases you may need to log out and log back in.
Add it to your application launcher (optional)
If you are adding an application with a graphical interface, you will probably want to add this to your application launcher. That way you can point and click to open the application.
With a text editor, create a new file with the following contents and save it to ~/.local/share/applications/heidisql.desktop. Be sure to replace USERNAME with your actual username.
1
2
3
4
5
6
7
8
[Desktop Entry]
Name=HeidiSQL
Comment=Run HeidiSQL
Exec=heidisql
Icon=/home/USERNAME/.local/opt/heidisql-qt5/heidisql.png
Terminal=false
Type=Application
Categories=Development;
