
Here are the ideas on how to create custom command in Linux using ‘alias’
One of the best examples is you need to go to a directory and display the contents in the order of edit made. To achieve this you need to issue two commands. Instead of using two commands you can complete this with a single command.
1. How to create Custom Command
I want to go to my home directory and list the components inside of it.
>$ cd (home_dir)
>Srini lsdm
test1
test2
test3
Here, I used two commands. One is ‘cd‘ and another one is ‘lsdm’.
The command you need to create custom command is ‘alias‘
2. How to Use Alias
>$ alias name=’string’
Let me create a new command
>$ alias foo='cd (home_dir); lsdm'
Now new command is created with ‘foo’.
>$ foo
>$srini
test1
test2
test3
3. How to Verify the Actual Commands Behind Your Custom Command
Use ‘type’ command to verify.
>$type foo
foo is aliased to 'cd (home_dir); lsdm'
How to nullify alias-command. The command is ‘unalias’
>$ unalias foo
Now the ‘alias-command’ foo is no longer present. So the ‘foo’ command is not available now.
How to search for the files and content in the Files
Locate – it will search the pathname of similar to what you entered in any directory.
Find – you can find a particular string in a group of directories.
Related Posts
You must be logged in to post a comment.