SSH and aliases

I’ve had one heck of a week at work. I was given a fresh server and was told to install PHP, mysql, GIT, and everything on it that’s required for my application so my app could function and be secure. I had to do this via SSH. One thing that I’m not very good at. Thank god I am surrounded by guys who rock at it and have more SSH experience than me. One thing I quickly learned: Aliases are freakin’ awesome.

Some SSH commands are long and hard to remember. Commands like going to the sites-available folder can be a pain. Why not make it simple? With aliases, you can. You can easily set temporary aliases that last per the session by just calling aliases command:

$ alias apa='cd /etc/apache2/sites-available'

The code above means that whenever apa is typed, you are sent to the sites-available folder. A list of commonly used aliases can be found at How to Geek. I have a couple for ones that I do a lot. View the laravel log, go to my master folder so I can run GIT, etc.

Now what if you want an alias to be permanent? You need to edit the .bashrc file. So run…

$ sudo nano ~/.bashrc

There’s an area where you can add aliases. Then to activate the aliases, run:

$ source ~/.bashrc

…or just log out and log back in. 🙂

Happy coding people!

Leave a Reply

Your email address will not be published. Required fields are marked *