Derniers articles

Catégories

Bash Jquery Linux php PluXml Proxy Raspberry Pi ssh Tools Tunnel Unix


bash_aliases

12 octobre 2012

Lister les alias actifs: alias
Désactiver tout les alias: unalias -a
Désactiver un alias particulier: unalias aliasname

Voici une petite collection d'alias bien pratique:


### Very usefull
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias cdh='cd ~'

alias lt='ls -lhart --color=auto'
alias ll='ls -lF --color=auto'
alias la='ls -alF --color=auto'
alias ls='ls -F'

alias psgb="ps -aux | grep bash"
alias psx="ps -auxw | grep $1"

alias svi='sudo vim'
alias snan='sudo nano'

alias scr='screen -R -D'

alias hcl='history -c; clear'

#Make mount command output pretty and human readable format
alias mount='mount |column -t'

#Show open ports
alias ports='netstat -tulanp'

# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
	alias reboot='sudo reboot'
	alias poweroff='sudo poweroff'
	alias halt='sudo /sbin/halt'
	alias shutdown='sudo /sbin/shutdown'
fi

## get meminfo ## 
alias meminfo='free -m -l -t'
 
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
 
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'

### Debian apt
alias aptu='sudo apt-get update'
alias aptua='sudo apt-get update && sudo apt-get upgrade'
alias apti='sudo apt-get install'
alias aptr='sudo apt-get remove'
alias apts='apt-cache search'

## shortcut  for iptables and pass it via sudo#
# display all rules #
alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers'
alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers'
alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers'
alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers'
alias firewall=iptlist

###   Handy Extract Program
extract () {
   ee() { # echo and execute
       echo "$@"
       $1 "$2"
   }
   for x in "$@"; do
       [[ -f $x ]] || continue
       case "$x" in
           *.tar.bz2 | *.tgz )    	ee "tar xvjf" "$x"    ;;
           *.tar.gz | *.tbz2 )    	ee "tar xvzf" "$x"    ;;
           *.bz2 )                	ee "bunzip2" "$x"     ;;
           *.rar )                	ee "unrar x" "$x"     ;;
           *.gz )                 	ee "gunzip" "$x"      ;;
           *.tar )                	ee "tar xvf" "$x"     ;;
           *.zip )                	ee "unzip" "$x"       ;;
           *.Z )                  	ee "uncompress" "$x"  ;;
           *.7z )                 	ee "7z x" "$x"        ;;
       esac
   done
}

### This piece of code lists the size of every file and subdirectory of the current directory,
### much like du -sch ./* except the output is sorted by size, 
###with larger files and directories at the end of the list. 
###Useful to find where all that space goes. 
dusa ()
{
   du -a --max-depth=1 | sort -n | awk '{
               sub("./","",$2);
               size=$1;
               $1="";
               unit="K";
               if (size >= 1024)
               {
                       size = size /1024;
                       unit="M";
               }
               if (size >= 1024)
               {
                       size = size /1024;
                       unit="G";
               }
               printf "%6.1f%s %s\n",  size, unit, $0;
       }'
}

#export
export HISTFILESIZE=5000              # Larger history
export CLICOLOR=1                     # Use colors (if possible)
export LSCOLORS=ExGxFxdxCxDxDxBxBxExEx 

Classé dans : Accueil, Unix - Mots clés : Unix, Linux, Bash

1 commentaire

vendredi 17 avril 2015 @ 14:52 peau a dit : #1

Cet article est d'une grande qualité, je voulais vous remercier pour vos efforts.

Écrire un commentaire

Quelle est la dernière lettre du mot vsxwul ? : 

Derniers articles

Catégories

Archives