scripts linux

.bash_aliases

set -o vi

# This is I think original PS1
## PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$'

# This PS1 prints HOSTNAME in window /h and VERSION /v
PS1='\[\e]0;\u@\v: \h: cmd# \#: /pts/\l : Time \t: \w\a\]${debian_chroot:+($debian_chroot)}\u@\$:\#:\w\$ '

# This PS1 prints USER /u \$ and then VERSION \v
PS1='\[\e]0;\u@\$: \v: cmd# \#: /pts/\l : Time \t: \w\a\]${debian_chroot:+($debian_chroot)}\u@\$:\#:\w\$ '

alias c=clear
alias d=date
alias e=exit
alias m='less -i'

alias ll='\ls -alrtF --color=auto'
alias llA='\ls -Alrt --color=auto'
alias llF='\ls -alF --color=auto'
alias dird='\ls -alrt --color=auto | grep ^d' alias vmplayer='cd /home//Hadoop/cloudera-quickstart-vm-5.4.2-0-vmware; vmplayer cloudera-quickstart-vm-5.4.2-0-vmware.vmx; cd -; ' # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then     PATH="$HOME/bin:$PATH" fi . ${HOME}/bin/.chk_bin ${HOME}/GURU/script export LPDEST='' echo -e "Print ----- lpr -P /usr/share/cups/data/testprint -----\n\n     LPDEST ----- lpstat -----\n\n\n" . .Mongo; echo -e "WRA Mongo WRA\t\t:hll2320d:\n\n\n\n\n"

echo -e "\n\nbramsohan\n/BabuRsohan11 www. https://educatefwd.wordpress.com/\n\n"

echo -e "\n\nrakesh.khandwaha@gmail.com  \n\nhttp://www.educatingforward.com/  --  BramSohan11 \n( 9417689364 )"

sh bin/dig_ipaddress.sh

dig_ipaddress.sh

#!/bin/sh +xv

echo "\n`date`\ndig +short myip.opendns.com @resolver1.opendns.com\n"
dig +short myip.opendns.com @resolver1.opendns.com

echo "\n`date`\ndig TXT +short o-o.myaddr.l.google.com @ns1.google.com\n"
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com


date
echo -n "\n\nPlease press Return"
read Return
date


sleep 3

.gshut

# shutdown
# shutdown -help
# shutdown -h
# shutdown --help
# shutdown -H
# shutdown -H +1 Shutting down now
# shutdown now
# man shutdown
# shutdown -h now
# man shutdown
# sudo shutdown -r now
# sudo shutdown now
# sudo shutdown -r now
# shutdown -r now
# sudo shutdown -r now
# shutdown -now
# shutdown -help
# sudo shutdown -r now
# sudo - shutdown now
# sudo -u root shutdown now

# use this last shutdown as -P means POWEROFF

echo "Please choose an option:"
echo "1) shutdown --help"
echo "2) sudo -u root shutdown -r now"
echo "3) sudo -u root shutdown -P now"

read opt
echo "opt :" $opt ":"
sleep 7

case ${opt} in
1*)
 shutdown --help
 ## sudo -u root shutdown --help
 ;;
2*)
 sudo -u root shutdown -r now
 ;;
3*)
 sudo -u root shutdown -P now
 ;;
4*)
 echo "4)"
 ;;
5*)
 echo "5)"
 ;;
*)
 echo "Hey Enjoy your day :)"
 ;;
esac

# read
# This was the Original command which was changed to options
# sudo -u root shutdown -P now

ll_files

#!/bin/bash -v

DT=`date +%Y%m%d`
echo ${DT}


umask 0222
ls -altr > files_on_${DT}

sort -k9 files_on_20* | less -i

chk_swap

#/bin/bash

OFILE=/tmp/delete_swap_results

echo "Started writing \n @ `date`" > ${OFILE}

echo "OFILE = ${OFILE}"
date
ls -alrt ${OFILE}



# func1 {
# while true
# do
#     ls -alrt /tmp/delete_swap_results
#     echo -e "\n\n"
#     sleep 7
# done
# }



while true
do

##    date
    VAL=`free -m | grep Swap | cut -c21-32`
##    echo `free -m | grep Swap | cut -c21-32 `
##    echo "VAL=${VAL}\n\n"

    if [ ${VAL} -ne 0 ]
        then

        echo "${VAL} is NOT EQUAL to 0" >> ${OFILE}

        echo "\n\n"
        ls -alrt ${OFILE}

        date >> ${OFILE}
        free -m >> ${OFILE}
        echo -e "\n\n" >> ${OFILE}

    fi

#     func1

    sleep 5

done

.chk_bin

# This file checks the contents of the $HOME/bin directory
# displays all the local executables and
# Also files which are not executables(ordinary files)

echo -e "\n\n`pwd`\n"
# DIR=${HOME}/GURU/bin
# echo "DIR=\$HOME/GURU/bin = <${DIR}>"

DIR=$1
echo "DIR=\$1 = <${DIR}>"

if [ -z "$1" ]
then
    DIR=`pwd`
fi


echo "DIR=. = <${DIR}>" 

echo -e "\n`pwd`\n"

cd ${DIR}




ls -AF1 ${DIR}

echo -e "\nDirectories"; ls -AF1 ${DIR} | grep '\/$'

echo -e "\nFiles"; ls -AF1 ${DIR} | grep '[^@*/]$'

echo -e "\nExecutable Files"; ls -AF1 ${DIR} | grep '\*$'

echo -e "\nSymbolic Link"; ls -AF1 ${DIR} | grep '@$'


cd -

.bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
 *i*) ;;
 *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
 debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
 xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'


    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

.bash_logout

# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
    [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

Directory structure of Files in ~/GURU/

~USER/:~/USER/GURU$ 
.:
total 28
-rw-rw-r-- 1 USER USER  220 Apr 14 12:55 .bash_logout
-rw-rw-r-- 1 USER USER 3659 Apr 14 12:56 .bashrc
drwxrwxr-x 3 USER USER 4096 Apr 14 13:03 ../
-rw-rw-r-- 2 USER USER 1275 Apr 14 13:25 .bash_aliases
drwxrwxr-x 2 USER USER 4096 Apr 14 13:26 bin/
drwxrwxr-x 2 USER USER 4096 Apr 14 13:27 script/
drwxrwxr-x 4 USER USER 4096 Apr 14 13:34 ./

./bin:
total 32
-rwxrwxr-x  1 USER USER  618 Apr 14 12:56 .chk_bin*
-rwxrwxr-x  1 USER USER  939 Apr 14 12:56 .gshut*
-rwxr-xr-x  1 USER USER  168 Apr 20 15:36 delete_media.sh*
drwxrwxrwx 13 USER USER 4096 Apr 21 18:16 ../
drwxrwxr-x  3 USER USER 4096 Apr 21 22:25 .GAMES/
lrwxrwxrwx  1 USER USER   50 Apr 22 12:51 xonotic-linux-glx.sh -> /home/USER/bin/.GAMES/Xonotic/xonotic-linux-glx.sh*
lrwxrwxrwx  1 USER USER   50 Apr 22 12:51 xonotic-linux-sdl.sh -> /home/USER/bin/.GAMES/Xonotic/xonotic-linux-sdl.sh*
-rw-r--r--  1 USER USER 1017 Apr 23 13:47 del_media_dir.sh
-rwxrwxr-x  1 USER USER  181 Apr 23 13:50 show_passwords*

./script:
total 16
-rwxrwxr-x 1 USER USER  671 Apr 14 12:56 chk_swap*
-rwxrwxr-x 1 USER USER  117 Apr 14 12:57 ll_files*
drwxrwxr-x 2 USER USER 4096 Apr 14 13:27 ./
drwxrwxr-x 4 USER USER 4096 Apr 14 13:34 ../

~/.bash_aliases

cat > ~/.bash_aliases

/etc/sysctl.conf # for swappiness of system default=60, change to 10
/etc/sysctl.conf
sudo nano /etc/sysctl.conf

#

# This is added by Gurdyal Singh to control SWAPPINESS #cat /proc/sys/vm/swappiness
# Decrease swap usage to a more reasonable level #for RAM less than 2GB it should be 10or5
vm.swappiness=10
sudo nufw enable/disable/status/reload # Enable Firewall

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s