Create your own command on linux
Creating a Bash script
It’s important to create a Bash script which will run your command.
Let’s see:
#!/bin/bash
#on displays the actual folder name
echo "the folder is `pwd`"
#then the rest of the files
echo "The folder which contains files are `ls`"
Save this file (CTRL + O with Nano) give it the name of your command (Example:
FileInfos)
Turning the command active (Executable)
Try to type the name of your bash script, you will notice that it won’t execute.
Now you have to modify the
CHMOD of the script which you will run by typing:
chmod +x yourScript
Now, copy your script in the path,
/usr/bin like below:
cp yourscript /usr/bin/
Now you are done! Run your command by typing the script name which you moved in
/usr/bin.