Once you add your aliases save the file, which in the nano editor is done by pressing the Сtrl-x keyboard shortcut, answering “y” when asked to save, and hitting enter. Bashrc just open it in a command line text editor such as nano, or any other you might prefer, and add the same exact alias command as in the above example at the bottom of it, or find where other aliases are already set and add yours after them. You can edit whichever you prefer, or whichever exists on your system. Bash_profile residing in your user home directory. If you want to save aliases permanently you will have to edit the bash configuration file, which is usually. One thing to keep in mind though is that aliases that are set this way get lost the moment you close the command line session, or in other words, they are temporary. Now the accesslog alias no longer exists. What if I want to unset the alias once I no longer need it or wish to set a new better alias? Well, simply run: unalias accesslog Now instead of having to write the whole tail -f command every time I want to look at what’s happening in the access.log file I can simply run the accesslog alias command instead, which is pretty nifty. What it does is follow the access.log file and display new entries in it as they happen. In this example I’ve effectively created a new accesslog command which is an alias of the tail -f /var/log/lighttpd/access.log command. Here’s a simple example: alias accesslog='tail -f /var/log/lighttpd/access.log' Replace the “name” with your shortcut command, and “command you want to run” with the larger command you want to create an alias of. It will then act as a shortcut to the larger command, which you can type and run instead.Ĭreating aliases in UNIX (and Linux) is done with a simple alias command which follows this format: alias name='command you want to run' When you want to save yourself from typing an unwieldy command over and over again you can create and use an alias for it. ![]()
0 Comments
Leave a Reply. |
AuthorTiffany ArchivesCategories |