Questions tagged [executable]

The permission bit in a file mode that allows a file to be run as a program. Also, questions related the format of program files, and to locating and executing program files.

Filter by
Sorted by
Tagged with
255
votes
4answers
68k views

How do I clear Bash's cache of paths to executables?

When I execute a program without specifying the full path to the executable, and Bash must search the directories in $PATH to find the binary, it seems that Bash remembers the path in some sort of ...
156
votes
9answers
45k views

How to chmod without /usr/bin/chmod? [duplicate]

Today I was told a tale by a Unix trainer where the root password got leaked to the students, and one of the fellas removed the execute permission from /usr/bin/chmod itself. How do you recover chmod ...
149
votes
1answer
10k views

How is Mono magical?

I'm learning C#, so I made a little C# program that says Hello, World!, then compiled it with mono-csc and ran it with mono: $ mono-csc Hello.cs $ mono Hello.exe Hello, World! I noticed that when I ...
114
votes
9answers
21k views

Why is /dev/null a file? Why isn't its function implemented as a simple program?

I am trying to understanding the concept of special files on Linux. However, having a special file in /dev seems plain silly when its function could be implemented by a handful of lines in C to my ...
99
votes
4answers
111k views

Where do executables look for shared objects at runtime?

I understand how to define include shared objects at linking/compile time. However, I still wonder how do executables look for the shared object (*.so libraries) at execution time. For instance, my ...
84
votes
7answers
134k views

What is /usr/local/bin?

Before today, I've used the terminal to a limited extent of moving in and out of directories and changing the dates of files using the touch command. I had realised the full extent of the terminal ...
84
votes
1answer
9k views

Why does the following script delete itself?

If you create an executable file with the following contents, and run it, it will delete itself. How does this work? #!/bin/rm
83
votes
4answers
265k views

Why do we use “./” to execute a file?

Why do we use ./filename to execute a file in linux? Why not just enter it like other commands gcc, ls etc...
82
votes
5answers
61k views

Does the shebang determine the shell which runs the script?

This may be a silly question, but I ask it still. If I have declared a shebang #!/bin/bash in the beginning of my_shell_script.sh, so do I always have to invoke this script using bash [my@comp]$...
70
votes
2answers
48k views

Getting “Not found” message when running a 32-bit binary on a 64-bit system

