date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,659,734,788,000
When a executable file is run in a process, if the executable file is overwritten or deleted and then recreated by reinstallation, will the process rerun the new executable file? Does the answer to the question depend on whether the executable is run as a service/daemon in the process or not? the operation system, e...
It depends on the kernel and on the type of executable. It doesn't depend on how the executable was started or installed. On Linux: For native executables (i.e. binaries containing machine code, executed directly by the kernel), an executable cannot be modified while it's running. $ cp /bin/sleep . $ ./sleep 999999 &...
Will overwriting to an executable file affect a process which is running the original executable file?
1,659,734,788,000
I've noticed that when I mount a FAT filesystem on Linux, all of the files have their executable permissions set. Why is this? There's almost no chance that you can or want to directly execute any program found on a FAT file system, and having the executable bit implicitly set for all files seems annoying to me. I un...
FAT may not be a POSIX-style filesystem, that doesn't mean that you shouldn't be allowed to store executables on it and run them directly from it. Because FAT doesn't store POSIX permissions, the only way this can happen (easily) is if the default mode used for files allows their execution... In the past, when (V)FAT ...
Why does Unix set the executable flag for FAT file systems? [closed]
1,659,734,788,000
I am getting the same not found [No such file or directory] error when trying to execute a ksh script. Read tips about the PATH and running the script with a ./ in the posts here and here and tried but no luck. The script does exist under the directory from where I am trying to execute and has full permissions but giv...
I believe there may be some carriage returns causing this error here. I was able to reproduce the error successfully. Testing cat ksh_experiment.ksh #!/usr/bin/ksh echo "Hello" Now after providing the permissions when I ran the file, it produced the output successfully. Now as discussed over here, I inserted some c...
-ksh: revenue_ext.ksh: not found [No such file or directory]
1,659,734,788,000
Compiled a binary from the golang source, but it won't execute. I tried downloading the binary, which also didn't work. Permissions all seem to be right. Running the file from go for some reason works. Output of ~/go$ go run src/github.com/exercism/cli/exercism/main.go1: NAME: exercism - A command line tool to inte...
Check that noexec is not in effect on the mount point in question. Or choose a better place to launch your script from. $ mount | grep noexec [ snip ] shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime) $ cat > /dev/shm/some_script #!/bin/sh echo hi $ chmod +x /dev/shm/some_script $ /dev/shm/some_script bash...
Despite execution privilege, getting permission denied
1,659,734,788,000
Assuming that you can't reach the internet nor reboot the machine, how can I recover from chmod -x chmod ?
1 - use a programming language that implements chmod Ruby: ruby -e 'require "fileutils"; FileUtils.chmod 0755, “chmod"' Python: python -c "import os;os.chmod('/bin/chmod', 0755)” Perl: perl -e 'chmod 0755, “chmod”' Node.js: require("fs").chmod("/bin/chmod", 0755); C: $ cat - > restore_chmod.c #include <sys/types....
How can I recover from a `chmod -x chmod`? [duplicate]
1,659,734,788,000
I following Michael's reply to see what executable formats my Ubuntu can recognize to execute $ ls -l /proc/sys/fs/binfmt_misc/ total 0 -rw-r--r-- 1 root root 0 Apr 19 16:11 cli -rw-r--r-- 1 root root 0 Apr 19 16:11 jar -rw-r--r-- 1 root root 0 Apr 19 16:11 python2.7 -rw-r--r-- 1 root root 0 Apr 19 16:11 python3.5 --...
See How is Mono magical? for more background. /proc/sys/fs/binfmt_misc is a virtual file system managed by binfmt_misc (which is why the files are all 0-sized). cli is used for Windows and .NET executables (and really any MZ executable, as also used in DOS and OS/2); the detector it refers to determines whether a give...
What kinds of executable formats do the files under /proc/sys/fs/binfmt_misc/ allow?
1,659,734,788,000
I'm trying to figure how is the sticky bit used in NFS v3. RFC 1813 says on page 22: 0x00200 Save swapped text (not defined in POSIX). What do they mean by "swapped text"? In "NFS Illustrated", the author, Brent Callaghan, says it means not to cache. However, I haven't seen this explanation in other places.
The text section of an executable is the actual executable code, this is what it refers to. On Linux this request is ignored, it is just an optimisation, made by the admin. The kernel can do this for it self, without the prompt. It is saying that if the executable text gets swapped out, and the process ends, then keep...
What does the "sticky bit" mean in NFS?
1,659,734,788,000
If one program, for example grep, is curretly running, and a user executes another instance, do the two instances share the read-only .text sections between them to save memory? Would the sharing of the main executable text sharing be done similarly to shared libraries? Is this behavior exhibited in Linux? If so, do o...
Unix shares executables, and shared libraries are called shared (duh...) because their in-memory images are shared between all users. I.e., if I run two instances of bash(1), and in one of them run, say, vim(1), I'll have one copy each of the bash and the vim executables in memory, and (as both programs use the C libr...
Are .text sections shared between loaded ELF executables?
1,659,734,788,000
I imagine there's a environment variable or some setting I'm unaware of, but this is driving me nuts. baco:~ # ls -la /root/subversion-1.4.6/subversion/svnadmin/.libs/svnadmin -rwxr-x--- 1 root root 57263 Mar 10 2008 /root/subversion-1.4.6/subversion/svnadmin/.libs/svnadmin baco:~ # ls -la /usr/local/subversi...
Looks like the svnadmin binary is just a layer of code that wraps a shared library to do the actual work (including the version number). Indeed, if I run strings $(which svnadmin), the version message does not appear in the output, so it's not part of the svnadmin binary. So, a difference in the LD_LIBRARY_PATH betwee...
Bash executes a different file from the one prompted, even when providing full path
1,659,734,788,000
Can we determine inside the very script whether it started as source (.) or executable (shebang or something alike)?
Test on $0 if you have a script: #!/bin/bash echo $0 and make it executable (chmod 755 test.sh) and do: source test.sh you get bash (or something else depending on how you are logged in and what your shell is). If you do ./test.sh you get ./test.sh, so assuming that the script knows how it is saved on the disc you...
Script started as `source` or `executable`?
1,659,734,788,000
I am attempting to assemble the assembly source file below using the following NASM command: nasm -f elf -o test.o test.asm This completes without errors and I then try to link an executable with ld: ld -m elf_i386 -e main -o test test.o -lc This also appears to succeed and I then try to run the executable: $ ./test...
You need to also link start up fragments like crt1.o and others if you want to call libc functions. The linking process can be very complicated, so you'd better use gcc for that. On amd64 Ubuntu, you can: sudo apt-get install gcc-multilib gcc -m32 -o test test.o You can see files and commands for the link by adding ...
Unable to run an executable built with NASM
1,659,734,788,000
So for convenience, I store all my data on my Windows partition so that I can access my data easily from both Linux and Windows. However, I tried compiling a C++ program with g++, and found out that I cannot run the program with ./program_filename, as it tells me bash: program_filename: Permission denied Doing cp pro...
Make sure that your mount options allow the execute permission bit. There are mount options one can use to limit the permissions of files within the mounted filesystem: general noexec prevents all files from being executable, FAT-specific option showexec grants the permission only to files with extensions .exe, .com a...
Why can't I run programs on another partition in Linux?
1,659,734,788,000
I am trying to get npm to work. In the process, I seem to have two versions of it installed: A corrupt one installed in ~/bin, and another I just compiled and ran make install to put it in /usr/local/bin/npm. So, I moved the entire ~/bin folder into ~/old/bin ... but still when I run npm the system searches in ~/bin: ...
The executable's previously known location is likely hashed by the shell. Resetting the shell's cache with hash -r should fix the issue. If you don't want to reset the entire cache, you can delete the individual entry for npm using hash -d npm.
What determines the path where the system searches for a file?
1,659,734,788,000
I'm developing a perl script which expected to be downloaded by Mac users with a very small knowledge of shell, linux etc, let's say office managers and accountants. After the downloading the script should be executed just by double-clicking via GUI. My goal is to make this as painless as possible to non-tech-savvy u...
Or, you can have sh take care of it for you: #!/bin/sh exec perl -x "$0" "$@" #!/usr/bin/perl ... Yes, that's sh and Perl all in one file. From man perlrun: -x tells Perl that the program is embedded in a larger chunk of unrelated text, such as in a mail message. Leading garbage will ...
run perl script with unknown perl location
1,659,734,788,000
I have this at the top of a script #!/usr/bin/env mocha as most people know, this tells the OS which executable to use to execute the script. However, my question is - how can we include more information to the mocha executable as to how to execute the script? mocha takes optional arguments, so I would like to do som...
The shebang line is interpreted by the kernel and is not very flexible. On Linux, it's limited to a single argument: the syntax is #!, optional whitespace, path to the interpreter (not containing whitespace), optional whitespace, and optionally a single argument (which may contain whitespace except at the beginning). ...
Include more instructions on how to run file in hashbang or elsewhere
1,659,734,788,000
I deleted the executable, so why is it still running? root@raspberrypi:/test# ls -la total 11096 drwxrwxrwx 2 pi pi 4096 Mar 12 18:26 . drwxrwxr-x 11 pi pi 4096 Feb 28 13:50 .. -rwxrw-rw- 1 pi pi 12149 Feb 28 13:00 .cproject -rwxrw-rw- 1 pi pi 3183 Mar 12 18:26 main.cpp -rwxrw-rw- 1 pi pi 2169 F...
Looks like it's a problem synchronizing the NFS folder. If I create the executable on the NFS server, it will only be visible/executed locally after an ls command. If I delete the executable on the NFS server, it still runs locally, event after an ls command showing that the file is not there. But if I delete the exec...
Why does this executable still execute after I deleted it?
1,314,899,170,000
Is there a way to detect if an external command exists (i.e. wget, svn)? More specifically today, i was trying to run one of my scripts i wrote and the person didn't have wget or svn installed. The script just downloads a file extracts it or uses svn to export the trunk.
In Bash the type shell built-in gives information about the executable things: aliases, functions, executables. See help type for details. # just check for existence type -t 'yourfunction' > /dev/null || echo 'error: yourfunction not found' # explicitly check for given type [[ "$( type -t 'yourfunction' )" != 'functi...
How would one detect if external command exists in a script?
1,314,899,170,000
I am trying to port Android apps to Linux (don't laugh :) and I have come across a problem. When trying to execute an Android executable (app_process) after adding the executable permission with ./app_process it says it doesn't exist although cat ./app_process works. Also in my file manager (Pantheon Files) the execut...
Android and Linux are two different operating systems. You can't just take an executable from one and run it on the other. The first hurdle is the kernel. Android and Linux are based on the same kernel, but they have a few different features. In particular, Android provides binders, which only exist in the mainstream ...
Why can't I execute Android x86 executables on Linux
1,314,899,170,000
Reading What do the brackets around processes mean? I understand that the executable name is printed. Linux ps man page: Sometimes the process args will be unavailable; when this happens, ps will instead print the executable name in brackets. However with ps -Awwo pid,comm,args I get: PID COMMAND COMMAND ...
Both the comm column and the first word of the args column in the ps output show the name of the executable program if everybody involved follows the default convention. However it is possible to have discrepancies for various reasons. When a program starts, the command name as shown in the args column is chosen by th...
What does `init [2]` mean in the COMMAND column of ps?
1,314,899,170,000
$ uname -a Linux kali 4.3.0-kali1-amd64 #1 SMP Debian 4.3.3-5kali4 (2016-01-13) x86_64 GNU/Linux $ lsb_release -a No LSB modules are available. Distributor ID: Kali Description: Kali GNU/Linux Rolling Release: kali-rolling Codename: kali-rolling Recently, I download IDA Demo from hex-rays website. After downl...
Oh I think I must install gcc-multilib first by: sudo apt install gcc-multilib
bash: ./idaq: No such file or directory
1,314,899,170,000
Once while talking with my friend I was trying to joke that we might stand a better chance of completing our project if we just run loads of random programs and expect one of them to solve our problem. To demonstrate that, I wrote this "proof of concept": while true; do dd if=/dev/urandom of=pliczek count=1 chmod +x ...
You are writing 512 bytes into a file and execute it. So the outcome could be anything a program with 512 bytes could possibly do. What that is depends on your machine. But 512 bytes are plenty of instructions, so basically everything could have happened like changing the root password, creating random files or genera...
What does this command actually cause?
1,314,899,170,000
I've recently purchased a usb stick which I will be using to share data between me and my colleagues. I'd like to format it as ext3, but I know this will cause trouble because for instance Mac OS X has troubles mounting that. The problem is that any other FS I've used before (except for ext2 or ext4) seems to screw ...
According to Universal Disk Format - Wikipedia, UDF may work: it has POSIX-style permissions, is readable by Linux, Mac OS X, and Windows XP and up, and is writable by Linux, Mac OS X, and Windows Vista and up.
Most unix-like filesystem that can be mounted under windows and Mac OS X
1,314,899,170,000
I understand that there are two stages of execution in Linux, dealing with every command we run. I'll name this how I understand them because I don't know the original phrasing: Shell handling --- The shell edits the command (splitting it to different rows etc) and all of this is done in a different shell than the cu...
Shell handling --- The shell edits the command (splitting it to different rows etc) Yeah, sort of. The shell gets a command as a single string (usually one line of input), and turns it into a set of strings that actually go to the executable it eventually runs. The shell splits the whitespace separated words from ...
What are the main execution stages in Linux (how does a program basically gets executed in Linux)?
1,314,899,170,000
The description of the bzImage in Wikipedia is really confusing me. The above picture is from Wikipedia, but the line next to it is: The bzImage file is in a specific format: It contains concatenated bootsect.o + setup.o + misc.o + piggy.o. I can't find the others (misc.o and piggy.o) in the image. I would...
Till Linux 2.6.22, bzImage contained: bbootsect (bootsect.o): bsetup (setup.o) bvmlinux (head.o, misc.o, piggy.o) Linux 2.6.23 merged bbootsect and bsetup into one (header.o). At boot up, the kernel needs to initialize some sequences (see the header file above) which are only necessary to bring the system into a de...
More doubts in bzImage
1,314,899,170,000
When I am building software from source on a GNU+Linux system, during the ./configure stage I frequently see the following line: checking for suffix of executables... How do I create such a check in a bash script? The reason I want to know this is that I want to create a makefile in which it compiles with suffix .exe...
The test is done by compiling a small dummy C program and by checking how the compiler names the output file. The following example is a simplified version of what configure is doing #!/bin/sh cat << EOT > dummy.c int main(int argc, char ** argv) { return 0; } EOT gcc -o dummy dummy.c if [ -f dummy.exe ] ; then...
Find out extension of executable files?
1,314,899,170,000
I was working through my C programs, I am new to Linux/UNIX development and was having a look around. I created a simple C program of Hello world and was inspecting the compilation process. I tried to read the file header of the final executable and got the Output as this $ objdump -f my_output file format elf32-i386 ...
The flags in the output are BFD - Binary File Descriptors. They're part of the binutils package, you can read what the flags mean if you look in the bfd header file /usr/include/bfd.h for their meaning or here. The reference to the "flags" 0x00000112 is what's called a flag field. It's binary and each bit represents a...
Portions of the file Header
1,314,899,170,000
I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command. ls -l `find Test/ -perm /u=x,g=x,o=x -type f` Is this a good/right/quick command or not? My solution is: find Test/ -executable -ty...
Not really, you can integrate the ls command with find, find Test/ -type f -perm /u=x,g=x,o=x -exec ls -l {} \; UPDATE Actually -executable is not an equivalent of -perm /u=x,g=x,o=x. You might have files that is executable only by the group or others, which will not be displayed. So, depends on your purpose, if you w...
Find executable files recursively
1,314,899,170,000
When a command is piped to another command in what way or in what format does the piped output exist/get sent? Is it a temporary file? Is it a string? And how does the command that receives the piped output decode/read that output? Example: echo "Someone string" | ./program | tail Does the program "program" receiv...
It goes as a bit stream. That's how it's sent and how it's received. The interfaces are file descriptors (or handles). A simple file is also handled that way. See: Standard streams on Wikipedia File descriptor on Wikipedia
In what format does piped output get sent and received from one command/program to another? [duplicate]
1,314,899,170,000
I am writing expect script which can be used on mulple operating systems but the problem is i can't use #!/usr/bin/expect evreywhere so instead i tried to do #!`which expect` at the top but it failed [sesiv@itseelm-lx4151 ~]$ ./sendcommand -bash: ./sendcommand: `which: bad interpreter: No such file or directory an...
One trick that mostly works (for perl, python, php interpreters, and probably others): #!/usr/bin/env expect I think env is always in /usr/bin/. A lot of interpreters can run that way now. Other hacks used to exist, but weren't understandable, or weren't all that portable.
Specifying a generic interpreter for a program like expect?
1,314,899,170,000
I am trying to run the statistics software Stata 11 on Ubuntu 11.10. as a regular user and I get the following error message: bash: xstata: Permission denied The user priviledges seem ok to me, tough: -rwxr-x--x 1 root root 16177752 2009-08-27 16:29 xstata* I would very much appreciate some advice on how to resolve ...
In the ls output you can see the file owner(root) and group(root). The user priviiledges apply to file owner (rwx), file group (r-x) and others (--x). Because you are not the root (and I suppose that you are not in the root group), only other (--x) applies to you. Thus you can run the file, but not read it. As a quick...
"Permission denied" when starting binary despite "rwx" priviledge
1,314,899,170,000
Well I'm just too green to Linux, but I'm stuck with a thing that I should know, and I don't. My file has the following permission bits sets: -r-xr-xr-x is owned by root ( but it should not matter since -x is active even for any user) it is not writable, and since it resides on a CDROM even if is a virtual iso mount...
The most likely explanation is Patrick's: the filesystem is mounted with the noexec option, so the execute permission bits on all files are ignored, and you cannot directly execute any program residing on this filesystem. Note that the noexec mount option is implied by the user option in /etc/fstab (supposedly for sec...
Can't execute a file with execute permission bit set [duplicate]
1,314,899,170,000
Can an executable know where it is stored? For my open source project, I wrote a small bash script to automate some operations. The script lies at the root of the project and performs its tasks on all files below. People have the project files on their own computers, at their favorite path, so I can't just hardcode cd...
#! /bin/bash echo I am located in $(dirname "$0") cd "$(dirname "$0")" Note that this may be a relative path.
Can an executable know where it is stored?
1,314,899,170,000
Surely this is an easy question, that I just don't know how to search for, but if I have two identically named executable files, one in /usr and one in /usr/local (for example), how can I change which one is executed by default without specifying the path, as in /usr/local/file, if $ which returns /usr? Centos6.4 btw....
It's not always as simple as "which comes first in $PATH;" see https://superuser.com/questions/358695/how-does-linux-decide-which-executable-im-trying-to-run. For a quick fix, set an alias in .bashrc (assuming you're using bash...) alias gorgonzola='usr/local/gorgonzola' Note: white space is not allowed around the "=...
How to change which program is executed by default
1,314,899,170,000
Possible Duplicate: “No such file or directory” lies on Optware installed binaries I am currently trying to get some piece of hardware to work on an embedded device. One part of the driver is an executable, which has to be started to get the hardware to work. However when I try to execute it I get bash: no such fi...
Although the architecture is the same, and this message commonly indicates that the binary is for a foreign architecture, the real meaning of this message is that it's linked against an incompatible C runtime library. See this message on the Linux From Scratch website. In his case upgrading glibc gave him this error f...
File not found for file which is there [duplicate]
1,314,899,170,000
I'm looking for a way to have an executable binary hardwired into a script. Something like this: #!/bin/bash ...some shell code execute binary: >>> binary code ... <<< ...some more shell code possibly I've found this solution, which uses uuencode and is good. But it depends on shrutils...
How about: unpack() { tail +9 "$0" > /tmp/xxx.$$ chmod +x /tmp/xxx.$$ } unpack /tmp/xxx.$$ <add args here> rm /tmp/xxx.$$ exit <add the binary here> If you don't like to have binary data in the script, you may encode it and replace cat by the related decoder. Note that you need to replace the +9 by the line n...
Is there a way to embed an executable binary in a shell script without extra tools?
1,314,899,170,000
Please help me to find out how to limit number of program concurrent executions. I mean, particular program can be ran only, for example 5 times at once. I know how to limit proccess number for user, but how to do that for program, using PAM?
PAM is used to authorize logins and account modifications. It is not at all relevant to restricting a specific program. The only way to apply a limit to the number of times a program can be executed is to invoke it through a wrapper that applies this limit. Users can of course bypass this wrapper by having their own c...
Limit number of program executions
1,314,899,170,000
As shown by the following code: ll total 136 -rwxr-xr-x 1 kaiyin kaiyin 19067 May 9 2013 dbmeister.py -rwxr-xr-x 1 kaiyin kaiyin 1617 Jul 29 2011 locuszoom -rwxr-xr-x 1 kaiyin kaiyin 112546 May 9 2013 locuszoom.R ./locuszoom -bash: ./locuszoom: Permission denied locuszoom is executable globally, but still c...
The harddisk needs to be remounted so that exec mount option is included. excerpt from mount man page FILESYSTEM INDEPENDENT MOUNT OPTIONS .... exec Permit execution of binaries. You can do this 1 of 2 ways. Examples Via the command line. $ mount -o remount,exec /media/data1 Or in your /etc/fstab. # <file ...
File executable by all, yet still cannot be executed?
1,314,899,170,000
I have noticed that sometimes python scripts are not being started directly, ie /foo/bar.py, but rather from a shell script, which does nothing else than /usr/bin/python -O /foo/bar.py $@ One such example is wicd network manager. /usr/bin/wicd-gtk is a shell script, which starts the wicd-client.py: $ cat /usr/bin/wicd...
You didn't post the full script — the script does other things before running wicd-client.py. It first ensures that a certain directory and a certain symbolic link exist: # check_firstrun() if [ ! -d "$HOME/.wicd" ]; then mkdir -p "$HOME/.wicd" fi # Make sure the user knows WHEREAREMYFILES ;-) if [ -e "/var/lib/w...
direct execution of python scripts
1,314,899,170,000
I'm running a 64bit kernel, already have CONFIG_IA32_EMULATION set, so do I still need CONFIG_IA32_AOUT enabled? From the help in menuconfig, I don't quite get it.
Short answer: If your system is a normal desktop/laptop and you don't run any really archaic software, you should be safe to disable CONFIG_IA32_AOUT. Keep CONFIG_IA32_EMULATION, as chances are that some of your binaries are still 32-bit. Explanation: There are two issues involved here: executable file formats and e...
What does CONFIG_IA32_AOUT do actually?
1,314,899,170,000
I was going through the questions of this site. In this particular question, I see the command lsof being used to list the files that are open for a particular user. I ran the below command in my terminal. lsof -a -u root -d txt I am seeing a long output which are completely irrelevant (at least to me). I am findin...
lsof lists all files that are accessed by a program one way or another. The fourth column (FD) describes the way in which the program is accessing the file. Here are some common cases (there are others): A number: the file is opened by the process, and the number is the file descriptor. Letters after the file name in...
lsof - debug the output information
1,314,899,170,000
I see that there are other questions like this out there, but the answers there did not work for me. I am using I downloaded the Julia 1.9.2 (Linux, x86-64, glibc) prebuilt binary and tried to execute the binary, but I get the following error. bash: ./julia: cannot execute: required file not found I am able to execute...
Julia 1.9 is already available in nixpkgs. For some reason Julia 1.8 is the top result, which is why I might have missed it. As such this particular issue falls under the general category of executing non-NixOS binaries on NixOS and has already been covered the Unix stack exchange.
Cannot exceute binary: required file not found
1,314,899,170,000
I use Vim a lot, and I know how I can start vim in insert mode. So I have an alias named vii in my .bash_aliases file. On other hand I use Git a lot too, and I have this line in my .gitconfig: [core] editor = vi To write a commit message the vi editor is opened every time and I have to go in insert mode. So I tho...
Aliases are internal to each of your current shell environments - they are expanded by the currently running shell (bash in your case), so they only have effect on what you execute by typing/pasting in your terminal. You have at least two options here: create a wrapper script named vii that will execute vim -c 'start...
place the aliased version of an existing command in /usr/bin/
1,314,899,170,000
I watched a video lecture today that introduced C and things like how to make a C program that will run in Linux. I followed the steps given and now I'm stuck with a bit of a problem. I created my C file (HelloWorld.c) and used the command gcc -o HelloWorld HelloWorld.c to compile the file, both of these steps were su...
You don't have the value of the PATH environment variable set to include whatever directory the HelloWorld executable file lives in. Supposing you have used cd to get to the directory, you can run HelloWorld with this command: ./HelloWorld Unix shells have a variable called PATH, which is a :-delimited list of directo...
Running C Programs on Linux
1,314,899,170,000
I use Ubuntu 16.04 and I have a localization file, a file that executes many files, that I got after downloading my own GitHub project to my machine. This file contains a Bash script, and is named localize.sh. I run it in a subsession via ~/${repo}/localize.sh. The file contains many lines, all with the same basic pat...
Based on the Answer by Marc, I assume the shortest solution would be something like this: $ myPath="$HOME/$repo"; find ${path} -type f -iname "*.sh" -exec {} \; file_1 file_2 ...
How to execute many files in the same directory in a minimal, DRY, pretty way?
1,314,899,170,000
I am working on a Linux server, and I running different jobs on different node. However, when compiling my program, I didn't set their specific name, so they are all a.out Now I found one of the running a.out, may be not right, and want to terminated. But the Top command doesn't show the path to the executable. How ...
You can use lsof (available for just about any Unix variant, but often not part of the default installation) to list all the files a process is using. “Using” includes open file descriptors as well as closely related concepts such as which executable the process is running. The executable has txt in the FD column, for...
How to know the path of a running executable?
1,494,218,857,000
I have made a simple addition program in C in both OS, Linux (Ubuntu and CentOS) and Windows 7 with the same source code, which is as follows: #include <stdio.h> int main(){ int a,s,d; printf("type the values u want to add and give tab between them\n"); scanf("%d %d",&a,&s); d=a+s; printf("addition is %d",d); ret...
The core of the issue is that you're trying to run the program, which is console application, but you don't have terminal attached to it. In terminal you can run your program by just calling the program name, but in GUI you need to specify explicitly that there should be a terminal window raised to run console apps (t...
a program made in c runs on double click in windows but not in linux
1,494,218,857,000
The job of my Unix executable file is to perform a long computation, and I added a interrupt/resume functionality to it as explained below. At regular intervals, the program writes all relevant data found so far in a checkpoint file, which can then be used as a starting point for a "resume" operation. To interrupt the...
It depends a bit on if you care only about the program itself crashing, or the whole system crashing. In the first case, you could write the fresh data to a new file, and then rename that to the real name only after you're done writing. That way the file will contain either the previous, or the new checkpoint data, b...
Best way to create "interruptable" executable
1,494,218,857,000
How do I use file to differentiate between ELFves and scripts as quickly as possible? I don't need any further details, just ELF, script (/plaintext), or other/error.
If it's just between ELF and script, you may not need file at all. With bash: IFS= LC_ALL=C read -rn4 -d '' x < file case $x in ($'\x7fELF') echo ELF;; ("#!"*) echo script;; (*) echo other;; esac (-d '' (to use NUL character as delimiter) is to work around the fact that bash's read otherwise just ignores the NU...
Differentiate between ELFves and scripts quickly
1,494,218,857,000
I have a source tree which, when make is run, produces several executables named "001", "002", and etc. I'm trying to write a script which will find all of these executables in my source tree, and then execute them. I have this so far: find build/ -type f -executable | ack --nocolor "\d{3}$" Which lists the executable...
Try: $ find build/ -type f -executable | ack --nocolor "\d{3}$" | while read prog do "$prog" done
Execute all files in a list
1,494,218,857,000
I've installed hddtemp on my Arch Linux, but it needs to be run with root permissions. I want to execute it as a normal user without using sudo. How can I do this?
It's possible to assign users in a group permission to run an executable by using the /etc/sudoers mechanism. For instance, to permit all users in the users group to run hddtemp with root permissions run visudo as root and add: %users ALL = (root) NOPASSWD: /path/to/hddtemp
Make a programme executable by common users
1,494,218,857,000
This is more of a general question I have been curious about but put simply: how does bash execute commands given to it via a script or terminal? It would be possible, I guess, to have a bunch of if statements checking all commands like so (Pseudocode): if (command == "pwd") pwd(); else if (command == "echo") echo(); ...
Basically, some commands are built in to the bash shell program itself (e.g. echo, set), in which case, bash already has the code compiled into it to run those commands internally, in response to a user calling them from the command line. If you look at the manual in man bash or info bash, it has a list of the 'builti...
How does bash execute commands
1,494,218,857,000
I have (foolishly?) written a couple of moderately general-purpose xslt scripts. I'd quite like to turn these into executables that read an xml document from standard in or similar. The way you do this with other languages is to use a shbang. Is there an easy / standard way to do this with xsltproc and friends? Sure...
You could use the generic binfmt-misc kernel module that handles which interpreter is used when an executable file is run. It is typically used to allow you to run foreign architecture files without needing to prefix them with qemu or wine, but can be used to recognise any magic characters sequence in a file header, o...
xslt shbang: Using xslt from the command line
1,494,218,857,000
Here is what I do tree -R /Applications/NetBeans/NetBeans\ 7.0.app/ | perl -e 'while (<>) { print if /java$/ }' but of course this doesn't return the result I want. What I want is to display an executable java file along with its recursive directory so that I would know where that java file is. Something like this st...
To find executable files called java under the specified directory: find '/Applications/NetBeans/NetBeans 7.0.app/' -name java -type f -perm -u+x The output will be one file name per line, e.g. /Applications/NetBeans/NetBeans 7.0.app/Contents/Resources/NetBeans/ExecutableJavaEnv/java If you want to omit the …/NetBea...
How to grep recursive UNIX tree results along with each tree node?
1,494,218,857,000
I’ve made a script that would work on rhel distros and forks. It’s for personal use to automatically download repositories and software that I use. When I make the script executable on the host machine I can right click on the script and choose run as a program. When I copy the script to a flash drive and then copy it...
When I copy the script to a flash drive and then copy it from a flash drive to another computer running the same operating system I have to make it executable again to give back the function to right click and run as a program. Execute permissions are not preserved when you copy files to and from the flash drive bec...
How to make my script stay executable on different devices?
1,494,218,857,000
It would be handy to be able to start Java programs by just calling the class file from the terminal (and have it running it the terminal when double-clicked in GUI, but this is less important). I so far only help myself with the following ad hoc fix: alias cs='java charstat.Charstat' Linux recognises the files as Ja...
Linux Ubuntu already does this for a jar. With the openjdk-8-jre package (and earlier versions), executing a jar invokes jexec on it. This isn't done for a class, maybe because it's rare for a class to be a standalone executable rather than a library (then again, that's also the case for jars). You can configure the s...
Getting Java programs start without calling with Java
1,494,218,857,000
I'm wondering if $PATH cascades entries. You'll all need to take a leap of faith with me here, but here it goes. Let's say we have a Java executable at /usr/bin/java but this version is very old and outdated. Unfortunately, we don't have su access so we can't just replace it. We can, however, download the current vers...
Your $PATH is searched sequentially. For example if echo $PATH shows /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin, each of those directories is searched in sequence for a given command (assuming the command isn't an alias or a shell builtin). If you want to override specific binaries on a per-user basis ...
Handling duplicate programs names bash
1,494,218,857,000
Trying to run an executable file on terminal (I am using Tails live OS), but I keep receiving an error message. I have set permissions already. The command I wrote: sudo ./home/amnesia/myfile I receive "Command not found"? I tried running it with or without sudo: $ sudo /home/amnesia/myfile sudo: unable to execute /h...
$ /home/amnesia/myfile bash: /home/amnesia/myfile: No such file or directory $ file /home/amnesia/myfile ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped So myfile exists, but running it gives the message “No such file or directory”. This ha...
/home/amnesia/myfile: command not found — 64-bit executable, 64-bit kernel
1,494,218,857,000
I set some additional locations to the PATH environment variable in my ~/.bashrc so that these are included/sourced in logins and non-interactive scripts that are scheduled with cron. I've noticed though that on one system the PATH is modified correctly, but none of the scripts within will run despite ownership and pe...
You mentioned in the comments that your home directory's filesystem is mounted with the users mount option. $ grep home /etc/fstab LABEL=home /home ext4 noatime,users 0 4 – The users mount option implies noexec. From mount(8): users Allow every user to mount and unmount the filesystem. This option implies the o...
permission denied on scripts in ~/bin
1,494,218,857,000
I am trying to write a script that will attempt to find if a certain program is installed. Lets say that the program is called, myprog. The problem is that the program can be named in different formats such as, 'prefix-myprog', 'myprog', and 'prefix_myprog'. If I use: which myprog then the command line will return ...
find /bin /sbin /usr -type f | grep -i myprog Find all files in directories /bin, /sbin and /usr, then filter on 'myprog'. man find man grep apropos myprog can be useful too. man apropos or what about locate -r myprog? man locate
Finding program name by wildcard pattern
1,494,218,857,000
I want to know, if I can use the binary of a program without modification on the three systems? After all they are all Unices. I talk about the same architecture.
No, you cannot, as the ABIs differ. Some BSDs do have binary compability with Linux binaries, with some caveats (enabling virtual 8086 mode is a common issue). Often you may need to patch the source, however, as many binaries will make assumptions about their environment based on the fact that the source is developed ...
Can I use the same binary on Linux, *BSD and Illumos?
1,494,218,857,000
After reading about removing the execute permission from chmod, I got curious. Is it possible to recover from removing the execute permission from ld-linux.so without rebooting if I haven't yet exited bash? Every command appears to stop functioning.
You would need a statically linked (or already running) utility that can do a chmod operation. If you had a statically linked BusyBox or a similar emergency shell installed, that would probably do it. In some old distributions, the basic package management utility (e.g. dpkg or rpm) used to be statically linked to ena...
Recovering from removing execute permission from ld-linux.so
1,494,218,857,000
I want to put a bunch of executable scripts in the .command dir (which is also executable), and then only have to source that directory in my .bash_profile. Is this possible? I can get this to work with one file. But when adding a second file, the second file's commands aren't available in the shell. my .bashprofile ...
You can't do that with one source. The first argument is taken as the file name, the others show up as the positional parameters $1, $2... in the sourced script. $ cat test.src echo hello $1 $ source test.src there hello there But you could do it with a loop: for f in ~/commands/*.src; do source "$f" done (As a...
Can you put multiple executable scripts in one directory, and by sourcing that directory make all of those commands available?
1,494,218,857,000
I'm not sure if this is the best place to ask this - please point me in the right direction if there's a better place. Let's say, hypothetically, that I have two machines - A is a development machine, and B is a production machine. A has software like a compiler that can be used to build software from source, while B ...
Using what you have so far and if the makefile is generated with GNU autotools, I would set the target location or install path with ./configure --prefix=/somewhere/else/than/the/usual/usr/local and then run make && make install and finally copy the files from the prefix folder to the usr/ folder in the other machin...
Can binaries built from source be installed on a second machine?
1,494,218,857,000
Basically, I want to receive input from 2 different files whem I'm calling an executable on terminal Like: ./a.out < file1.pgm file2.pgm I want to read both the files input on my code, one after another.
For the question, where file1.pgm and file2.pgm are files whose contents you want sent to a.out as input: cat file1.pgm file2.pgm | ./a.out If file1.pgm and file2.pgm are executables that produce output for a.out: (file1.pgm; file2.pgm) | ./a.out
How to receive input from 2 files on an executable
1,494,218,857,000
Possible Duplicate: Getting “Not found” message when running a 32-bit binary on a 64-bit system ts3user@...:~/ts3$ dir CHANGELOG LICENSE doc ... ts3server.pid ts3server_linux_x86 ts3server_minimal_runscript.sh ts3server_startscript.sh tsdns ts3user@...:~/ts3$ ./ts3server_linux_x86 sh: ./ts3server_linux_x86: No su...
Teamspeak has two server package:"Server amd64" or "Server x86" You try to execute the 32 bits version, and I guess your linux is 64 bits. Two solutions: download the 64 bits package install the ia32 libs to be able to run 32 bits binaries: sudo apt-get install ia32-libs
Linux isn't sure whether a file exists or not [duplicate]
1,494,218,857,000
my platform: SOC = STM32H743 (ARMv7E-M | Cortex-M7) Board = Waveshare CoreH7XXI Linux Kernel = 5.8.10 (stable 2020-09-17) initial defconfig file = stm32_defconfig rootfs = built using busybox | busybox compiled using arm-linux-gnueabihf-gcc I've created rootfs by following this guide. my kernel cannot execute any f...
the problem is that you are compiling it in a normal static elf format. you should compile it as an FDPIC-ELF executable (because you need a position independent executable (FDPIC) due to the lack of MMU). FDPIC ELF is not ET_EXEC type. it is ET_DYN (it means it's shared) type and it is loaded by the Linux dynamic loa...
kernel cannot execute binaries (error -8)
1,494,218,857,000
I was reading about setuid on Wikipedia. One of the examples goes as follows: 4700 SUID on an executable file owned by "root" A user named "tails" attempts to execute the file. The file owner is "root," and the permissions of the owner are executable—so the file is executed as root. Without SUID the user "tails" woul...
You are right and the Wikipedia article is wrong. See the below for an example: $ ls -l /usr/bin/passwd -rwsr-xr-x. 1 root root 30768 Feb 22 2012 /usr/bin/passwd $ sudo cp /usr/bin/passwd /tmp/ $ cd /tmp $ ls -l passwd -rwxr-xr-x 1 root root 30768 Dec 21 07:43 passwd $ sudo chmod 4700 passwd $ ls -l passwd -rws----...
setuid example from Wikipedia: 4700
1,494,218,857,000
I created a desktop entry and moved it to ~/.local/share/applications, but it doesn't execute when I click on it from the start menu. This is my .desktop file: [Desktop Entry] Type=Application Categories=Game Name=Minecraft Icon=/home/user/Games/Minecraft/Minecraft-icon.png Exec=/home/user/Games/Minecraft/Minecraft.ja...
You have to specify that you want to run .jar file. Normally jar are not treated as executable so for Exec part you have to add java -jar like this: Exec=java -jar /home/user/Games/Minecraft/Minecraft.jar
How to create a desktop entry for .jar files?
1,494,218,857,000
As of OpenBSD 6.0 mandatory W^X enforcement is implemented. Binaries that need permission to violate this rule can be marked with the ld command: Identify W^X labelled binaries at execve(2) time based upon the WX_OPENBSD_WXNEEDED flag set by ld -zwxneeded. I tried: ld -b <binary> -zwxneeded ld <binary> -zwxn...
Found the answer after rereading openBSD upgrade guide, filesystem mount options have to be adjusted in fstab. The wxallowed mount option. W^X is now strictly enforced by default; a program can only violate it if it is located on a filesystem mounted with the wxallowed mount(8) option. This allows the base system to ...
Mark binaries writable and executable in openBSD
1,494,218,857,000
I'm trying to execute some binary with bash. I am getting a "Permission denied" message despite having given the full privileges (chmod 777) and being the 'root' user: This is the file description: -rwxrwxrwx 1 root root 641K Aug 22 15:04 wrapid This is the error message: bash: ./wrapid: Permission denied Output of...
According to the info provided you are trying to run 64-bit executable on 32-bit kernel. It won't work that way. You either need 32-bit binary or 64-bit kernel/glibc libraries.
permission denied when executing binary despite "rwx" privilege and root user
1,494,218,857,000
I have this simple Bash script: #!/bin/bash java -jar ClosureCompiler/compiler.jar --js ../src/typescript.js --js ../src/ts-compiler.js --js_output_file TSCompiler.js I'm getting this error when I try to run the script using build.sh in the MSYS environment under Windows (64-bit!): ./build.sh: ./build.sh: cannot exec...
The file was encoded in UCS-2 Little Endian ! Changing the encoding to UTF-8 without BOM resolved the issue.
Calling java from Bash: "Cannot execute binary file"
1,494,218,857,000
A C# file in mono can be compiled using gmcs command. This will create a hello.exe file. $ gmcs hello.cs $ ls hello.cs hello.exe $ ./hello.exe Hello from Mono! To generate a linux executable, I tried this command, but it generates the error: $ gmcs /t:exe hello.cs /out:hello Unhandled Exception: System.ArgumentExce...
I was very impatient and felt that the package mono-2.0-devel might have mkbundle. So I went ahead and installed mono-2.0-devel which needed only 18 additional packages. When I typed mkb and hit tab, it showed me mkbundle2. I tried: $ mkbundle2 -o hello hello.exe --deps OS is: Linux Sources: 1 Auto-dependencies: True ...
Generating a Linux executable with Mono with mkbundle
1,494,218,857,000
I've just tried installing tmux from source (via installing libevent first). The installation seemed fine, without throwing any obvious error. But when I typed tmux in iTerm2, it returned "command not found". However, there is clearly an executable named tmux in /opt/bin/. So I am a bit puzzled that whether I have suc...
When you type tmux in a shell, the shell looks for an executable called tmux in one of the directories enumerated in the PATH variable (it's a colon-separated list of directories). Check if /opt/bin is in your path: echo $PATH If /opt/bin is not in your path, then either install tmux in a different directory that is ...
How to verify if tmux is properly installed on Mac OSX
1,494,218,857,000
I've installed PgSQL 9.1.2 from PostgreSQL repositories and all it's fine except that I can't execute command from every path in my OS. For example suppose that I want to run the command pg_dump: for that I need to change from (actual path) to /usr/pgsql-9.1/bin and then execute as ./pg_dump even if I'm root user. I t...
Just open your .bashrc and add the following lines in the end: PATH=$PATH:/usr/pgsql-9.1/bin export PATH
Access PgSQL executables from anywhere
1,494,218,857,000
I am running a python script named myscript.py on ubuntu machine. I usually use python command to run python scripts as below. python main.py Recently, I downloaded a python script from a Github repository ( if need to look into the repository can find it at https://github.com/gsrivas4/mnist-gan) which asks to run sc...
./ is simply a relative path indicating the current working directory. When executing a file that is not in your PATH it's necessary to prefix it with either the full path or a relative path, ./ is the most simple method of doing this, but it would also work if you used a full path like /path/to/script.py The reason ...
Running python script on ubuntu machine using ./myscript.py
1,494,218,857,000
I have a binary code and I want to run it. 01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100 How can I create a file "application/x-executable" and execute it on Debian?
That's just the binary representation of the ascii encoding of "Hello World", not an executable, there's no way to execute that.
Execute binary code
1,494,218,857,000
I'm setting up prometheus in a web server, and I noticed that each exporter is its own program that must be added to a directory in $PATH. My question is, is there any advantage to making a specialized directory for these (for example, "/usr/exporters/bin", to make up some example) and put all exporter programs in the...
The only benefit is having fewer directories in $PATH, therefore, fewer directories to search when looking for an executable, but: This event (searching all the directories in $PATH) is rare. $PATH entries (the executables) are kept in a hash table within bash, which is updated at startup or via rehash. No need to se...
Is there any benefit to grouping similar programs into a single path directory?
1,494,218,857,000
Whenever I create or copy few shell files to usb storage device, then I am not able to make them executable. If I create test.sh, it's default file permission will be 644, but when I execute chmod 777 test.sh no error reports and echo $? also returns "0". But still ls -l shows permission as 644 and I can not execut...
Yes, this can occur if your device is formatted with a filesystem that does not support that kind of permission setting, such as VFAT. In those cases, the umask is made up on the fly from a setting in the fstab (or the hotplugging equivalent). See, most probably, man mount for details. For example, for VFAT, we find:...
can't change file permission
1,494,218,857,000
I am running a quite complicated script which changes directories and runs many other commands. All these commands are run using 'scriptname', which works fine when I execute the main script from my terminal. However, sometimes I have to ssh into a server and run the main script from there, it fails as there isn't a ....
There are ways to change this behavior including adding ./ to your PATH environment variable, but this introduces a serious security risk to your environment. The way your scripts are written is really wrong and the correct solution is to go through all of them and fix the way local scripts are called. This is the onl...
Run script without ./ before the name
1,494,218,857,000
I'm looking to find all executable files that are NOT in my $PATH. Currently I'm doing this find / \( -path "/opt" -prune -o -path "/var" -prune -o -path "/bin" -prune -o -path "/sbin" -prune -o -path "/usr" -prune -o -path "/opt" \) -o -type f -executable -exec file {} \; I feel like there is a better way, I tried u...
Assuming GNU find and the bash shell (as is used in the question), this is a short script that would accomplish what you're trying to do: #!/bin/bash IFS=: set -f args=( -false ) for dirpath in $PATH; do args+=( -o -path "$dirpath" ) done find / \( \( "${args[@]}" \) -o \ \( -type d \( ! -executab...
Find all executable files excluding certain directories
1,494,218,857,000
I pressed ENTER after typing the following stupid command on my home directory: find . -type f -exec chmod -x '{}' ';' What do you advise as a fix for this. My guess is that I can't do anything but do something like: find . -type f -exec chmod og+x '{}' ';' Or may be do some tricky stuff based on extensions (which d...
Here is a script that I wrote a while back to fix permissions on files copied from a FAT system. Won't work if the file names contain newlines (although if someone wants to fix it so that it does, feel free): #!/bin/sh [ $# != 0 ] && dir="$1" || dir=. [ -d "$dir" ] || { echo "usage: $0 [dir]"; exit 1; } cat <<- EOF...
How to recover from recursive 'chmod -x' on my home folder
1,356,038,512,000
I am looking for a structured format of version info for OS-level executables, such as in /usr/bin and /usr/local/bin. The problem we are having is the inconsistent architecture between our PROD and TEST environments and we are finding that many executables in our lower environments have had patches applied whereas P...
I'm inclined to say there is no easy way to do this. I say this because versioning is not at all a standarized procedure in UNIX/Linux or with any of the vendors at least at a program level. A suggestion might be to examine the installed package information which does contain versioning information. However, if pe...
Is there a structured format of version info for OS-level executables?
1,356,038,512,000
For example, if I do [OP@localhost executable]$ cat garbage lalala trololol [OP@localhost executable]$ chmod +x garbage [OP@localhost executable]$ ./garbage ./garbage: line 1: lalala: command not found ./garbage: line 2: trololol: command not found Bash seems to be trying to interpret this "executable" as a script....
Expanding on my previous comment on another answer, the kernel contains seven binary loaders (look for files starting with binfmt_ there, or read the binfmt-specific Kconfig): a.out (which is currently on a stay of execution); ELF; FDPIC ELF (on ARM, MMU-less SuperH, and C6x); em86 (on Alpha); flat binaries (on MMU-l...
What types of executable files exist on Linux?
1,356,038,512,000
I'm following the course of Baking Pi – Operating Systems Development. In it they created another section .init. So can we create as many sections as we want (not just .data, .bss, .text) and can we put code and data (initialized of no) in any of them?. If so, what's the purpose of sections then?
Initial research At first sight it would appear that the answer would be "no" the specification for ELF only allows the following sections. C32/kernel/bin/.process.o architecture: i386, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 Sections: Idx Name Size VMA LMA File off A...
How many sections can I create in object file?
1,356,038,512,000
I have a binary that runs on my Debian Squeeze system, but then it doesn't do anything on my Debian Wheezy (kernel Linux 3.2.0-4-amd64) system. Both systems are 64 bit, while the executable is a 32 bit binary. Here's the output of: me@myhost:~$ file myApp.run myApp.run: ELF 32-bit LSB executable, Intel 80386, versi...
The 64-bit O/S does not have the 32-bit libraries installed. apt-get update; apt-get upgrade; apt-get install ia32-libs This will provide the missing /lib/ld-linux.so.2.
Why won't my binary run?
1,356,038,512,000
I looked at this scheme and now i want to know, can one executable be runned in a two systems, which have the same ancestor? (and so probably the same kernel?) For example, according to the scheme: Solaris <- System V R4 <- BSD 4.3, so, can the BSD* (OpenBSD, FreeBSD, NetBSD) and the Solaris run the same executable? P...
Short answer: No. Medium answer: Maybe, if the target OS supports it. Long answer... First thing to be aware of is that different vendors may use different chip sets. So a Solaris binary may be compiled for a SPARC chip. This won't run on an Intel/AMD machine. Similarly AIX may be on a PowerPC. HP-UX might be on PA...
*nix executable compatibility
1,356,038,512,000
Say I have a somecommands.sh and I use chmod 777 to make it executable. Why I have to type ./scommand.sh instead of typing just somecommand.sh to run it from its own directory? Does this make any sense? If it's able to omit, what should I do? Thanks
You have to likely do that, because your current path (pwd) is not in your search path for executable files. Type this in your console: echo $PATH | tr ':' '\n' Every folder that is printed, is in the search path for executable files (in that order). Now, if you want to run a file from a different directory, you have...
Why when we run a executable file we need to add ./ ahead? [duplicate]
1,356,038,512,000
How do I change the permissions of an executable file to access the /etc/shadow file? So far I have the following bash script: #!/bin/bash gcc print.c -o print chmod +s print ./print exit 0 and the following c-code: #include <stdio.h> #include <stdlib.h> int main() { FILE *open = fopen("/etc/shadow", "r"); ...
To give a binary permission to run things as root, you need to set the "sticky bit" on the binary. Normally after compiling, you might see: # ls -l print -rwxr-xr-x 1 mark mark 111 24 Oct 17:32 print Setting the set-uid (sticky) bit can be done using and octal mode, or symbolically (note that you will need "root" ...
print the /etc/shadow file in the console
1,356,038,512,000
I'd like to override some hardcoded paths stored in pre-compiled executables like "/usr/share/nmap/" and redirect them to another dir. My ideal solution should not require root priviledges, so creating a symlink is not ok. (Also recompiling it's not an option)
I've just found this ptrace-based chroot reimplementation: PRoot. The bind function is just what i was looking for! This is more reliable than replacing strings in the executable + can be easily used in scripts...
override hardcoded paths in executables
1,356,038,512,000
I have Crunchbang 64 bit, a debian wheezy distro. Debian have a rebranded Firefox called Iceweasel and a rebranded Thunderbird called Icedove. But I don't want any of them. I was able to install the latest version of Firefox by adding Linux Mint repo, and installing it from there. I did the same and installed Thunder...
First of all, don't add mint repositories to Debian, not a good idea. Mint is based on Ubuntu which, while based on Debian, is not 100% compatible with Debian repositories. Mixing them is likely to cause trouble. Instead, add LMDE (Linux Mint Debian Edition) repositories. LMDE is Debian and is 100% compatible with the...
How to install the real Thunderbird on Debian wheezy?
1,356,038,512,000
I'm trying to execute a compiled Lazarus file which was working on macOS 10.14.x. After updating to 10.15, I started to get an error, "Bad CPU type in executable", which as far as I understand means that it is no longer compatible. ./myScript ->>>>>>>>>>>>>>> bad CPU type in executable file myScript ->>>>>>>>>>>>>>> M...
macOS Catalina (10.15) dropped support for 32-bit executables, which is why your executable no longer works. The ideal solution is to build a 64-bit binary. The Lazarus wiki describes how to do this: target x86_64, use Cocoa widgets, and build with fpc rather than ppc386.
Executing "Bad CPU type" executables in 10.15.x
1,356,038,512,000
Multiple Linux distros can be installed on the same machine. The format of executables should be the same for every one of them. So I want to use multiple distros on a single machine and have access to some applications like Skype, Chrome or Spotify from all. I don't want to waste time and disk space to install them o...
As far as I can understand you want to have a multi-boot system where you can boot a different Linux distros at a time, but keeping the same binaries in a shared partition. What you want to do isn't feasible, and if you were trying to do it, you would be spending 10x more time compared to managing each distro separate...
Different Linux distros sharing applications
1,356,038,512,000
Using pipes, one can create files with simple shell built-ins. { echo "#!/bin/bash" \ echo "echo Hello, World!" \ } > helloworld.sh With chmod these can then be made executable. $ chmod 755 helloworld.sh $ ./helloworld.sh Hello, World! I wonder whether it is possible to save the chmod step. Already, I found that u...
It is not possible to create an executable file solely with a shell redirection operator. There is no portable way, and there is no way in bash either (in the source code, you can see that redirection calls do_redirection_internal which calls redir_open with the parameter mode set to 0666, and this in turn calls open ...
create executable files via piping
1,356,038,512,000
Suppose I have a shell script file foo.sh. I can do chmod + x foo.sh and change it into an executable file. In Kernighan-Pike: Unix Programming Environment (UP) they show that after this typing foo should execute the script. Instead in my Ubuntu system I need to type sh foo or ./foo. I am guessing this is due to so...
The name of the executable is important. If your file is named foo.sh, then executing foo will not work unless there is some other executable named foo. Unlike Windows, Unix does not do implicit file extensions. If the following works: ./foo.sh But this doesn't: foo.sh That means that the file is in your current ...
About executing shell script
1,356,038,512,000
Coming from a windows platform I am a bit confused over how compressed files are installed in Linux . I am using fedora 20. Now I downloaded FoxIt pdf reader from here. I also read this post which explains what to do with compressed files.However I am still confused as to what to do when a the bz2 file is uncompressed...
That error (likely) means you are trying to run a 32-bit executable on a 64-bit system. I'll answer the specific issue here, but see the bottom of the answer for the better approach in general. You say have yum around, so this may help you: yum install lib/ld-linux.so.2 yum will try to find anything that provides tha...
Installing a bz2 file
1,356,038,512,000
Having downloaded archives of Sage, Firefox, and Thunderbird from their respective websites on Trisquel 6.0, neither clicking the appropriate shell script nor executing a command to run the programs will open them. Looking at the files' permissions, they are indeed executable. Edit: Firefox and Thunderbird have now my...
The first thing to check after extracting a program from an archive is the permissions (chmod a+x ./sage), but if that was the problem, the error message would be “permission denied” and not “command not found”. Give your description “opened the folder in the terminal and run the command”, it's likely that you ran the...
Why can't I run programs extracted from an archive?
1,356,038,512,000
Does execution of a file need read permission? It is natural to think yes, because execution of a file needs to load the file into memory. If the answer is no, why is that? In particular, same question when the file is a directory? Thanks.
When you execute a file, in many cases you don’t need to read it, so you don’t need read permission. You’re right, the system needs to read it on your behalf, but that’s not defined as requiring the read permission (because nothing running as you ever needs access to the file’s contents). The exception is any circumst...
Does execution of a file need read permission?
1,356,038,512,000
in my $PATH I have folder ~/.zsh/bin which I use for small scripts and custom built executable binaries, for example I added a recently compiled tool I made called wercker_build_status to the folder. Yet when I type in the command line wercker_build_status it can't find it, I have to type the full path to the file, ~/...
Use $HOME in your path rather than tilde (~), especially if you enclose the new PATH in double quotes. The tilde is not expanded when it occurs in quotes. Testing: $ mkdir "$HOME/t" $ cat >"$HOME/t/foo" <<END #!/bin/sh echo "hello" END $ chmod +x "$HOME/t/foo" $ PATH="$PATH:~/t" $ foo zsh: command not found: foo ...
binary placed in folder on $PATH is not immediately accessible
1,356,038,512,000
Situation Some programs that I build from source have a directory libexec in the installation directory (for example, gnuplot). As a matter of rule, I add a export LD_LIBRARY_PATH=${installation directory}lib:${LD_LIBRARY_PATH} to my .bashrc when I have lib folders. Likewise with PATH and PKG_CONFIG_PATH if ${insdir}/...
libexec is intended for private binaries, i.e. binaries which are used by a program but which shouldn't be available generally. See the FHS: /usr/libexec includes internal binaries that are not intended to be executed directly by users or shell scripts. So no, you shouldn't add it to any PATH-style variables.
Should libexec folders be added to some PATH-like variables?
1,356,038,512,000
CentOS here, but I don't think that matters because this should be a core Linux question (methinks). While trying to install & run Apache Kafka (a Java executable) on a CentOS box, I thought of a question that applies to Linux in general. When you run a shell script or a native executable (such as java), does the scri...
Short answer: both. Longer (and much more useful) answer: By default, the program will run as the user who launched it. However, a program can, if written to do so and given the correct permissions, assume root privileges and/or drop back down to a "system" user to run itself as. This ability must be explicitly bestow...
What user does a Linux script/app run as?