Hard to find but downloading java from a script (not openjdk in the repos) is not something I found easily.
So here is page with the links:
http://java.com/en/download/manual.jsp?locale=en
nJoy 😉
Hard to find but downloading java from a script (not openjdk in the repos) is not something I found easily.
So here is page with the links:
http://java.com/en/download/manual.jsp?locale=en
nJoy 😉
One of the benefits of using Ubuntu OS is it comes with build-in security/safety/privacy feature. One of this feature is a keyring manager application that stores and manage your password for your credentials. This feature is really useful to keep your credentials safe and no one can unlock them, except you of course, even if your Ubuntu-powered machine (laptop, netbook, etc) got stolen.
(more…)
A common problem when many people share large systems as the same user ( I know .. I know but anyways move on ) Â is that when you logon you might want to take over where someone else left off. Also sometimes you want to share a session with someone for supervision or just team experience.
Screen tool in linux is fantastic for this. I wrote this script to allow people to be reminded to have a screen session and if already there allow you to log on to the screen by either taking over the session or sharing it with the other user.
installation of screen is as easy as :
sudo yum install screen -y
or for you debbie penguins out there
sudo apt-get install screen -y
The script goes like this :
## Screen profile for user session sharing
## by David Saliba (copyleft) 2013
#!/bin/bash
function greet {
clear
cat /etc/motd
echo "Hostname:" `hostname `
echo
ifconfig | grep inet | egrep -v "inet6|localhost|127\.0\.0\.1"
echo
# df -h /
echo "Welcome ! # No screen session #"
}
function newscreen {
echo "Would you like to create a new session ? (Y/n)"
read -t 10 b
if [[ $b == "N" || $b == "n" ]]; then
{ # Dummy if no just continue
echo
}
else
{
echo " Remember to use <CTRL> + A and then d to leave the screen session active or just disconnect "
echo -n "Creating "
sleep 1; echo -n "." ;sleep 1; echo -n "."; sleep 1; echo -n "."
exec screen -S Workarea
}
fi
}
if [ -z "$STY" ]; then
firstscreen=$(screen -list | grep "(" | cut -f 2 | head -n 1)
# echo $firstscreen
if [ ! -z "$firstscreen" ]; then
{
echo "Found screen ($firstscreen).Do you want to jump on it (Y), or share the session (X)? (Default Y in 10s)"
read -t 10 a
if [[ $a == "N" || $a == "n" ]]; then
{
greet
}
elif [[ $a == "X" || $a == "x" ]]; then
{
echo -n "Joining "
sleep 1; echo -n "." ;sleep 1; echo -n ".";
exec screen -x $firstscreen
}
else
{
echo -n "Connecting and taking over"
sleep 1; echo -n "." ;sleep 1; echo -n ".";
exec screen -r -d $firstscreen
}
fi
}
else
{
greet str3amuK
newscreen
}
fi
fi
Save this script under /etc/profile.d/screen.sh or some other name you will recognize.
SHOW GRANTS; SHOW GRANTS FOR CURRENT_USER; SHOW GRANTS FOR CURRENT_USER(); e.g. SHOW GRANTS FOR root;
mysql> SHOW grants for root;
+———————————————————————————-+
| Grants for root@% |
+———————————————————————————-+
| GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY PASSWORD ‘*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B’ WITH GRANT OPTION |
+———————————————————————————-+
1 row in set (0.00 sec)
mysql>
nJoy 😉
Really easy :
git diff > patchfile.pch
and
patch -p1 < patchfile.pch
nJoy 😉
How do I use bash while loop to repeat certain task under Linux / UNIX operating system? How do I set infinite loops using while statement? The bash while loop is a control flow statement that allows code or commands to be executed repeatedly based on a given condition. For example, run echo command 5 times or read text file line by line or evaluate the options passed on the command line for a script.
The syntax is as follows:
while [ condition ] do command1 command2 command3 done
command1 to command3 will be executed repeatedly till condition is true. The argument for a while loop can be any boolean expression. Infinite loops occur when the conditional never evaluates to false. For example following while loop will print welcome 5 times on screen:
#!/bin/bash x=1 while [ $x -le 5 ] do echo "Welcome $x times" x=$(( $x + 1 )) done
Here is a sample shell code to calculate factorial using while loop:
#!/bin/bash counter=$1 factorial=1 while [ $counter -gt 0 ] do factorial=$(( $factorial * $counter )) counter=$(( $counter - 1 )) done echo $factorial
To run just type: $ chmod +x script.sh $ ./script.sh 5 Output:
120
While loops are frequently used for reading data line by line from file:
#!/bin/bash FILE=$1 # read $FILE using the file descriptors exec 3<&0 exec 0<$FILE while read line do # use $line variable to process line echo $line done exec 0<&3
You can easily evaluate the options passed on the command line for a script using while loop:
......
..
while getopts ae:f:hd:s:qx: option
do
case "${option}"
in
a) ALARM="TRUE";;
e) ADMIN=${OPTARG};;
d) DOMAIN=${OPTARG};;
f) SERVERFILE=$OPTARG;;
s) WHOIS_SERVER=$OPTARG;;
q) QUIET="TRUE";;
x) WARNDAYS=$OPTARG;;
\?) usage
exit 1;;
esac
done
.......
..
Infinite for while can be created with empty expressions, such as:
#!/bin/bash while : do echo "infinite loops [ hit CTRL+C to stop]" done
You can do early exit with the break statement inside the whil loop. You can exit from within a WHILE using break. General break statement inside the while loop is as follows:
while [ condition ] do statements1 #Executed as long as condition is true and/or, up to a disaster-condition if any. statements2 if (disaster-condition) then break #Abandon the while lopp. fi statements3 #While good and, no disaster-condition. done
In this example, the break statement will skip the while loop when user enters -1, otherwise it will keep adding two numbers:
#!/bin/bash while : do read -p "Enter two numnbers ( - 1 to quit ) : " a b if [ $a -eq -1 ] then break fi ans=$(( a + b )) echo $ans done
To resume the next iteration of the enclosing WHILE loop use the continue statement as follows:
while [ condition ] do statements1 #Executed as long as condition is true and/or, up to a disaster-condition if any. statements2 if (condition) then continue #Go to next iteration of I in the loop and skip statements3 fi statements3 done
|
Using the Job Control of bash to send the process into the background:
|
nJoy! 😉
Simply do this:
SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = 'dbname' AND TABLE_NAME = 'tabname'
nJoy ;-)
Simple and easy :
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
nJoy 😉
Google Chrome is an alternative web browser beside Mozilla Firefox. It’s free and open source. But the problem Google Chrome on Backtrack 5 is Google Chrome can’t run in root mode. We know that Backtrack run the root mode by default. If you run the Google Chrome it won’t work. So if you want to install and run Google Chrome in root this is the tutorial.
apt-get install chromium-browser
Access the Chrome directory
cd /usr/lib/chromium-browser
And here we go, open chromium-browser with hexaedit to edit the hexa code of chromium-browser
hexedit chromium-browser