Systems administrators commonly use the command line to complete various tasks on a server. Many times we run a string of commands at once, or want a specific variable included automatically. In Linux, we can create an alias, which is a command that runs a set string of commands and variables. I’m going to list a few of my favorite ones, and why I like them:
- alias ssh=’ssh -A’This alias automatically adds ssh key agent forwarding when I type ssh. It’s a good way to avoid forgetting to add agent forwarding. Agent forwarding allows me to continue using my ssh key instead of a password.
- alias root=’ssh -A -lroot’This alias is the same as the one above but includes using root as the user I try to login as. This make a a quick login as root always ready in case I need to change a system file on a remote server.
- alias sshx=’ssh -X -A’This alias is the same as the first one, but has the added benefit of turning on X11 forwarding, so I can run GUI applications on the remote server, but have the window appear on my local workstation. This requires some extra setup on your local system (For Macs you just need to install the free XQaurtz tool) This is very handy if you want to configure a remote server application but it requires using a GUI tool to do so.
- alias mdate=’date +%m%d%G%H%M’mdate adds the proper variables to the date command to produce an output in the DDMMYYYYHHmm format. You can use mdate as part of a backup script to append the current date/time to a file.
Ex: mysqldump -u root –password=yaysecurepassword database > database_
- alias publicip=’curl ifconfig.me’This alias displays the public IP of the server you are on. That would be the IP address your server appears to be coming from if it were to visit a website for example. It could be useful for scripting, or just as a quick way to find out what IP you are using if you manage many servers.
I hope these are useful to you, but if you have others you like to use, share them with me in the comments section!
Matthew Ahrenstein has joined Pixafy’s staff and will be supporting Chris Deneen on the DevOps team. His background’s ecletcic, and his knowledge set makes him a great addition to the team. Here, he tackles Pixafy’s version of a welcome wagon: the dreaded Pixafy interview questions.
Q: Tell us a little bit about yourself.
Originally I’m from East Islip, N.Y., but I moved out to Shoreham when I was 10. I’m currently living with my parents. My father is a Cat Scan Technologist, and my mother is a Registered Nurse. My brother is in school to become a lawyer (not law school yet) and my sister is following the same path, but is 4 years behind (she’s 4 years younger than my brother). I’m in a relationship for 2 years come November, and I have a Terrier-Poodle mix named Shadow. He’s 12 now, but still acts like a puppy. (more…)