How to create custom commands in Unix/Linux?

  • Can anyone guide me to create custom commands in Unix/Linux.

    For future reference, you should check out the facts page. It explains the things you should put in your questions. (such as posting the things that you have researched & tried). That's likely why someone gave this question a down vote.

  • Eric

    Eric Correct answer

    7 years ago

    Create a bash script in your /usr/bin folder, it should look something like this

    #!/bin/bash
    Whatever combination of commands you want to run when you type this thing.
    

    Its really that easy.

    Just name the bash script what you want to type in to the terminal, and make it excecutable: chmod +x filename and you're good to go!

    Could you modify this to be a step-by-step guide, including every necessary step? I am still unsure how to make my own custom command.

    @AndersMB, you need to **read a book**. There are many good ones, even available for free. Start with "The Linux Command Line".

    Umm.. he was joking. He _was_ joking, right?!

    execute with `./filename`

    /usr/bin folder is intended for the Linux distributor. ~/bin is the right place to put personal stuff and /usr/local/bin is for custom software intended for everyone on the system to use. One would like to keep a degree of logical separation / easy navigation over their own files.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM