How to add command shortcut in Ubuntu shell
When you need to write long commands in Linux shell, like me, you must have been looking for a way (if you haven’t found the way already
) to create shortcuts for those long commands.
Based on your need, you can do any of the following:
alias: If you need a shortcut for only the current shell session, use alias.
- To check current aliases list: alias
- To check an existing alias: alias ALIAS_NAME
- To add new alias: alias COMMAND_SHORTCUT = ‘LONG_COMMAND’ [example: alias apacheReload = '/etc/init.d/apache2 reload''']
- To remove an existing alias: unalias ALIAS_NAME
- Learn more about alias at Wikipedia, Bash Man Page for Alias
Symbolic Links: This is actually my favorite. Does not depend on current shell session. FYI. each command is actually an executable script.
- To create a shortcut for all users, create a soft symbolic link of the executable script in /usr/local/bin. For example, to execute apache related commands using just apache, issue this command
ln -s /etc/init.d/apache2 /usr/local/bin/apache #this command will create a soft symbolic link of apache2 in /usr/local/bin directory. Now you can just manage apache by using apache command. - To create a shortcut only for current user, create a soft symbolic link of the executable script in $HOME/bin
Using your own shell scripts: This requires understanding of shell scripting. You can create a shell script which essentially provide the full ability to create new system commands. Make the script executable, keep it in home directory.
I hope it helps some one. Please use the comment section to provide your feedback.
-
iTekBlog
Tags
apache redirection blogging boot Browser directory print download download limit Download Manager download time limit effective search emacs fedora fedora 9 firefox free stuffs Google internet ISO java latex Linux maverick Media miktext mozilla no-www Open Source os PHP picture Picture of the Day python search search techniques social networking Software sulphur sun jdk thesis writing tips Tips n Tricks ubuntu utility vmware player Windows





