1834644 Members
2165 Online
110069 Solutions
New Discussion

Favorite Command Aliases

 
SOLVED
Go to solution
spex
Honored Contributor

Favorite Command Aliases

Hi,

I've seen some excellent threads on favorite sysadmin shell scripts, but haven't seen anything similar for favorite command aliases. Perhaps not as interesting a topic, but one that could prove to be fun and useful. Top points for the best command aliases.

Here are a few of mine:

alias lld='ls -l | grep ^d'
alias lis='tail -f listener.log | sed -f lfilter.sed' # Makes Oracle's listener.log legible
alias locate='zcat /var/opt/locate/loc.db.Z | grep' # loc.db.Z is updated daily
alias logcheck='more ...'
alias ip='/usr/sbin/arp `hostname`'

PCS
13 REPLIES 13
Pete Randall
Outstanding Contributor
Solution

Re: Favorite Command Aliases

Not an alias exactly but we use a little script in /usr/local/bin called psg as a sort of alias for the "ps -ef |grep" command:

##########################################################################
# psg - Process Search
# Substitute for "ps -ef|grep" command string.
##########################################################################
case $# in
0) echo "Error: Argument Expected";
exit;
;;
1) ps -ef | grep $1 | grep -v "grep"
# 1) UNIX95= ps -fC $1
;;
*) echo "Error: Only 1 Argument Allowed";
exit;
;;
esac


Pete

Pete
inventsekar_1
Respected Contributor

Re: Favorite Command Aliases

alias rm='rm -i' is my first preference.
Be Tomorrow, Today.
inventsekar_1
Respected Contributor

Re: Favorite Command Aliases

alias ll='ll -rt'
or
alias lld='ll |grep ^d'
Be Tomorrow, Today.
inventsekar_1
Respected Contributor

Re: Favorite Command Aliases

sorry, in my previous reply
---------------
alias lld='ll
---------------
should be
alias lld='ll -rt|grep ^d'

bdf in mb:
----------
this is actually a script like Pete told, i converted it as an alias:

alias bdfmb = echo "Filesystem Mbytes used avail %used Mounted on" | bdf | grep -v Filesystem | awk '{ printf("%s %10d %10d %10d %4s %s\n",$1,$2/1024,$3/1024,$4/1024,$5,$6)}'

Be Tomorrow, Today.
A. Clay Stephenson
Acclaimed Contributor

Re: Favorite Command Aliases

I actually prefer no aliases at all because regardless of the box I happen to login on, I want the behavior to be the same.
If it ain't broke, I can fix that.
TwoProc
Honored Contributor

Re: Favorite Command Aliases

I've always thoroughly enjoyed the look on the other admin's faces as they see me use the "dog" command so often.

alias dog=cat

It goes quite well with my habit of naming temp/junk files that I'm going to throw away "poop".

