Clear all containers and images in docker

If you want to clear all containers and all images from docker
there is a set of commands you can run to do that .
Note that this will delete the containers and images with no way of recover.
Delete All Containers :

docker rm $(docker ps -a -q)

Delete All images :

docker rmi $(docker images -q)

Learn Python

I had a good “administrator” life with Bash and pearl , but I came to see the power of python .
learning python is very easy , all you needs to do is replace any script you are about to write in bash with python .
Yes I know its easier to just write it in Bash , but believe me after a very short period of time it would feel as if you have no need for Bash
of course python can do much more then just scripts , but one step at a time 🙂

Gnome 3 power button shutdown

If you work with the new gnome 3 as your desktop you probably noticed
that clicking the power button doesn’t shut the computer , in my case it just restart it .
in order to set the power of there is a small tweak to be made :
open dconf-editor and navigate to :  org -> gnome -> settingsdaemon -> plugins ->power

change power-button from none to shutdown
now when you press power button , the system will shut it self down

Redirect to www in php

Here is a simple way to redirect any hit to www using php .
and also keep the protocol ( http/https )

	header('Location:' . "http://www.$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ,true, 301);
	header('Location:' . "https://www.$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ,true, 301);

install cx_Oracle on CentOS 7

Here is a simple way to install cx_Oracle on CentOS 7
in order to install , we will use Oracle instant client , and python pip

1. Download and install oracle client from Oracle

yum install libaio
rpm -Uvh oracle-instantclient12.1-basic-
rpm -Uvh oracle-instantclient12.1-devel-
rpm -Uvh oracle-instantclient12.1-sqlplus-

2. Add Oracle client to library path

echo "/usr/lib/oracle/12.1/client64/lib" >/etc/

3. install epel repo via yum extra

yum install epel-release

4. Install additional

yum install gcc python-pip.noarch python-devel

5. Install  cx_Oracle via pip

pip install cx_Oracle


symetric gpg encryption

Symetric encryption is an encryption that uses same key to decrypt.
here is a way to encrypt file with symetric key without user interact ( batch )

gpg --batch -q --passphrase '<password>' --cipher-algo AES256 -c <file>

Create TAP/TUN device CentOS 7

Here is how to do it on CentOS 7 / RedHat 7 where the command  tunctl is missing
and when you try to run ifconfig you get an error

~# ifconfig tap0
SIOCSIFADDR: No such device
tap0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device

to solve this you may run this commands
1. first we must create the device using ip command

# ip tuntap add tap0 mode tap

2. run ifconfig

~# ifconfig tap0
~# ifconfig tap0
tap0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet netmask broadcast
ether 32:f5:3a:44:a5:64 txqueuelen 500 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Bash Special Variables

Bash shell has some built in variables that can be use in scripts
for example if you want to know the process id of the current command , you may use $$
here is a list of some special variables

$# Number of command-line arguments.
$_ The underscore variable is set at shell startup and contains the absolute file name of the shell or script being executed as passed in the argument list. Subsequently, it expands to the last argument to the previous command, after expansion. It is also set to the full pathname of each command executed and placed in the environment exported to that command. When checking mail, this parameter holds the name of the mail file.
$- A hyphen expands to the current option flags as specified upon invocation, by the set built-in command, or those set by the shell itself (such as the -i).
$? Exit value of last executed command.
$ Process number of the shell.
$! Process number of last background command.
$0 First word; that is, the command name. This will have the full pathname if it was found via a PATH search.
$n Individual arguments on command line (positional parameters). The Bourne shell allows only nine parameters to be referenced directly (n = 1–9); Bash allows n to be greater than 9 if specified as ${n}.
$*, [email protected] All arguments on command line ($1 $2 …).
“$*” All arguments on command line as one string (“$1 $2…”). The values are separated by the first character in $IFS.
[email protected] All arguments on command line, individually quoted (“$1” “$2” …).

simple install sun java

a quick and eazy way to install java under linux
1. download jre or jdk from
2. create a directory to hold the versions

# mkdir /usr/java

3. extract the tar file under the directory

# tar -xzvf jre-7u45-linux-x64.tar.gz -C /usr/java
# ln -s /usr/java/jre1.7.0_45 /usr/java/jre-latest

4. the last part is to create links in the system in order to
make sure it uses this new java version we just extracted .
* global java command
debian linux based version:

# update-alternatives --install /usr/bin/java java /usr/java/jre-latest/bin/java 90
# update-alternatives --config java

RedHat linux based version :

# alternatives --install /usr/bin/java java /usr/java/jre-latest/bin/java 90
alternatives --config java

browsers links

ln -s /usr/java/jre-latest/lib/amd64/ <path to install dir>/plugins/

bash history security

Bash history can reviel what a person commands where .
but what if the person wants to hide his tracks , he may use the


will couse bash to delete the history upon logout .
there is how ever a harden attribute you may set to overcome this problem
when a user login , there are set of files/scripts the profile runs .
one place you may put such script would be under /etc/profile.d/ , with file extension sh
as it is being called by /etc/profile .
just place this small line in there :

readonly HISTFILE

now when a person wants to unset this parameter , bash will scream with this error

-su: unset: HISTFILE: cannot unset: readonly variable