The Wayback Machine - https://web.archive.org/web/20240118182339/https://www.geeksforgeeks.org/doexec-command-in-linux-with-examples/
Open In App
Related Articles

doexec command in Linux with examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

doexec command in the Linux system is used to run an executable with an arbitrary argv[0]. It allows the user to argv[0] other than the name of the executable, which is by default passed.

Syntax:

doexec /path/to/executable argv[0] [argv[1-n]]

Options:

The argv list is used to send all options to the program being executed.

Example:

The following is a C program that is executed using the doexec command.

C




#include<stdio.h>
  
int main(int argc, char* argv[]){
    printf("The following is the list of the command-line arguments passed:\n");
    for(int i=0;i<argc;i++)
        printf("%d -> %s\n",i,argv[i]);
    return 0;
}


Using the following lines of codes we compile and run the executable.

gcc test.c -o test
doexec ./test "This is argv[0]"

Output:

The following is the list of the command-line arguments passed:

0 -> This is argv[0]

 

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 02 Jun, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials