BASH 54
Bashrc - Commands By micha on 12th October 2021 09:00:26 AM
  1. status() {
  2.  echo -e "\n\e[33mMachine System:\e[0m" ; lsb_release -d
  3.  echo -e "\n\e[33mMachine information:\e[0m" ; uname -a
  4.  echo -e "\n\e[33mUsers logged on:\e[0m" ; w -h
  5.  echo -e "\n\e[33mCurrent date:\e[0m" ; date
  6.  echo -e "\n\e[33mMachine status:\e[0m" ; uptime
  7.  echo -e "\n\e[33mMemory status:\e[0m" ; free -m
  8.  echo -e "\n\e[33mFilesystem status:\e[0m"; df -h
  9. }
  10.  
  11. extract ()
  12. {
  13.  if [ -f $1 ] ; then
  14.  case $1 in
  15.  *.tar.bz2) tar xjf $1 ;;
  16.  *.tar.gz) tar xzf $1 ;;
  17.  *.bz2) bunzip2 $1 ;;
  18.  *.rar) rar x $1 ;;
  19.  *.gz) gunzip $1 ;;
  20.  *.tar) tar xf $1 ;;
  21.  *.tbz2) tar xjf $1 ;;
  22.  *.tgz) tar xzf $1 ;;
  23.  *.zip) unzip $1 ;;
  24.  *.Z) uncompress $1;;
  25.  *.7z) 7z x $1 ;;
  26.  *) echo "'$1' cannot be extracted via ex()" ;;
  27.  esac
  28.  else
  29.  echo "'$1' is not a valid file"
  30.  fi
  31. }
  32.  
  33. netinfo ()
  34. {
  35. echo "--------------- Network Information ---------------"
  36. /sbin/ifconfig | awk /'inet addr/ {print $2}'
  37. /sbin/ifconfig | awk /'Bcast/ {print $3}'
  38. /sbin/ifconfig | awk /'inet addr/ {print $4}'
  39. /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
  40. myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `
  41. echo "${myip}"
  42. echo "---------------------------------------------------"
  43. }
  44.  
  45. #dirsize - finds directory sizes and lists them for the current directory
  46. dirsize ()
  47. {
  48. du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
  49. egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
  50. egrep '^ *[0-9.]*M' /tmp/list
  51. egrep '^ *[0-9.]*G' /tmp/list
  52. rm -rf /tmp/list
  53. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.