It is just so stupid and corny, I've always enjoyed it, and to me (and I'm pretty sure only to me) it's right up there with the warning section of tunefs.
We are the people our parents warned us about --Jimmy Buffett
H.Merijn Brand (procura
Honored Contributor

Re: Favorite Command Aliases

Aliasses also work in (t)csh, which I happen to use.
When using aliasses, the first alias is - of course - 'a'

alais a alias

The second would be 'h

a h history

alias . source
alias > glob "" >
alias a alias
alias cd3 cd /pro/3gl/!*
alias cdp cd /pro/3gl/CPAN/!*
alias dbperl perl -MPROCURA::DBD -e'$d = DBDlogon (1);'
alias for foreach i ( !* )
alias h history
alias j jobs
alias l ls --color=auto -aCF
alias ll ls --color=auto -ali
alias ls ls $LS_OPTIONS
alias man env TERM=vt100 man
alias pg pg -p "Pg %d > " -n
alias sd sccs diffs !*
alias ve sccs edit !*; $VISUAL !*
alias vi elvis -Gx11 -fork

And next to aliasses, there is the complete functionality. Maybe even more powerful than aliasses

complete cd 'p,1,d,'
complete cd3 'p,1,D:/pro/3gl/,'
complete cdp 'p,1,D:/pro/3gl/CPAN/,'
complete ftp 'p,1,`perl -lnae'$F[1]&&$h{$F[1]}++}END{print for sort keys%h' ~/.netrc 'netstat -r|sed s/^/\ /|'`,'
complete path 'n,-e,c,'
complete sccs 'p,2,`sccs tell`,'
complete sd 'p,1,`sccs tell`,'
complete ssh 'p,1,`perl -lnae'$F[1]&&$h{$F[1]}++}END{print for sort keys%h' ~/.netrc 'netstat -r|sed s/^/\ /|'`,'
complete telnet 'p,1,`perl -lnae'$F[1]&&$h{$F[1]}++}END{print for sort keys%h' ~/.netrc 'netstat -r|sed s/^/\ /|'`,'
complete unsetenv 'p,1,e,'

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
spex
Honored Contributor

Re: Favorite Command Aliases

Thanks to everyone who submitted.
Geoff Wild
Honored Contributor

Re: Favorite Command Aliases

I'm with Clay - don't use aliases at all.

What I do like is:

set -o vi

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Doug O'Leary
Honored Contributor

Re: Favorite Command Aliases

Hey;

I generally keep aliases to a minimum as well. I do like to have my environment set up the way I like it though so I generally have my own environment file which I source as soon as I execute /bin/ksh -o vi..

I also have those set as function keys, so when I log into a box, I hit f7 (executes /bin/ksh -o vi) and f8 (sources /root/mcd)

The function keys are set up via a ~/.Xdefaults file:$ cat /home/dkoleary/.Xdefaults
*ttyModes: erase
*VT100.Translations: #override \
F7:string("/bin/ksh -o vi\n")\n\
F8:string(". ./mcd\n")\n\
F9:string("exit\n")\n\
F11:string("check\n")\n\
F12:string("proclog | more\n")\n

I do use functions however. I've included my mcd as an attachment. The two really cool functions are mcd and whenis.

mcd sets the xterm title whenever you cd into a directory. So, the title of my current xterm window says:

dkoleary@usildb13:/usr/bin

whenis displays the current number of days since jan 1 1970. Anyone using the shadow password patch vs trusted systems will understand the need for that. It'll also display the date for any number supplied as a cli arg:

# whenis
13308

# whenis $((13308-45))
04/25/06






------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
Rick Garland
Honored Contributor

Re: Favorite Command Aliases

I avoid aliases. You can get used to many aliases that over time you forget what the actual command is (or was).

And if you work on numerous systems, not all systems will have aliases.
Arturo Galbiati
Esteemed Contributor

Re: Favorite Command Aliases

Hi,
this is my preferred list on HP-UX:

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias m='pg -s -p " Page: %d "'
alias v='vi'
alias erase="cp /dev/null "
alias ll='ls -AFl'
alias lm='ll|m'
# to see file accessed today
alias lla='ll|grep "$(date +%b" "%e)"'
alias lh='ls -AFl|grep " \."|grep -v "^d"|m'
alias lk='ls -AFl|grep "^l"|m'
alias dir='ls -AFl|grep "^d"|m'
alias makex='chmod u+x'
alias env='env|m'
alias flist='typeset +f'
alias catn='cat -n'
alias psme='ps -fu $(whoami)|grep -v $$'

HTH,
Art
MarkSyder
Honored Contributor

Re: Favorite Command Aliases

I like to use aliases for potentially dangerous commands (you've already been given rm="rm -i" and mv="mv -i") but also for frequently used commands where I would like to reduce the amount of typing involved. These include:

tx="tar xvf"
tc="tar cvf"
duk="du -k|sort -k1,1nr|pg"

Mark syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing