Can't run executable

Hello,

I would like to run executables from a USB or from my desktop. Doesn’t seem to work. I’ve been searching for answers a bit. Came to understand that it has to do with file system mounts not being set to executable.

The solution from what I’ve read should be to change fstab settings to set a mount as executable or remounting a certain mount as executable.

I have been unsuccesful in either. How do I do this?

Greetings,

Susetenance

Hello and welcome to these forums.

I assume that the file system on the USB device is not a Linux file system. This means that file ownership and the permissions bits are not on the file system and thus are emulated (faked) by your Linux system. For security reasons, no x permissions are faked for any files of such a non-linux file system. So your observation and analyses are correct. It is also not possible for the system to do so, because which of the files on the non-Linux file system are executable? There is no way to decide this.

Because it is best to use non-Linux file system only for direct exchange of files between a Linux system and another system (often some form of MS Windows), it is the best to copy the files you need to appropriate place(s) on your system. You can then set x-permission bits for the user and/or group and/or world of those file you think contain executebles to your need.

I do not know how your USB file system is mounted now. When you did that using the desktop feature, there will not be any fstab entry. So you can not change there.

You can create an fstab entry however. In that case, you can indeed configure to set x-bits, but those will then be set for all files, not just for those you think are executable (as said, how can the system know they are). For documentation about how to set those options in an fstab entry

man mount

Scroll down to File system Dependent Options and then to the type of file system you have on the USB.

The first thing to check is – “Is it a Linux executable file?

  • Easily checked – from a CLI (Command Line – Terminal) execute “file «file name»
    ” …

 > file /bin/bash 
/bin/bash: **ELF 64-bit** LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=fc5b4ccec058a6dae93c4748c08587285d576391, for GNU/Linux 3.2.0, stripped
 > 

  • Assuming that, your executable file gave a result similar to the output above – “ELF 64-bit
    ” – check the permissions as follows –

 > stat /bin/bash 
  File: /bin/bash
  Size: 1012552         Blocks: 1984       IO Block: 4096   regular file
Device: 802h/2050d      Inode: 4980740     Links: 1
Access: (**0755**/-**rwxr-xr-x**)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-08-18 15:08:41.400119557 +0200
Modify: 2020-06-08 22:19:29.000000000 +0200
Change: 2020-08-18 15:08:37.840119474 +0200
 Birth: -
 > 

The “0755” and “rwxr-xr-x” indicate that, the file’s permissions allow execution – “x” …

If, the “x” is missing, the current Linux permissions are such that, the file can never be executed …

  • The “x
    ” bit will have to be set – “chmod +x «file name»” …

Did you take into account that the OP (rather vague) talks about USB? I interpreted this as USB connected mass storage. But when people have that it often is an USB stick or similar and many of those have non-=Linux file systems. Thus chmod will not work.

I’m pretty sure that if a Linux system can read a file in a filesystem, it can apply its own Linux properties and security bits and may or may not integrate with the security set when the file(s) were originally written to storage.
Determining factors would include the current OS reading the filesystem, the filesystem itself and the OS used to last write the file.

TSU

That is sheer nonsense. No other word for that.

You can always tell the shell to execute it from a terminal “sh /path/to/the/executable”

Thank you for the replies.

I suppose I was a bit vague as far as USB goes. But you assumed right I was talking about a USB stick.

So I ran the file check:
“ELF 64-bit LSB executable”

It’s a .run file after all.

Stat check:
“Access: (0644/-rw-r–r–r)”

So I ran:
“sudo chmod +x <filename>”

It’s weird. The command seems to be accepted, but nothing really happens. I just get a new command line and that’s that. The file doesn’t seem to actually execute.

Do I still have to remount the USB to change it to executable status or edit fstab? If so can you share the code with me?

Many thanks,

Susetenance

Did you understand all that hcvv wrote already? Confirm the file system on the USB stick and report back

df -Th

Probably it isn’t (only) a filesystem issue?
https://www.ubuntupit.com/how-to-execute-run-and-bin-packages-in-linux-system/

We have seen what a .run and .bin package file is and where they come from. As the .bin and .run files are not conventional packages, you can’t execute them on Linux in a traditional method.

I didn’t read all that, just got curious when I read about the “.run” file.

Nothing particularly unusual about them in a Linux context.

