Linux create link to executable

Thread Tools
Display

I have an executable in an obscure directory. I want to put a link to it in /usr/local/bin. So I make a link with «sudo ln -s». But then trying to run the program from the command line fails, despite /usr/lcoal/bin being in my $PATH list. The command «which» fails to find it as well.

Going to /usr/local/bin and running ls -l, the links are there but are red colored outlined in grey. Googling, this apparently means they are links that are to «unstatable» files. I don’t know what that means, though.

Running the program works if I put in the pathname to the original, obscure directory that the actual executable sits in, so I’m pretty sure its not a problem with the actual program.

I have an executable in an obscure directory. I want to put a link to it in /usr/local/bin. So I make a link with «sudo ln -s». But then trying to run the program from the command line fails, despite /usr/lcoal/bin being in my $PATH list. The command «which» fails to find it as well.

Going to /usr/local/bin and running ls -l, the links are there but are red colored outlined in grey. Googling, this apparently means they are links that are to «unstatable» files. I don’t know what that means, though.

Running the program works if I put in the pathname to the original, obscure directory that the actual executable sits in, so I’m pretty sure its not a problem with the actual program.

to show the file permissions of the executable itself as well as the link in /usr/local/bin

Источник

New to Linux and Ubuntu.

I want to create a link to Slic3r in a folder i’ve created on the desktop. All the other apps that I wanted to show up in this folder I copied from the /usr/share/applications folder and they all worked. Slic3r does not seem to show up in that the applications folder though. I installed in using a long complex list of instructions that I can’t find now. It works perfectly, but I still would like to create an icon in the design folder that I’ve created on the desk top. Where else might I be able to find the app if it does not show up in the applications folder?

Читайте также:  Как загрузить безопасный режим windows 10 при загрузке через биос

1 Answer 1

In Ubuntu, shortcuts to applications are text files with .desktop file extention. These are usually provided with the application if you installed it via the Software Center or apt. However, if you installed it using a different method, you most likely have to create the .desktop file yourself.

First of all, you have to know the location of the executable you want to run. If you don’t, but can start it by typing its name in the terminal, the command which will tell you its absolute path (e.g. which firefox ).

Now open your favorite text editor (e.g. gedit). A simple .desktop file may look like this:

Replace the name of the application and the path to the executable. Save the file as * .desktop (e.g. slic3r.desktop) to your Desktop.

If you want it to appear in the Dash, place a copy in

/usr/share/applications (visible for every user)

/.local/share/applications (visible for your user only)

Источник

How to create a statically linked position independent executable ELF in Linux?

I have a working position independent Linux freestanding x86_64 hello world:

which I can assemble and run with:

Since it is position independent due to the RIP relative load, now I wanted to link it as a PIE and see it get loaded at random addresses every time to have some fun.

but then running it fails with:

and readelf -Wa says that a weird interpreter /lib/ld64.so.1 was used instead of the regular one /lib64/ld-linux-x86-64.so.2 for some reason.

I then learnt that his is actually the recommended System V AMD64 ABI interpreter name at 5.2.1 «Program Interpreter».

In any case, I then try to force matters with:

and now it works: I get hello and the executable gets loaded to a different address every time according to GDB.

Finally, as a final step, I wanted to also make that executable be statically linked to make things even more minimal, and possibly get rid of the explicit -dynamic-linker .

That’s what I could not do, and this is why I’m asking here.

If I try either of:

-static does not seem to make any difference: I still get dynamic executables.

After quickly glancing at the kernel 5.0 source code in fs/binfmt_elf.c I saw this interesting comment:

so I guess when I achieve what I want, I will have a valid interpreter, and I’m so going to use my own minimal hello world as the interpreter of another program.

One thing I might try later on is see how some libc implementation compiles its loader and copy it.

Related question: Compile position-independent executable with statically linked library on 64 bit machine but that mentions an external library, so hopefully this is more minimal and answerable.

Источник

How to make a file executable? [duplicate]

How can I make my file so that I can double click on it, and it runs. It is a .sh script, but I also have files that say:

Читайте также:  Sharp 205 драйвер windows 10 64 бит

in the description of what they are.

I can’t run any of these from terminal, or by double clicking.

If possible, I would like a way using either the GUI or a Terminal, but not a combination of the two.

Here is a screenshot of what I see when I right click then go on properties. The file first:

And the shell script here:

NB: I accept that this is a duplicate (I was looking for it, and couldn’t find it, so asked + answered it, hoping that I would find it) however, I don’t think the question about .desktop files is a duplicate.

1 Answer 1

There are two ways of making a file executable:

GUI Method:

Go to the permissions tab, then tick the box Execute: [✓] Allow executing file as program.

Command line method:

Note that chmod does also have some more advanced options. It accepts three groups of options, represented as — — — . The first set of — is User. The second is Group and the last is Other (everyone else).

r stands for Read, w for Write and x for eXecute.

To allow everyone to read it, but only Group to execute and User to read and write it would be -rw- rx- r— . This would be added to the command as:

chmod also can do this in numbers. It is based on binary.

So there are these numbers:

Execute by user is 100 . Execute by group is 010 . Execute by other is 001

Write by user is 200 . Write by group is 020 . Write by other is 002 .

Read by user is 400 . Read by group is 040 . Read by other is 004 .

Then you add these together to get the desired combination.

So to allow everyone to read it, but only Group to execute and User to write it would be 400 + 040 + 004 and 010 and 200

That adds up to 600 + 050 + 004 = 654 .

You could then run the command.

to set it. So to set all permissions you can run:

Finally, you can do:

To take all permissions away from everyone.

To add read and write for the user, without affecting any other permissions (e.g. Execute permissions).

This website has a very useful little tool, whereby you can tick the options you want and it gives you the command:

However, not all the possible combinations are sensible to use; the main ones that are used are the following:

755 — Owner has all, and Group and Other can read and execute

700 — Owner has all

644 — Owner can read and write, and Group and Other can read

600 — Owner can read and write

And, if you’re using non-trivial user groups:

775 — Owner can read and write, and Group and Other can read

Читайте также:  Драйвер для принтера hp laserjet m1132 mfp для mac os

770 — Owner and Group have all, and Other can read and execute

750 — Owner has all, and Group can read and execute

664 — Owner and Group can read and write, and Other can just read

660 — Owner and Group can read and write

640 — Owner can read and write, and Group can read

777 and 666 are rarely used, except in /tmp .

Thanks Ilmari Karonen for pointing out the ones in common usage!

Источник

I am installing p4v in /opt , but /usr/bin is on my path. Is it possible to create a soft or symbolic link for p4v from /opt to /usr/bin , so I can just type «p4v» since /usr/bin is in my path?

8 Answers 8

To create a symlink at /usr/bin/bar which references the original file /opt/foo , use:

You would need to apply the above command as root (i.e. with sudo ).

The error is that you are writing the command wrong. The correct way is

If the ‘p4v’ executable is at /opt/bin/p4v, you can simply run:

It would be better to add /opt/bin (or wherever the executable is) to your path:

/.profile would be better for setting $PATH .

Check the software location by this.

output will be this.

To create the soft link. for example you want to create the soft link for skype on your desktop

For more information about ln .

Note, this works if you both nodes are below you in the same tree. You can use relative notation

  • -s command makes it a symbolic link
  • -n makes it possible de create a folder-type symlink

This template was more helpful for me than the above answers. Probably not more correct, just less obfuscated:

Just replace the parts in <> ‘s

If it is saying target is not a folder , it means there are spaces in your folder names eg: New Folder has a space

You need to edit the path and add a backslash \ after every space in the paths

I have found that it is easier to go to where you want the link to be and then create the link using sudo ln -s /path/to/source/file , than doing ln -s target source .

So in your case I would do cd /usr/bin then sudo ln -s /opt/bin/pv4 . The other way has not been working in my case.

Not the answer you’re looking for? Browse other questions tagged symbolic-link or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.10.8.40416

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Оцените статью