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.

learn more… | top users | synonyms

107
votes
7answers
8k views

How to chmod without /usr/bin/chmod?

Today I was told a tale by a Unix trainer, a tale 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 ...
77
votes
3answers
16k 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 ...
28
votes
8answers
30k views

What is /usr/local/bin? Came across it in an script installation for Applescript but would like to know more

Before today, I've used Terminal to a limited extent of moving in and out of directories, changing the dates of files using the touch command, but had realised the full extent of Terminal after ...
27
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 ...
27
votes
2answers
15k 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 ...
24
votes
4answers
23k 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...
23
votes
1answer
2k 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 ...
22
votes
6answers
9k 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 ...
22
votes
8answers
21k 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 ...
21
votes
4answers
7k 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?
19
votes
2answers
3k 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?
19
votes
3answers
4k 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 ...
19
votes
4answers
1k 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 ...
17
votes
1answer
10k 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 ...
15
votes
4answers
5k 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 ...
15
votes
1answer
647 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: ...
14
votes
2answers
2k views

How are system commands like ls created?

I'm a *nux newbie and 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? ...
14
votes
1answer
1k 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 ...
14
votes
1answer
2k 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 ...
14
votes
1answer
1k 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 ...
13
votes
5answers
9k 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 ...
13
votes
5answers
10k 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?
13
votes
1answer
886 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 ...
11
votes
5answers
5k 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?
10
votes
2answers
874 views

Run a binary owned by root without sudo

I had a question on a job interview: How can you execute (run) the program with the user user1 without sudo privilegies and without access to the root account: $ whoami # user1 $ ls -l ...
10
votes
2answers
346 views

Why do so many programs live in PATH?

One thing that puzzles me about desktop Linux, at least, is that just about everything is in my PATH. By everything, I mean every desktop application, including things like gnome-character-map and ...
10
votes
1answer
9k views

how to convert a shell script into binary executable?

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

Test whether Linux binary is 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 ...
9
votes
3answers
563 views

Is there a way to execute a native binary from a pipe?

echo 'main(){}' | gcc -xc - -o /dev/stdout | ??? Is there a way to run the output binary on a unix-like system? EDIT: I needed it to run the output of g++ in a sandboxed environment where I can't ...
8
votes
3answers
3k 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 ...
8
votes
1answer
3k 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 ...
8
votes
1answer
1k views

How to run my own program without specifying its path

Let's suppose I have compiled something and I run it like so: $ /path/to/my/executable/mycmd Hello World What do I need to do to run it like $ mycmd Hello World from everywhere in my computer? ...
8
votes
3answers
310 views

where to put binaries so they are always in path and can be found easily

I am making quite some binaries, scripts etc that I want to install easily (using my own rpms). Since I want them accessible for everyone, my intuition would be to put them in /usr/bin; no need to ...
8
votes
2answers
4k views

Creating Static Binary

I installed an application [ e.g. fdisk ]. But it required libraries for execution. I am looking for utility/tool which will help me to create a static binary from already installed binaries. So that ...
7
votes
3answers
3k views

If I see a process running using ps, how can I find the executable?

If I can see a process running using ps -e, how can I find the file which launched it?
7
votes
1answer
6k 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 ...
7
votes
2answers
461 views

Detect if an ELF binary was built with gprof instrumentation?

Is it possible to check if given program was compiled with GNU gprof instrumentation, i.e. with '-pg' flag passed to both compiler and linker, without running it to check if it would generate a ...
6
votes
6answers
1k views

How can one run a program installed in one machine from another machine?

Is it possible to have, say, one machine with software installed and call that software from another machine? I thought this would be called an "application server" but by googling I find things that ...
6
votes
3answers
13k 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 ...
6
votes
3answers
8k views

Where do executables look for shared objects at runtime

The title is pretty explicit. 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 ...
6
votes
2answers
242 views

Why there are multiple folders for executable files in Linux? [duplicate]

I'm trying to understand Linux file system, and one of the question is: 1- Why there are multiple folders for executable files: /usr/bin, /usr/sbin/ and /usr/local/bin? Is there any differences ...
6
votes
1answer
457 views

Why do some symbolic links affect program behavior?

One thing that has been puzzling me for some time is this: % which halt /sbin/halt % file /sbin/halt /sbin/halt: symbolic link to `reboot' However, executing sudo halt does, of course, not reboot ...
6
votes
1answer
276 views

Portability of an executable to another Linux machine

I've installed the program Motion on one Linux machine (M1) and want the same program on another (M2). There are various builds of this program, and I have forgotten which one I have used, so can I ...
6
votes
1answer
187 views

Bash executes a different file from the one prompted, even when providing full path

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 ...
6
votes
1answer
502 views

Can capabilities be used in scripts without setcap'ing the interpreter binary?

Right now I'm using cap_net_bind_service MY_USERNAME in /etc/security/capability.conf. Now I just need to set cap_net_bind_service+i on the interpreter of my favouite scripting language to be able to ...
5
votes
1answer
564 views

What determines the path where the system searches for a file?

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 ...
5
votes
1answer
138 views

How would one detect if external command exists in a script?

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 ...
5
votes
3answers
502 views

Why does this executable still execute after I deleted it?

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 ...
5
votes
2answers
151 views

run perl script with unknown perl location

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 ...
5
votes
3answers
2k views

Create a command for a Linux executable file

I'm using a program called node-webkit, but I can't start the program without specifying the full path to the executable file. Is there any way to associate a command (such as node-webkit) with an ...