0

The two file formats that I encounter when I try to install a software on linux are .deb and .tar.gz or .tar.xz, For the .deb I use apt-get install and the package will be automatically added to a folder that is in the path variable like /usr/bin but for the zipped file formats sometimes I extract it and then the software is in a random place in my file system and I have to navigate to packageInstalationFolder/bin to find the .sh file in order to launch it. What I want is a way to make a link file to the original .sh file and put it in /usr/bin. and If you know a better way than this I'll be happy to know it

1 Answers1

0

This is very simple. Create a symbolic link to the executable in /usr/local/bin, and you will be able to launch the executable by simply typing the name of the link (that includes the .sh extension if you prefer to add that extension to your scripts).

The command to create a symbolic link is ln -s, so

sudo ln -s /path/to/your/executable.sh /usr/local/bin

will create a symbolic link with the name executable.sh in /usr/local/bin so you can run it simply by typing executable.sh.

You can name the link differently:

sudo ln -s /path/to/your/executable.sh /usr/local/bin/executable

Since no directory executable exists, the ln -s command will interpret that as the name of the link. Now simply type executable to execute that script.

You like to use /usr/bin. Don´t. That directory is managed by the packet system of the distribution. Place your manually installed programs (e.g. from tar.gz files in /usr/local/bin, which serves exactly that purpose. If that directory does not exist, create it first.

vanadium
  • 88,010
  • I solved the issue, what I did is that I passed the full path of the original folder, can you edit your solution with /full/path/to/your/exe..., may be it can help someone else. Thanks for your help. – Zine eddine Boumaza Oct 14 '22 at 13:32
  • Not sure how the paths I indicated in my answer could be more full than they already are. – vanadium Oct 14 '22 at 15:24
  • Using a relative path will cause some issues, So maybe It's better to be clear about your instructions. – Zine eddine Boumaza Oct 14 '22 at 15:26
  • Again, where do you see a relative path in my answer? – vanadium Oct 14 '22 at 15:30
  • It's just to remove ambiguity. the reader can assume that he can use a relative path, it's a common mistake to use a relative path. – Zine eddine Boumaza Oct 15 '22 at 08:18
  • A path that starts with / is an absolute path. There is no ambiguity here. Still, this is rather irrelevant to the problem: relative paths are perfectly fine, and that is actually quite common. You will find many links with relative paths in your system files. – vanadium Oct 15 '22 at 10:13