Last active
August 29, 2015 14:02
-
-
Save mv/2549eefe19f26c83a34c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat > /etc/profile.d/aliases.sh <<'EOF' | |
#!/bin/bash | |
# | |
# /etc/profile.d/aliases.sh | |
# | |
alias ls='ls -hAF --color=auto --time-style=long-iso' | |
alias ll='ls -l' | |
alias la='ls -a' | |
alias lr='ls -ltr' | |
alias cp='cp -i' | |
alias mv='mv -i' | |
alias rm='rm -i' | |
alias ds='ds -h' | |
alias df='df -h' | |
alias cd..='cd ..' | |
alias ..='cd ..' | |
alias grep='egrep --color' | |
### vertical list | |
alias path='IFS=: echo path: ; for f in $PATH ; do echo " $f"; done' | |
alias ldpath='IFS=: echo ldpath: ; for f in $LD_LIBRARY_PATH ; do echo " $f"; done' | |
alias manpath='IFS=: echo manpath: ; for f in $MANPATH ; do echo " $f"; done' | |
### count of files/dirs | |
alias kountf='for f in *; do printf "%40s %9d\n" $f `find $f -type f | wc -l`; done' | |
alias kountd='for f in *; do printf "%40s %9d\n" $f `find $f -type d | wc -l`; done' | |
### size of files/dirs | |
alias sizef='find . -type f | xargs du -h | sort -hr | head' | |
alias sized='find . -type d | xargs du -h | sort -hr | uniq | head' | |
### environment | |
alias env='env | sort' | |
alias envg='env | sort | grep -i' | |
alias setg='set | sort | grep -i' | |
### system | |
alias susu='sudo su -' | |
[ -f /var/log/messages ] && alias syslog="tail -F /var/log/messages" | |
[ -f /var/log/syslog ] && alias syslog="tail -F /var/log/syslog" | |
[ -f /var/log/system.log ] && alias syslog="tail -F /var/log/system.log" | |
# alias psg='ps -ef | grep -v grep | grep ' | |
# alias netl='netstat -lanp | grep ' | |
function psg() { | |
if [ -z "$1" ] | |
then | |
ps -ef | more | |
else | |
ps -ef | head -1 | |
ps -ef | grep -v grep | egrep -i --color "$1" | |
fi | |
} | |
function awkpid() { | |
# usage: psg httpd | grep www | awkpid | xargs kill | |
awk '!/^UID/ {print $2}' | |
} | |
function xkill() { | |
# usage: psg httpd | grep www | awkpid | xkill | |
xargs kill | |
} | |
function netl() { | |
if [ "$UID" == "0" ] | |
then cmd="netstat -lanp" # root | |
else cmd="netstat -lan" # users | |
fi | |
if [ -z "$1" ] | |
then | |
$cmd | head -2 | tail -1 && \ | |
$cmd | grep tcp | grep -i listen | more | |
else | |
$cmd | head -2 | tail -1 && \ | |
$cmd | egrep -i --color "$1" | |
fi | |
} | |
alias fstab='cat /etc/fstab | column -t' | |
alias mtab='cat /etc/mtab | column -t' | |
function mount() { | |
if [ -z "$1" ] | |
then /bin/mount | column -t | |
else /bin/mount $@ | |
fi | |
} | |
function mkcd { | |
mkdir -p "$1" && cd "$1" | |
} | |
### ip | |
alias myip='curl --max-time 7 -s http://whatismyip.akamai.com/ ; echo' | |
#lias myip='curl --max-time 5 -s http://checkrealip.com/ | grep "Current IP Address"' | |
alias myif='echo $ ip addr list ; ip addr list | grep inet | sort' | |
alias myrt='echo $ nestat -rn ; netstat -rn ; echo ; echo $ ip route list ; ip route list' | |
alias myfw='echo $ iptables -L ; iptables -L' | |
### pkgs | |
if which rpm &>/dev/null | |
then | |
alias rpmg='rpm -qa | sort | grep -i' | |
alias rpml='rpm -ql' | |
alias rpm_info='rpm -qi' | |
alias rpm_list='rpm -qa | sort' | |
alias rpm_count='rpm -qa | wc -l' | |
alias rpm_provides='rpm -q --provides' | |
alias rpm_requires='rpm -q --requires' | |
alias yumg='yum list | grep -i' | |
alias yumr='yum repolist all' | |
function yum_repo_reset() { | |
if [ -z "$1" ] | |
then echo 'yum_repo_reset repo-name' | |
else | |
if [ -d /var/cache/yum/*/*/${1} ] | |
then /bin/rm -rf /var/cache/yum/*/*/${1} && yum repolist all | |
fi | |
fi | |
} | |
function r2c { | |
if [ -z "$1" ] | |
then echo 'r2c: rpm2cpio' | |
else rpm2cpio "$1" | cpio -idmv | |
fi | |
} | |
fi | |
if which dpkg &>/dev/null | |
then | |
alias dpkgg="dpkg -l | egrep '^ii' | grep -i" | |
fi | |
### puppet | |
function pp { | |
if [ -z "$1" ] | |
then puppet --version | |
else puppet apply -e "include $1" $@ | |
fi | |
} | |
# vim:ft=sh: | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment