My ~/.bash_aliases 2017

I have a base ~/.bash_aliases file which I normally use Ansible to update on various servers when needed and thought I’d share it.
This is intended for sys admins using Ubuntu.
The main aliases are :
ll – I use this ALL the time, it’s `ls -aslch` and shows the file listing.
agu – Apt get update, just refreshes the apt files from the net, doesn’t actually install anything but should be run before running any apt programs.
agg – Apt Get Upgrade this updates all the programs that need upgrading. Usually the server needs to be restarted after.
acs – Apt Cache Search. If there’s something to install like the PHP gearman extension I’ll usually use `acs php | grep gearman` to work out the name.
a2r – Apache2 reload.
a2rr – Apache2 restart, for when just reloading the config isn’t enough.
aliasd – Open up the local aliases file. Will apply the changes when you exit nano.
aliasd_base – Open up the main (base) aliases file which contains these aliases. If not using Ansible then I normally load the aliases into a new server by pasting the contents of the file in on the command line, then running aliasd_base and pasting it in again into the file.
chownWWW – Change the file and folder contents to being owned by www-data:www-data DO NOT RUN THIS IN THE ROOT DIRECTORY.
du – Directory usage. A general listing of file and directory sizes.
das – A directory size listing ordered by largest at the top. It’s not amazing but works well enough. I use `ncdu` the program (usually has to be installed with `agi ncdu`) to get better directory listing.
directoryExec – Makes the directories executable by the user and group.
logs – Shows most of the /var/log files, tails them so you can see any changes.
logsudo – Same as logs, but with sudo so you see more of the files.
gac – Git add and git commit. A nice quick way of doing a git commit. I usually do `gac -m “* Commit message here”
gitt – Shows the last 24hrs worth of git commits. Great for putting into a timesheet.
gittt – Shows how long ago the commits were, I mainly use this when trying to work out which commits are from today vs yesterday.
ssh-config – Edit the main ssh config file.
diglookup – Does a quick check of the A records, MX, TXT and other stuff for a domain, useful when someone says that there’s an issue with the site. example usage `diglookup kublermdk.com`
Note that the attempt to do a reverse lookup on the IP usually fails if there’s multiple A records for the main site, so you sometimes have to [ctrl] + [c] cancel out of that bit at the end. I’ll fix it one day :P
$ diglookup kublermdk.com
=====================
=== kublermdk.com ===
=====================
Wed Jan 18 11:36:58 ACDT 2017
--- dig kublermdk.com
139.162.46.66

--- dig www.kublermdk.com
kublermdk.com.
139.162.46.66

--- dig kublermdk.com mx
20 aspmx2.googlemail.com.
30 aspmx4.googlemail.com.
30 aspmx3.googlemail.com.
40 aspmx5.googlemail.com.
10 aspmx.l.google.com.
20 alt1.aspmx.l.google.com.

--- dig kublermdk.com txt
"i=221&m=domains-mx2-p11"
"keybase-site-verification=XREU5_ZiKnxXnNBV2L5Jcmn1tfUvL371DsulTNs7s9I"
"google-site-verification=m1fr_lDxzFtXawjhPXV56vbyOzKdw0SyTa1zCrdbArU"

--- dig mail.kublermdk.com
ghs.google.com.
ghs.l.google.com.
172.217.25.179

--- whois kublermdk.com

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

 Domain Name: KUBLERMDK.COM
 Registrar: NETREGISTRY PTY. LTD.
 Sponsoring Registrar IANA ID: 677
 Whois Server: whois.netregistry.net
 Referral URL: http://www.netregistry.com.au
 Name Server: NS0.DNSMADEEASY.COM
 Name Server: NS1.DNSMADEEASY.COM
 Name Server: NS2.DNSMADEEASY.COM
 Name Server: NS3.DNSMADEEASY.COM
 Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
 Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
 Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
 Updated Date: 29-oct-2014
 Creation Date: 06-jul-2007
 Expiration Date: 06-jul-2017

>>> Last update of whois database: Wed, 18 Jan 2017 01:06:49 GMT <<<

For more information on Whois status codes, please visit https://icann.org/epp

[...]

--- Web server's reverse IP 'nslookup 139.162.46.66'

li1459-66.members.linode.com.

Server: 10.0.2.3
Address: 10.0.2.3#53

Non-authoritative answer:
66.46.162.139.in-addr.arpa name = li1459-66.members.linode.com.

Authoritative answers can be found from:

---======---
I then have a ~/.bash_aliases_local file that has server specific changes. e.g kublermdk-logs which will show the logs specific for my site, esp if it’s something like a Symfony project where a lot of the useful log files are stored in something specific. I’d have
alias kublermdk-logs='tail -f /var/logs/apache2/kublermdk/*.log /var/www/kublermdk/www/app/logs/*.log'
Grab what you want, let me know if you’ve got any good aliases yourself.
Cheers!

By Michael Kubler

Photographer, cinematographer, web master/coder.

Leave a comment

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