Score:0

Create a shortcut to a .sh file and put it in /usr/bin

uy flag

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

hr flag
The Linux [FHS](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html) would prefer `/usr/local/bin` over `/usr/bin` for this kind of thing. See also [How to run scripts without typing the full path?](https://askubuntu.com/questions/427818/how-to-run-scripts-without-typing-the-full-path)
David avatar
cn flag
A tar file opens where you tell it to not a random location.
Zine eddine Boumaza avatar
uy flag
@David Yes this is easy to fix, I appologise
David avatar
cn flag
No need. but thanks.
Score:0
cn flag

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.

Zine eddine Boumaza avatar
uy flag
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.
vanadium avatar
cn flag
Not sure how the paths I indicated in my answer could be more full than they already are.
Zine eddine Boumaza avatar
uy flag
Using a relative path will cause some issues, So maybe It's better to be clear about your instructions.
vanadium avatar
cn flag
Again, where do you see a relative path in my answer?
Zine eddine Boumaza avatar
uy flag
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.
vanadium avatar
cn flag
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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.