Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable. This tutorial will walk you through both steps and show you how to create your own command in Linux.
How to create a Bash Script?
To create a bash script, enter the following code:
#!/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 by pressing CTRL + O with Nano. Give it the name of your command.
How to make the command executable?
If you try to type the name of your bash script, you will notice that it will be executed (run).
Now, you have to modify the CHMOD of the script that you will run by typing:
chmod +x yourScript
Now, copy your script in the path, /usr/bin, like below:
cp yourscript /usr/bin/
You're all done! Run your command by typing the script name, which you moved to /usr/bin.
- Search in Vim editor: Linux, for words
- How to compile assembly code: in Linux, Windows, with NASM
- Ubuntu remove password: for sudo, for user, for root
- How to disable avahi-daemon: Linux, Ubuntu
- Debian change language: to English, command
- Change password Linux: script, terminal, Samba
- Debian add printer: command line, install cups
- Linux read file line by line: for loop
- Vim autocomplete: C++, command
- How to resize partition Linux: Gparted, command line
- Linux display file in reverse order
- How to recover lost admin password in CUPS?
- How to uninstall package: in Linux
- How to remove the content of a directory: Linux
- Adding space in mount point: to FSTAB
- How to convert DOS to UNIX: Linux, command
- How to split a file in Linux: split, merge
- How to install htop Linux: Ubtunu, Mint
- Restart network interface: Linux, Ubuntu
- Restoring Linux: from backup, using Tar
- Customize Wine on Linux: download, install, locate theme
- What is a Daemon: in Linux
- Delete lines in Linux: SED, commands