Now most of that aliasing can be configured in sudoers instead, so it wont matter what shell you use.
Believe me, I am no shell expert, I use and study the zshell, (because I've been using it for soo long) because of some shell function, mostly date and time, user name and pwd (present working directory) in colour(!) a la knoppix live distribution.
anyway, now with out being a bash guru,
I should be able to set my system up to do most of the day to day admin stuff
with sudo, instead of shell alias's.
the old and new files look like this.
3 files, ~/.zshrc, the new /etc/sudoers file and the old /etc/sudoers file.
the new /etc/sudoers file,
[code]
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.
## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias FILESERVERS = fs1, fs2
# Host_Alias MAILSERVERS = smtp, smtp2
## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem
## Command Aliases
## These are groups of related commands...
## Networking
# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
## Installation and management of software
# Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
## Services
# Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
## Updating the locate database
# Cmnd_Alias LOCATE = /usr/bin/updatedb
## Storage
# Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount
## Delegating permissions
# Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp
## Processes
# Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall
## Drivers#
Cmnd_Alias DRIVERS = /sbin/modprobe
# Defaults specification
#
# Disable "ssh hostname sudo
# You have to run "ssh -t hostname sudo
#
Defaults requiretty
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
## user MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
## Allows members of the users group to mount and unmount the
## cdrom as root
%users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
## Allows members of the users group to shutdown this system
%users localhost=/sbin/shutdown -h now
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
[/code]
the old style /etc/sudoers file,
[code]
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification
# Runas alias specification
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
%wheel ALL=(ALL) ALL
# Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
# Samples
%users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
%users localhost=/sbin/shutdown -h now
[/code]
zshrc,
[code]
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000000
SAVEHIST=600000
setopt appendhistory beep extendedglob nomatch notify
#bindkey -v #set below
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/glenn/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
#
# .zshrc file for zsh 4.0
#
# .zshrc is sourced in interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
# Set a colour prompt # home by wilsontc modified and adopted 1st-oct2008 GlennsPref
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOR="%{$terminfo[sgr0]%}"
if [ `whoami` = 'root' ]; then
PS1="$PR_RED%n$PR_NO_COLOR@$PR_BLUE%m%u$PR_NO_COLOR:$PR_CYAN%2c$PR_NO_COLOR%(!.#.$) "
else
PS1="$PR_GREEN%n$PR_NO_COLOR@$PR_BLUE%m%u$PR_NO_COLOR:$PR_CYAN%2c$PR_NO_COLOR%(!.#.$) "
fi
# Put a clock on the right hand prompt
RPS1="$PR_CYAN(%D{%d-%m %H:%M})$PR_NO_COLOR"
# Search path for the cd command
cdpath=(.. ~ ~/src ~/zsh)
# Use hard limits, except for a smaller stack and no core dumps
unlimit
limit stack 8192
limit core 0
limit -s
# Set up aliases # to get root access via sudo instead of "access denied"
alias su='su -p'
alias man='sudo man'
alias cat='sudo cat'
alias locate='sudo locate'
alias lsusb -v='sudo lsusb -v'
alias lsusb='sudo lsusb'
alias lsmod='sudo lsmod'
alias lspci -v='sudo lspci -v'
alias lspci='sudo lspci'
alias fw-reset='sudo fw-reset'
alias service='sudo service'
alias netstat='sudo netstat -anu'
alias fslint='sudo /usr/bin/fslint-gui'
alias organise-rpms= 'sh ~/build/rpms/organise-rpms'
alias gen-hdlist2= 'sh ~/build/rpms/gen-hdlist2'
alias smart='sudo smart'
alias ifup='sudo ifup'
alias ifdown='sudo ifdown'
alias ifconfig='sudo ifconfig'
alias updatedb='sudo updatedb'
alias rpm='sudo rpm'
alias urpmi.update='sudo urpmi.update'
alias urpmi='sudo urpmi --noclean'
alias urpme='sudo urpme'
alias mv='nocorrect mv' # no spelling correction on mv
alias cp='nocorrect cp' # no spelling correction on cp
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
#alias j=jobs
#alias pu=pushd
#alias po=popd
#alias d='dirs -v'
#alias h=history
alias ll='ls -l'
alias la='ls -a'
alias top='htop'
alias mount='sudo mount'
alias umount='sudo umount'
alias mbmon='sudo mbmon'
alias make='sudo make'
# List only directories and symbolic
# links that point to directories
alias lsd='ls -ld *(-/DN)'
# List only file beginning with "."
alias lsa='ls -ld .*'
# Shell functions
setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" } # csh compatibility
freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
# Where to look for autoloaded function definitions
fpath=($fpath ~/.zfunc)
# Autoload all shell functions from all directories in $fpath (following
# symlinks) that have the executable bit on (the executable bit is not
# necessary, but gives you an easy way to stop the autoloading of a
# particular shell function). $fpath should not be empty for this to work.
for func in $^fpath/*(N-.x:t); autoload $func
# automatically remove duplicates from these arrays
typeset -U path cdpath fpath manpath
manpath=($X11HOME/man /usr/man /usr/lang/man /usr/local/man)
export MANPATH
# Hosts to use for completion (see later zstyle)
hosts=(`hostname` ftp.math.gatech.edu prep.ai.mit.edu wuarchive.wustl.edu)
# Some environment variables
export MAIL=/var/spool/mail/$USERNAME
export LESS=-cex3M
export HELPDIR=/usr/local/lib/zsh/help # directory for run-help function to find docs
#oops, I created this, sudo man zshbuiltins | col -bx | perl /usr/share/zsh/4.3.10/Utils/helpfiles GW. (broken 24/11/2010)
#export PATH=$PATH:$HOME/bin #$PATH:$HOME/build/rpms
export PATH=/usr/local/bin:.:/home/glenn/bin:/home/glenn/build:/home/glenn/build/rpms:/usr/X11R6/bin/:/usr/games:/usr/bin:/bin:/usr/lib/qt4/bin
#HISTSIZE=90000
DIRSTACKSIZE=30
# Watch for my friends
#watch=( $(<~/.friends) ) # watch for people in .friends file
#y
watch=(notme) # watch for everybody but me
LOGCHECK=300 # check every 5 min for login/logout activity
WATCHFMT='%n %a %l from %m at %t.'
# Set/unset shell options
#setopt notify globdots correct pushdtohome cdablevars autolist
#setopt appendhistory beep extendedglob nomatch notify
setopt correctall autocd recexact longlistjobs
setopt autoresume histignoredups pushdsilent noclobber
setopt autopushd pushdminus extendedglob rcquotes
unsetopt bgnice autoparamslash
# Autoload zsh modules when they are referenced
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -ap zsh/mapfile mapfile
bindkey -v # vi key bindings
# bindkey -e # emacs key bindings
bindkey ' ' magic-space # also do history expansion on space
bindkey '^I' complete-word # complete on tab, leave expansion to _expand
# Setup new style completion system. To see examples of the old style (compctl
# based) programmable completion, check Misc/compctl-examples in the zsh
# distribution.
#autoload -U compinit # repeated above, removed for test 24/11/2010
#compinit # repeated above, removed for test 24/11/2010
# Completion Styles
# Enabling Caching
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
# allow one error for every three characters typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
# insert all expansions for expand completer
zstyle ':completion:*:expand:*' all-expansions tag-order
# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' parameters tag-order indexes
# command for process lists, the local web server details and host completion
zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
zstyle '*' hosts $hosts
# Filename suffixes to ignore during completion (except after rm command)
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
'*?.old' '*?.pro'
# the same for old style completion
fignore=(.o .c~ .old .pro)
# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
[/code]
Not sure if you can see it, but I see a whole lot of aliases I don't need anymore and they work on bash too.
I'm due to review my zsh aliases and sudo configuration files.
cheers for now.
Regards Glenn