Create your own Linux command
IT Tricks Random

Create your own Linux command

#Create #Linux #command

It is possible to give a new name to the commands that are frequently used in Linux or that are difficult to memorize. Thus, they end up becoming their own commands. This feature, called Alias, allows you to create nicknames for commands. Here’s how to do that below.

The feature of creating your own Linux command is used to create codenames for the most frequently used commands. Thus, it is possible to facilitate the execution of multiple tasks.

1. Creating the bash script

Initially, you need to create your Bash script, which will be executed at the time of your command.

For example:


#afixa-se o nome da pasta atual
echo "A pasta atual é 'pwd'"

#depois a lista dos arquivos
echo "Os arquivos contidos nesta pasta são 'ls'"

Then, register this file (CTRL + O with Nano) and give it the name of your command (for example, infopasta)

2. Make the command executable

If you try to enter the name of your Bash script, you should realize that it cannot be executed yet.

Start by modifying the CHMOD of the script so that you can run it as you type

chmod +x votreScript

Now, copy your script into your directory / usr / bin in this way:

cp votreScript /usr/bin/

Ready! Now, to launch your command, type in the console the name of the script you moved to the / usr / bin.

Photo: © Arian Darvishi – Unsplash

Leave a Reply

Your email address will not be published. Required fields are marked *