I have currently a strange problem on debian (wheezy/amd64). I have created a chroot to install a server (i can't give any more detail about it, sorry). Let's call its path /chr_path/. To make things ...
68
votes
8answers
188k views

#!/bin/bash - no such file or directory

I've created a bash script but when I try to execute it, I get #!/bin/bash no such file or directory I need to run the command: bash script.sh for it to work. How can I fix this?
64
votes
8answers
54k views

Can a script be executable but not readable?

Is it possible to execute a script if there is no permission to read it? In root mode, I made a script and I want the other user to execute this script but not read it. I did chmod to forbid read and ...
61
votes
2answers
37k views

Where should a local executable be placed?

I have an executable for the perforce version control client (p4). I can't place it in /opt/local because I don't have root privileges. Is there a standard location where it needs to be placed under $...
57
votes
8answers
9k views

Why does Bash's source not need the execution bit?

With Bash's source it is possible to execute a script without an execution bit set. This is documented and expected behaviour, but isn't this against the use of an execution bit? I know, that source ...
57
votes
7answers
142k views

How to find out the dynamic libraries executables loads when run?

I want to find out the list of dynamic libraries a binary loads when run (With their full paths). I am using CentOS 6.0. How to do this?
55
votes
2answers
15k views

Why and how are some shared libraries runnable, as though they are executables?

On 32-bit Linux systems, invoking this $ /lib/libc.so.6 and on 64-bit systems this $ /lib/x86_64-linux-gnu/libc.so.6 in a shell, provides an output like this: GNU C Library stable release version ...
52
votes
2answers
16k views

Shebang line with `#!/usr/bin/env command --argument` fails on Linux

I've got a simple script: #!/usr/bin/env ruby --verbose # script.rb puts "hi" On my OSX box, it runs fine: osx% ./script.rb hi However, on my linux box, it throws an error linux% ./script.rb /usr/...
51
votes
6answers
185k views

chroot: failed to run command ‘/bin/bash’: No such file or directory

When I run the chroot command an error is given: failed to run command ‘/bin/bash’: No such file or directory
48
votes
8answers
61k views

Can we get compiler information from an elf binary?

Is there some chance to know how a binary was built, under Linux? (and or other Unix) Compiler, version, time, flags etc... I looked at readelf and couldn't find much, but there might be other ways ...
44
votes
8answers
71k views

Different ways to execute a shell script

There a several ways to execute a script, the ones I know are: /path/to/script # using the path (absolute or relative) . script # using the . (dot) source script # using the `source` command ...
41
votes
4answers
26k views

What is the difference between running “bash script.sh” and “./script.sh”?

If script.sh is just something typical like #!/bin/bash echo "Hello World!" Is there a preferred way to run the script? I think you first have to chmod it so it becomes executable?
40
votes
4answers
21k views

What makes OSX programs not runnable on Linux?

I know there are many differences between OSX and Linux, but what makes them so totally different, that makes them fundamentally incompatible?
39
votes
5answers
34k views

How to recursively remove execute permissions from files without touching folders?

I made a backup to an NTFS drive, and well, this backup really proved necessary. However, the NTFS drive messed up permissions. I'd like to restore them to normal w/o manually fixing each and every ...
39
votes
1answer
26k views

Loading of shared libraries and RAM usage

I'm wondering about the way Linux manages shared libraries. (actually I'm talking about Maemo Fremantle, a Debian-based distro released in 2009 running on 256MB RAM). Let's assume we have two ...
38
votes
4answers
12k views

What is the min and max values of exit codes in Linux?

What is the min and max values of the following exit codes in Linux: The exit code returned from a binary executable (for example: a C program). The exit code returned from a bash script (when ...
37
votes
5answers
26k views

How to test whether a Linux binary was compiled as position independent code?

I recently learned that (at least on Fedora and Red Hat Enterprise Linux), executable programs that are compiled as Position Independent Executables (PIE) receive stronger address space randomization (...
37
votes
4answers
135k views

Viewing Linux Library / Executable version info

In Windows, EXE and DLL have version info, including at least the following fields: file version product version internal name product name copyright In Linux Library / Executable: Which fields ...
37
votes
1answer
49k views

What are stripped and not-stripped executables in Unix?

From man file, EXAMPLES $ file file.c file /dev/{wd0a,hda} file.c: C program text file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses ...
36
votes
4answers
15k views

How to recover from a chmod -R 000 /bin?

And now I am unable to chmod it back.. or use any of my other system programs. Luckily this is on a VM I've been toying with, but is there any way to resolve this? The system is Ubuntu Server 12.10. ...
36
votes
3answers
64k views

How to convert a shell script into a binary executable?

I want to convert my shell scripts into binary executable so that nobody else could edit or read it. Is there a way to convert it into a binary executable?
34
votes
5answers
22k views

How can I use environment variables in my shebang?

I have a Python script that need to be run with a particular python installation. Is there a way to craft a shebang so that it runs with $FOO/bar/MyCustomPython?
33
votes
5answers
1k views

Execution of possibly harmful program on Linux

I'm writing a program that will test programs written by students. I'm afraid that I can't trust them and I need to make sure that it won't end up badly for the computer running it. I was thinking ...
32
votes
2answers
4k views

Difference between “command not found” and “no such file or directory”?

For example: $ node -bash: /usr/local/bin/node: No such file or directory $ foo -bash: foo: command not found What's the difference? In both cases, node and foo are invalid commands, but it seems ...
29
votes
7answers
14k views

List all binaries from $PATH

Is there one-liner that will list all executables from $PATH in bash.
29
votes
1answer
6k views

What is Linux doing differently that allows me to remove/replace files where Windows would complain the file is currently in use?

The example I have is Minecraft. When running Bukkit on Linux I can remove or update the .jar files in the /plugins folder and simply run the 'reload' command. In Windows, I have to take the whole ...
27
votes
2answers
112k views

sudo: unable to execute ./script.sh: no such file or directory

I'm stumped. I have a script in my /home directory which is executable: [user@server ~]$ ll total 4 -rwx------ 1 user user 2608 Jul 15 18:23 qa.sh However, when I attempt to run it with sudo it says ...
26
votes
11answers
7k views

Execute as .test rather than ./test

Supposing I am in the same folder as an executable file, I would need to type this to execute it: ./file I would rather not have to type /, because / is difficult for me to type. Is there an easier ...
26
votes
5answers
19k views

Binary compatibility between Mac OS X and Linux

Brace yourselves, this question will likely appear naive and/or foolish, seeing as I am relatively new to the inner workings of unix like systems, and programming in general. Ready? Ok! I will go ...
26
votes
2answers
4k views

Why can't root execute when executable bits are not set?

root user can write to a file even if its write permissions are not set. root user can read a file even if its read permissions are not set. root user can cd into a directory even if its execute ...
24
votes
4answers
4k views

Why updating a running Linux system is not problematic?

It's years I use Linux systems on a daily basis, and I never had major problems by updating a system when it was running, but I still wonder why this is possibile. Let me make an example. Suppose a ...
23
votes
6answers
9k views

The way to use `/usr/bin/env sed -f ` in shebang?

Typing /usr/bin/env sed -f in terminal works. But if use it as a shebang, #!/usr/bin/env sed -f s/a/b/ The script will be fail to execute: /usr/bin/env: sed -f: No such file or directory I kind ...
23
votes
1answer
10k views

What does “LSB” mean when referring to executable files in the output of /bin/file?

I have found the term "LSB executable" or "LSB shared object" in the output of the file command in Linux. For example: $ file /bin/ls /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), ...
23
votes
1answer
1k views

How does Linux determine what facilities to use to run a (non-text) binary?

I understand that Linux uses shebang line to determine what interpreter to use for scripting languages, but how does it work for binaries? I mean I can run Linux binaries, and having installed both ...
23
votes
1answer
4k views

How to trick a particular command into thinking it is a different date?

How can I execute a command making it believe that is on a different date than system one? For instance, if I have this script: #!/usr/bin/env bash date +"%B %d, %Y" It prints the actual date: ...
21
votes
2answers
46k views

Why does sshd requires an absolute path?

Why does sshd require an absolute path when restarting, e.g /usr/sbin/sshd rather than sshd Are there any security implications? P.S the error message: # sshd sshd re-exec requires execution with ...
21
votes
1answer
984 views

How did the ~/.local/bin thing start? How widespread is it?

I find more and more tools that put executables into ~/.local/bin. I am old and for me ~/bin is the place in my $HOME for executables. Where did this crazy new fashion originate? Why are people doing ...
20
votes
4answers
2k views

What is a valid use case for an “execute only” file permission?

I was reading up on chmod and its octal modes. I saw that 1 is execute only. What is a valid use case for an execute only permission? To execute a file, one typically would want read and execute ...
19
votes
2answers
5k views

How are system commands like ls created?

I have some doubts regarding *nix. I don't know which type of executable file is ls, whether it is .sh or .ksh or any other kind of system executable if it is, what is that? when I tried to see what ...
18
votes
1answer
2k views

Why does the file command say that ELF binaries are for Linux 2.6.9?

Whenever I run file on an ELF binary I get this output: [jonescb@localhost ~]$ file a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (...
17
votes
3answers
29k views

Running sh script: «Permission denied» despite the executable bit and root rights

I installed Debian in VirtualBox (for various experiments which usually broke my system) and tried to launch the VirtualBox guest addon script. I logged in as root and tried to launch autorun.sh, but ...