What Is the Safest Way to Run an Executable on Linux

What is the safest way to run an executable on Linux?

Geordi uses a combination of chroot and interception of syscalls to compile and then sandbox arbitrary code.

Bash: run an executable file in background

Any executable in linux can be run in the background as follows:

 $ ./yourExecutable.exe&

Add the & character at end. (Assuming yourExecutable.exe is in the current working directory)

How to kill it later on?

$ ps -ax | grep yourExecutable.exe

You will get an output like:

9384  pts/7    S+     0:00 grep yourExecutable.exe
25082 pts/7 T 0:00 yourExecutable.exe&

Kill the second process using SIGKILL. That is the one you executed in the background.

$ kill -9 25082

What to install and how to run an executable file on Mac?

Since your question is tagged as C and Clang, and you are talking about build-essential, I will assume that you are attempting to build an application from source code.

Instead of build-essential, in macOS, you need Xcode. The Xcode CLI tools will work if the application is text-only or Curses, but you will need the entire Xcode IDE for any graphical application.

If running ./testme is telling you Executable format error is probably because it's a prebuilt executable, very likely a Linux ELF executable that will not run in macOS.

My suggestion is to try to build the software. Most C applications will build if you run make inside the directory. make is installed by default by Xcode. Other applications may need a third-party build system, such as CMake, but I do not know if that's the case.

Signed executables under Linux

The DigSig kernel module implements verification of binaries signed by a tool called bsign. However, there hasn't been any work on it since version 2.6.21 of the Linux kernel.

How to make sure an application keeps running on Linux

Notice: Upstart is in maintenance mode and was abandoned by Ubuntu which uses systemd. One should check the systemd' manual for details how to write service definition.

Since you're using Ubuntu, you may be interested in Upstart, which has replaced the traditional sysV init. One key feature is that it can restart a service if it dies unexpectedly. Fedora has moved to upstart, and Debian is in experimental, so it may be worth looking into.

This may be overkill for this situation though, as a cron script will take 2 minutes to implement.

#!/bin/bash
if [[ ! `pidof -s yourapp` ]]; then
invoke-rc.d yourapp start
fi


Related Topics



Leave a reply



Submit