Setup Unix Profile

cat > ~/.bash_aliases
.profile _orig
.bashrc _orig

In the File ” .bash_aliases ”  add following.

 alias c=clear
 alias e='exit'
 alias m='less -i'
 alias ll='ls -alrtF'
 alias dird='ls -alrt | grep ^d'

 alias shut='sudo shutdown -P now'

After this does not go into .bash_aliases file.

This is just for reference to update/install Linux OS.

dd bs=4M status=progress if=ubuntu-16.04-desktop-amd64.iso of=/dev/sdc1

main@main-desktop:~/Downloads$ pwd
main@main-desktop:~/Downloads$ ll ubuntu-16.04.1-desktop-amd64.iso 
-rw-rw-r-- 1 main main 1513308160 Aug 17 16:48 ubuntu-16.04.1-desktop-amd64.iso
cd ~main/Downloads
sudo dd bs=4M status=progress if=ubuntu-16.04-desktop-amd64.iso of=/dev/sdb 
sudo apt-get install unetbootin
sudo unetbootin
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 -alrt'
alias llA='\ls -Alrt'

alias dird='\ls -alrt| 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

. ${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"

script with admin privileges


# You need to give password for USER <USERNAME>

echo "Please Enter the password for USER `tput smso`<USERNAME>`tput rmso`"

su - <USERNAME> -c "sh bin/"



#!/bin/sh +xv

# set +xv
echo "\n\n\nThis is the Program to remove EXTERNAL HARD DISK DRIVES(e.g. USB, HDD, etc.) :\nProgram is : [`tput smso`{ $0 }`tput rmso`] :\n\n"

# echo $* 
# echo $1

cd /media
echo "Current Directory is : [`tput smso`{ `pwd` }`tput rmso`] :"
# pwd

echo -n "\nExisting files in above Directory are : [`tput smso`{ "
echo -n `ls`
echo " }`tput rmso`] :\n\n\n"

for i in `ls`
echo " `tput smso`{ ${i} }`tput rmso`\n\n"

echo "Do you want to delete `tput smso`${i}`tput rmso`"
read ans

# echo ${ans}
ans=`echo ${ans} | tr [:upper:] [:lower:]`
# echo "ANS ${ans} after proper"
echo "ANS :`tput smso` ${ans}`tput rmso`"

# set -xv

if [ "${ans}" = "y" ]
    echo "\nYes:\nI am going to delete Directory : \t `tput smso`{ /media/${i} }`tput rmso`\n\n\n"

##### Add following lines in /etc/sudoers so "sudo /bin/rmdir functions as intended"
##### <USERNAME> ALL=(ALL) NOPASSWD: /bin/rmdir
    sudo /bin/rmdir /media/${i}

sleep 3

echo "Please press Enter"
read Enter
sleep 11

cd -
# pwd


setup virtualenv python

$ curl -O
$ tar xvfz virtualenv-X.X.tar.gz ( virtualenv-15.1.0.tar.gz )
$ cd virtualenv-X.X
$ python myVE

Setup Virtual Environment

$ python Py_2.7.13

Activate Virtual Environment ( Activate Script )

$ source bin/activate

Deactivate Virtual Environment

$ deactivate

Removing an Environment

$ deactivate
$ rm -r /path/to/ENV

Running the Tests

$ python test

Install Scientific Packages

$ pip install nose pandas numpy scipy pytest

Result of Installing Packages

$ pip install nose pandas numpy scipy pytest
Collecting nose
  Downloading nose-1.3.7-py2-none-any.whl (154kB)
    100% |████████████████████████████████| 163kB 162kB/s 
Collecting pandas
  Downloading pandas-0.20.1-cp27-cp27mu-manylinux1_x86_64.whl (22.3MB)
    100% |████████████████████████████████| 22.3MB 29kB/s 
Collecting numpy
  Downloading numpy-1.12.1-cp27-cp27mu-manylinux1_x86_64.whl (16.5MB)
    100% |████████████████████████████████| 16.5MB 42kB/s 
Collecting scipy
  Downloading scipy-0.19.0-cp27-cp27mu-manylinux1_x86_64.whl (45.0MB)
    100% |████████████████████████████████| 45.0MB 17kB/s 
Collecting pytest
  Downloading pytest-3.1.0-py2.py3-none-any.whl (178kB)
    100% |████████████████████████████████| 184kB 136kB/s 
Collecting pytz>=2011k (from pandas)
  Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
    100% |████████████████████████████████| 491kB 276kB/s 
Collecting python-dateutil (from pandas)
  Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 198kB/s 
Requirement already satisfied: setuptools in ./lib/python2.7/site-packages (from pytest)
Collecting py>=1.4.29 (from pytest)
  Downloading py-1.4.33-py2.py3-none-any.whl (83kB)
    100% |████████████████████████████████| 92kB 309kB/s 
Requirement already satisfied: six>=1.5 in ./lib/python2.7/site-packages (from python-dateutil->pandas)
Requirement already satisfied: appdirs>=1.4.0 in ./lib/python2.7/site-packages (from setuptools->pytest)
Requirement already satisfied: packaging>=16.8 in ./lib/python2.7/site-packages (from setuptools->pytest)
Requirement already satisfied: pyparsing in ./lib/python2.7/site-packages (from packaging>=16.8->setuptools->pytest)
Installing collected packages: nose, pytz, python-dateutil, numpy, pandas, scipy, py, pytest
Successfully installed nose-1.3.7 numpy-1.12.1 pandas-0.20.1 py-1.4.33 pytest-3.1.0 python-dateutil-2.6.0 pytz-2017.2 scipy-0.19.0

Result of pip freeze;  alert

$ pip freeze;  alert

ubuntu xchange /dev/sda with /dev/sdb

I want to change /dev/sda to /dev/sdb and /dev/sdb to /dev/sda .

I used following steps :

sudo hdparm -I /dev/sda | grep -A 2 Model


If anyone’s interested, I created a file called 10-local.rules in /etc/udev/rules.d:

# If the kernel matches a device as sda, change it to sdb.
 KERNEL=="sda", NAME="sdb"
# Vice versa.
 KERNEL=="sdb", NAME="sda"


#Add ID_SERIAL and other variables into the environment
ACTION=="add", KERNEL=="/dev/[sh]d[a-z]", IMPORT{program}="ata_id --export $tempnode"
#Add symlink to hard drive
KERNEL=="/dev/[sh]d[a-z]", ENV{ID_SERIAL}=="WD-WCANU1937055", SYMLINK+="timsdisks/500gb_a"


Reference :
The second possibility is to change UDEV rules. The rules will be processed during system boot, and guarantee you a permanently consistent behavior. A good guide on these rules ca be found here:


adduser, addgroup

#Create Users Group

sudo adduser <USERNAME>
       adduser, addgroup - add a user or group to the system

       adduser [options] [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--firstuid ID] [--lastuid ID] [--ingroup GROUP | --gid
       ID] [--disabled-password] [--disabled-login] [--gecos GECOS] [--add_extra_groups] [--encrypt-home] user

       adduser --system [options] [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--group | --ingroup GROUP | --gid ID] [--dis‐
       abled-password] [--disabled-login] [--gecos GECOS] user

       addgroup [options] [--gid ID] group

       addgroup --system [options] [--gid ID] group

       adduser [options] user group

       [--quiet] [--debug] [--force-badname] [--help|-h] [--version] [--conf FILE]
adduser [options] [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--firstuid ID] [--lastuid ID] [--ingroup GROUP | --gid
       ID] [--disabled-password] [--disabled-login] [--gecos GECOS] [--add_extra_groups] [--encrypt-home] user


Following commands to create, modify <USER> <GROUP>

adduser --debug --gid <GROUP_ID> <USERNAME>
usermod -u <USER_ID> <USERNAME>
usermod -G <GROUP_ID> <USERNAME>

Rename Hard Disk

Rename Hard Disk in Unix

ubuntu@ubuntu:~$ ll /sys/block/sda/device
lrwxrwxrwx 1 root root 0 Feb  4 14:45 /sys/block/sda/device -> ../../../2:0:1:0/
ubuntu@ubuntu:~$ ll /sys/block/sda/device/delete
--w------- 1 root root 4096 Feb  4 14:55 /sys/block/sda/device/delete
ubuntu@ubuntu:~$ ll /sys/block/sdb/device
lrwxrwxrwx 1 root root 0 Feb  4 14:45 /sys/block/sdb/device -> ../../../3:0:1:0/
ubuntu@ubuntu:~$ ll /sys/block/sdb/device/delete
--w------- 1 root root 4096 Feb  4 14:57 /sys/block/sdb/device/delete
sudo -i
echo offline > /sys/block/sda/device/state
echo offline > /sys/block/sdb/device/state


echo 1 > /sys/block/sda/device/delete
echo 1 > /sys/block/sdb/device/delete
scan this hosts hard disks
echo "- - -" > /sys/class/scsi_host/host2/scan   ( /dev/sda for my ref )
echo "- - -" > /sys/class/scsi_host/host3/scan   ( /dev/sdb for my ref )

Reference :