Execute the executable file

Explains how to execute the executable file. Think of an executable as just a program. Running an executable file is synonymous with running a program.

Permission settings

To execute an executable file, the file must have execute permission. Executables generated by gcc have execute permission by default.

Let's use the "-l" option of the ls command to see the execute permission of the file. ..

ls -l

Only the executable file "test" has the execution permission "x".

-rwxrwxr-x 1 kimoto kimoto 6702 Dec 14 14:42 test
-rw-r--r-- 1 kimoto kimoto 78 Dec 11 10:52 test.c
-rw-rw-r-- 1 kimoto kimoto 1488 Dec 14 14:37 test.o

As a reference, remember to use the chmod command to grant execute permission.

Execute the executable file

To run the executable, specify the file name and press Enter.

Executable file name

One caveat is that in UNIX / Linux, when executing an executable file in the current directory, add "./" at the beginning. It is necessary to turn it on.

./test

You can also execute an executable file with an absolute path or a relative path.

# Run with absolute path
/ foo / bar / test

#Run with relative path
bar / test

Associated Information