Great sysadmins use aliases to avoid repeatedly typing common commands. Everybody knows lazy sysadmins are the best ones.
The Commands:
alias a='cat ~/.bash_aliases'
alias ea='vi ~/.bash_aliases; echo "Refreshing aliases"; source ~/.bash_aliases'
Here’s what they do:
- the command ‘a’ now prints out a list of your current aliases
- the command ‘ea’ brings up vi to edit your aliases and refreshes them when you’re done
Here’s the work flow:
> ea
... edit edit hack hack
> a
... list of aliases ...
Where to put it:
Using Linux: ~/.bash_aliases. This file gets read when you log in.
If you are using a Mac do this. In ~/.bash_profile add:
source ~/.bash_aliases
Then add everything into that file instead.
Here’s what mine looks like (well a part of it):
unalias -a
alias a='cat ~/.bash_aliases'
alias ea='vi ~/.bash_aliases; echo "Refeshing aliases..."; source ~/.bash_aliases'
# back up the day's work
alias bkup='sudo -i /root/backup.sh'
# ubuntu version
alias uver='cat /etc/lsb-release'
# manage apache configs
alias s='sudo vi /etc/apache2/sites-available/combined.conf'
alias sr='sudo /etc/init.d/apache2 reload'
# git short cuts
alias gb='git branch';
alias gs='git status';
alias gl='git log'
alias gsr='git svn rebase';
alias gsd='git svn dcommit';
# misc short cuts
alias ll='ls -l'
alias zf='zf.sh'
alias vi='vim'
Now go do it!
Most good sysadmins already know how to forward a local port to a remote machine and vice versa. However, sometimes it is useful to open a port on the remote machine to the world and have that traffic forwarded through SSH to your local machine.
A practical reason for this is if your web development server is sitting in the wild and you are in your comfy office behind a firewall. Perhaps you just want a wild server to forward a port into a box on your local network without anybody being the wiser. Well here’s how you do it.
- On the Remote Machine make sure this is in sshd_config, GatewayPorts yes
- Restart ssh
- On your local machine create the tunnel with:
ssh -R 8080:localhost:8080 user@remotehost
Now you should be able to access remotehost:8080 and SSH will tunnel the traffic to your local machine.
PS: this could be a potential security problem if you’re not smart.
I get a lot of commercial email trying to sell me technology services. Even though these are commercial emails with an unsubscribe link it is still annoying to have to filter through them and unsubscribe. A simple email hack that works well is to filter all email into a separate folder that is not coming from your top 5 domains.
Looking at my email most of it comes from the same five domains. So any emails not coming from these are automatically moved into a “tier-2″ folder for later sorting. It is a simple hack that works quite well.
As a side note, I actually get quite a bit of spam a day. I have a pair of Barracuda 600 spam firewalls that are very effective at catching 95% of them. The ones that filter through the above hack gets the rest. The one or two that beats the odds only take a few seconds for me to delete anyways.