Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a unix command

Tags:

linux

unix

I have a shell script named remote_execution.sh. Is it possible that I just type remote_execution in any of the folders and the execution starts, just like gcc, vi or any such command does?

Thanks in advance.

like image 804
user650521 Avatar asked Dec 02 '25 05:12

user650521


1 Answers

The following four steps should allow you to run remote_execution from anywhere in your filesystem:

  1. Rename the file to remote_execution, removing the .sh extension
  2. Add a "shebang" line to the top of the file

    #!/bin/bash
    
  3. Modify the permissions of the file so it is executable (see man chmod)

    chmod u+x remote_execution
    
  4. Move the file into a directory in your PATH so it "works in any folder". At a guess:

    mv remote_execution /usr/local/bin
    
like image 88
meagar Avatar answered Dec 03 '25 20:12

meagar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!