Here is a list of useful aliases used by the ANAT Tech department. Please feel free to use these as appropriate :
alias aRestart='sudo apache2ctl -k restart'
alias acs='apt-cache search'
alias agg='sudo apt-get upgrade'
alias agi='sudo apt-get install'
alias agr='sudo apt-get remove'
alias agu='sudo apt-get update'
alias apt='sudo apt-get install'
alias aliasd='nano ~/.bash_aliases'
alias alogs='sudo tail -f /var/log/apache2/access_logs/*_log /var/log/apache2/error_logs/*_log'
alias bashrc='nano ~/.bashrc'
alias cdetca='cd /etc/apache2/sites-available'
alias cdwww='cd /var/www/'
alias chownWWW='sudo chown -Rc www-data:www-data * .htaccess'
alias da='du -hsc *'
alias dir='ls --color=auto --format=vertical'
alias directoryExec='sudo find * -type d -exec chmod -c ug+x {} \;'
alias ds='du -hsc * | sort -n'
alias egrep='egrep --color=auto'
alias eximQ='sudo exim -bp'
alias eximRemove='exim -Mrm'
alias eximRouting='exim -bt'
alias eximStats='eximstats -nr /var/log/exim4/mainlog'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A --color=auto'
alias ldir='ls -l | egrep '\''^d'\'''
alias lf='ls -l | egrep -v '\''^d'\'''
alias ll='ls -Alsch --color=auto'
alias load='uptime'
alias logs='find /var/log/ -name "*.log" -type f -exec tail -f {} +'
alias logsudo='sudo find /var/log/ -name "*.log" -type f -exec sudo tail -f {} +'
alias ls='ls --color=auto'
alias maillog='tail -n 50 -f /var/log/exim4/mainlog /var/log/exim4/rejectlog'
alias mailstats='eximstats /var/log/exim4/mainlog'
alias mem='free -m'
alias netstats='sudo netstat -tulpn'
alias openz='gzip -d -c'
alias rm='rm -v'
alias rma='rm -Rv'
alias vdir='ls --color=auto --format=long' |
alias aRestart='sudo apache2ctl -k restart'
alias acs='apt-cache search'
alias agg='sudo apt-get upgrade'
alias agi='sudo apt-get install'
alias agr='sudo apt-get remove'
alias agu='sudo apt-get update'
alias apt='sudo apt-get install'
alias aliasd='nano ~/.bash_aliases'
alias alogs='sudo tail -f /var/log/apache2/access_logs/*_log /var/log/apache2/error_logs/*_log'
alias bashrc='nano ~/.bashrc'
alias cdetca='cd /etc/apache2/sites-available'
alias cdwww='cd /var/www/'
alias chownWWW='sudo chown -Rc www-data:www-data * .htaccess'
alias da='du -hsc *'
alias dir='ls --color=auto --format=vertical'
alias directoryExec='sudo find * -type d -exec chmod -c ug+x {} \;'
alias ds='du -hsc * | sort -n'
alias egrep='egrep --color=auto'
alias eximQ='sudo exim -bp'
alias eximRemove='exim -Mrm'
alias eximRouting='exim -bt'
alias eximStats='eximstats -nr /var/log/exim4/mainlog'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A --color=auto'
alias ldir='ls -l | egrep '\''^d'\'''
alias lf='ls -l | egrep -v '\''^d'\'''
alias ll='ls -Alsch --color=auto'
alias load='uptime'
alias logs='find /var/log/ -name "*.log" -type f -exec tail -f {} +'
alias logsudo='sudo find /var/log/ -name "*.log" -type f -exec sudo tail -f {} +'
alias ls='ls --color=auto'
alias maillog='tail -n 50 -f /var/log/exim4/mainlog /var/log/exim4/rejectlog'
alias mailstats='eximstats /var/log/exim4/mainlog'
alias mem='free -m'
alias netstats='sudo netstat -tulpn'
alias openz='gzip -d -c'
alias rm='rm -v'
alias rma='rm -Rv'
alias vdir='ls --color=auto --format=long'
Note: We have removed some aliases for security reasons.
Assumption : You are using Ubuntu on a web server. The aliases we have listed are mainly used on a standard LAMP (Linux Apache, MySQL, PHP) server using Ubuntu. Some commands are useful on other distros, whilst the apt-get and anything with specific directories might not be appropriate. Also, on some hosts apache is called httpd.
Explanation of some interesting aliases
aRestart : Just a quick way of restarting the Apache web server. This does a graceful restart so it won’t kick off any existing connections, although if someones downloading a large file (that will hopefully be restartable in any decent file downloader), then you can try the more forceful command /etc/init.d/apache2 restart.
acs : ‘apt-cache search’ This is Debian/Ubuntu specific and will do a search for packages (programs). Usually it can be a little too verbose and you might have to pipe the output to grep to find what you want e.g acs php | grep php
agi : This will run apt-get install for the package you want. I usually run it with ‘-s‘ first to simulate the install and see what it will actually do. e.g agi -s php5
aliasd : This is what you’ll likely use to edit your existing alias’s. Note the install install instructions.
chownWWW : This is great to use when you are migrating various files into an apache hosted directory, but be careful! This is run as root and is very powerful. You certainly don’t want to run it in the / root folder or something bad. Usually you’ll run it in the /var/www/ or ~/public_html/ folders depending on how your server is configured.
da : I use this a LOT for when trying to work out where my disk space is going. An alternative is to install ncdu (n-curses disk usage)
logs : This is a great way of tailing all the logs in the /var/log/ directory and seeing whenever they get appended to. Mainly used for checking apache logs or getting some more info about what your server is or isn’t doing. Note, this only gets the files which end in .log as I couldn’t get it to ignore gzip files by their type and there’s no point tailing compressed, log rotated logs.
directoryExec : This is used to add executable permissions to all subdirectories so you can actually view them. That is, in order for a user to be able to view the contents of a directory they need executable permissions on that directory. As with the chownWWW command this is a powerful, recursive command and should only be used when needed.
An older version of the directoryExec script is below for reference purposes.
alias directoryExec='for directory in "$( sudo find * -type d )"
do
sudo chmod -c ug+x $directory
done' |
alias directoryExec='for directory in "$( sudo find * -type d )"
do
sudo chmod -c ug+x $directory
done'
eximQ : This is an easy to remember shortcut if you use the exim4 email server. It’ll show the queue of emails waiting to be processed.
ll : I use this ALL the time to view a listing of files. I basically can’t use a terminal prompt without this as it gives lots of useful information. You can remove the h (so it’ll be ls -Alsc) if you don’t want it human readable, as it can sometimes be a little easier to find the larger files without h.
netstats : As per http://www.cyberciti.biz/faq/what-process-has-open-linux-port/ this shows which ports are open and which programs are opening them.
Got any more? Let us know of any useful aliases you’ve developed or found!