Those suffixes do not mean much. They are a mental help for people (what could that be?), and some applications lay value on them (and let us hope they are correct in their interpretation). But you can create them as you like. In any case, the operating system (kernel) has no concept of them.

@deanno_ferrari and @hccv,

Of course you are right. You can put various suffixes to the file. As I said, I didn’t read all of it. I just wondered if there may be other reasons why it wouldn’t execute as nothing is known about the file itself and it might “expect” something that is just not there.
Never mind…
:dont-know:

So far the OP has not showed that he read and understood Henk’s reply. Until then we can only speculate.

Sorry. I forgot to report the file system in my previous post. I used the command posted by deano_ferrari. The file system is “vfat”.

I formatted the USB stick as FAT32 on another system with Windows 10.

I’m not posting from the same system as I’m running the code on. The system I’m running code on will remain offline, so I won’t be able to post full output. Sorry if there’s any inconvenience.

Thanks for the heads up hcvv. :slight_smile:

Thanks for the information.

I understand that it is difficult to copy/paste into your posts from an off-line system. But please, when you report then by typing, do alter as less as possible and try to avoid to post conclusions instead of computer facts.

(BTW. when it is more output to be shown, redirect the output of the command to a file on removable mass-storage and then use that on an on-line system).

So, we are now sure this is an USB connected mass-storage device (and the fact that it is USB is not very important, mass-storage is mass storage, regardless of the type of bus used to connect it to the system).

It is most probably partitioned with only one partition (you did not show that, but it is the most used configuration for such “USB sticks”, specially if MS Windows is involved). And on that partition is a FAT32 file system.

As explained above Fat32 is NOT a Linux file sysem and as such does not support (does not have at all) metadata of files containing file ownership (by user and group) and permission bits. On mount, these are faked according to several rules (defaults and mount options) used during that mount. Once the file system is mounted, these are fixed. So doing any chmod (or chown) is useless, it won’t change anything.

You can walk two paths to enlightement here.

One is to use that stick only for the transport between a non-Linux operating system and your openSUSE system. This is the one I strongly support. Use non-Linux file systems not for anything more serious then directly transport. Either by carrying that file system on a removable device (like you probably did from a MS Windows system) to openSUSE, or by mounting them for file system that are on your system itself because of a multi-boot situation.
In that case, I advise to copy the files you need from the USB stick to an appropriate place on your openSUSE system (e.g. a fresh created directory inside your home directory. The result will be that all files are owned by the user that did the copy and that they will get the permissions as all files the user creates. Just the normal situation you, as that user, have all the time with al the files somewhere in your home directory. Then remove the USB stick and use it as a backup in case you brake something in what you now have on the system.

Now you can start worrying about what is executable. As mentioned earlier, the system can not by itself simply decide which of all those file contain what, let alone what is an “executable” file, executable in the meaning of a Linux system.
This is where your human knowledge may help. It could be that you know, or guess that a particular file is a Linux executable. Like somebody already said above, that can be checked with

file <path-to-the-file>

Example:

henk@boven:~> file /usr/bin/su
/usr/bin/su: setuid ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=9af3dfcd024a9449f65fd9af30b66d16d8ae3523, for GNU/Linux 3.2.0, stripped
henk@boven:~>

When it says something similar. there is a good chance that it will execute. Then you should set the x-permission bit for that file, at least for yourself.

chmod u+x <path-to-the-file>

And then you can try

<path-to-the-file>

(take care, <path-to-the-file> shoud have at least one / in it, thus when it is in your working directory make it ./file).

The second path you could go is mount the file system with options that will allow the user to execute directly from the non-Linux file system. As l already told you where to find information (in the mount man page in the part FILESYSTEM-SPECIFIC MOUNT OPTIONS and then Mount options for fat).
There you find e.g.

uid=value and gid=value
Set the owner and group of all files. (Default: the UID and GID of the current process.)
umask=value
Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal.
dmask=value
Set the umask applied to directories only. The default is the umask of the current process. The value is given in octal.
fmask=value
Set the umask applied to regular files only. The default is the umask of the current process. The value is given in octal.

So, as root compose a nce mount statement and when it works to satisfaction and you need that more often, create an /etc/fstab entry for it so you do not have to type that long mount statemnet again and again in the future.

When you need more advice on this, please ask. I guess you have enough to study for the moment. :wink:

Succesfully ran the executable. :smiley:

Thanks for all the replies, and thanks hcvv for all the valuable information.

With regards,

Susetenance

You are welcome.