Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create UNIX / Linux commands? [closed]

Tags:

c

linux

unix

I'm looking to create my own Unix/ Linux commands using C programming. Say for example .. I wrote simple file copy program, I'd like to make it as a Unix/ Linux command.

How do I do it ?

like image 242
user1027046 Avatar asked Feb 23 '23 12:02

user1027046


2 Answers

Any executable file placed in a directory that is in the PATH (shell) variable will be a Unix command.

like image 107
Vatine Avatar answered Feb 25 '23 01:02

Vatine


  1. Write your code using stdin, stdout and stderr in order to allow executing it from the command line and pipe its output
  2. Parse command line arguments and use them (if you need)
  3. Compile the binary
  4. Locate in any directory in the PATH (e.g. /usr/sbin)
like image 44
eyalm Avatar answered Feb 25 '23 01:02

eyalm