Most useful commands for Linux

* Continuously check Apache error log file:
$ tail -f /var/log/httpd/error_log

* View first 15 lines from MySQL log:
$ head -15 /var/log/mysqld.log

* vi keyboard shortcuts
=> jump to end of line
=> start of line
=> Delete rest of line
=> Repeat the last command given:
. (dot)

=> add ‘maal’ to the end of every line. 1 is line 1, $ is the last line
:1,$ s/$/maal/

=> put ‘bingo’ at the start of lines 5-10
:5,10 s/^/bingo/

=> change foo to bar for all occurrences in the rest of the file from where the cursor is

=> Delete current line and got into insert mode.

=> Remove the ^M from files that came from windows:
:se ff=unix

=> Turn on/off display of line numbers:
:set nu
:set nonu

=> if you want actual line numbers in your file:
:%!cat -n

=> find the word under cursor
* (star)

* screen command
Just type screen and your problems are solved 🙂
$ cat ~/.screenrc
# no annoying audible bell, please
vbell on

# detach on hangup
autodetach on

# don’t display the copyright page
startup_message off

# emulate .logout message
pow_detach_msg “Screen session of $LOGNAME $:cr:$:nl:ended.”

# advertise hardstatus support to $TERMCAP
termcapinfo xterm* ti@:te@

# make the shell in every window a login shell
shell -$SHELL

defscrollback 10000

# Extend the vt100 desciption by some sequences.

termcap vt* AF=E[3%dm:AB=E[4%dm
caption always
caption string ‘%{= wk}[ %{k}%H %{k}][%= %{= wk}%?%-Lw%?%{r}(%{r}%n*%f%t%?(%u)%?%{r})%{k}%?%+Lw%?%?%= %{k}][%{b} %d/%m %{k}%c %{k}]’

# keybindings

bind -k F5 prev
bind -k F6 next

* Display total number of internet (port 80) connections:
$ netstat -an |grep :80 |wc -l

* Display all ports your machine listening on:
$ netstat -ant | grep LISTEN

* Scan a machine on your LAN with nmap and know which ports are open on it:
$ nmap ip

* find top 10 largest files in /var:
$ find /var -type f -ls | sort -k 7 -r -n | head -10

* find all files having size more than 5 GB in /var/log/:
$ find /var/log/ -type f -size +5120M -exec ls -lh {} ;

* find all today’s files and copy them to another directory:
$ find /home/me/files -ctime 0 -print -exec cp {} /mnt/backup/{} ;

* find all temp files older than a week and delete:
$ find /temp/ -mtime +7-type f | xargs /bin/rm -f

* find and rename all mp3 files by changing their uppercase names to lowercase:
$ find /home/me/music/ -type f -name *.mp3 -exec rename ‘y/[A-Z]/[a-z]/

* Print Apache’s documentroot directory name:
$ grep -i documentroot /etc/httpd/conf/httpd.conf

* View file contents without comments and empty lines:
$ grep -Ev “^$|^#” /etc/my.cnf

* print only IP address assigned to the interface:
$ ifconfig eth0 | grep ‘inet addr:’ | cut -d’:’ -f2 | awk ‘{ print $1}’

* How many email messages sent for a particular date:
$ cat /var/log/maillog | grep “status=sent” | grep “May 25” | wc -l

* Find out a running process/daemon from process list (thanks to staranneph for recalling this):
ps -ef | grep mysql

* You can also note cpu/mem usage by using above. like in below command output, you can see that Plesk’s statistics process is utilizing more than 18% cpu alone:
[root@myserver ~]# ps aux | grep statistics
root 8183 18.4 0.0 58384 2848 ? D 04:05 3:00 /usr/local/psa/admin/sbin/statistics

WiMAX™ Operators Gather to Draft Global Roaming Agreements

Taipei, Taiwan — Sixteen WiMAX operators from across the globe gathered in Taipei this week to draft roaming agreements and bring consumers one step closer to true global roaming on 4G networks. The first WiMAX Forum Global Operator Summit served as an interactive working event for all service providers to gain a concrete understanding of the opportunity for roaming and how to build a best-in-class framework for execution.

Global roaming continues to be one of the biggest challenges and opportunities for operators in the near and long-term. According to Informa Telecoms & Media, global roaming revenues are expected to grow by 86 percent over the next five years to reach USD $67 billion in 2015.

“The WiMAX Forum Global Operator Summit was created to specifically address overcoming both business and consumer perceptions that data roaming is expensive, and to explore ways to help operators grow revenue,” said Ron Resnick, president and chairman of the WiMAX Forum. “WiMAX has an established ecosystem with nearly 600 deployments around the world. The opportunity for operators to offer their customers roaming is there, and it is an excellent way for operators to add another viable revenue stream and earn returns on their 4G network investments.”

Nearly 70 representatives attended working sessions and collaborated to overcome industry obstacles, including: Accton Wireless Broadband, Aicent, ADT-BV, Alepo, Apacewave, Aptilo, AT4 Wireless, Banglalion, BridgeWater Systems, BSNL, Bureau Veritas ADT, Clearwire, Elite Core – India, Encodex Telesystems, FarEasTone, Gemtek, Global Mobile, Greenpacket, ID-WIBB, Indochina Telecom, Intel, ITRI, KT Telecom, LG Electronics, Media Tek Inc., Mformation, Motorola, M-Skylink Telecom, Packet One International, Planet Online Laos, Samsung, Sprint, Syniverse, Tatung InfoComm Co. Ltd., TTC, UQ Communications, VeeTime, Wi-Tribe and YTL Communications.

The WiMAX Forum Operator Summit event team included representatives from Sprint Nextel, Packet One Networks and ITRI of Taiwan. Summit sponsors included: Aicent, Aptilo Networks, Gemtek, Global Mobile Corporation, Green Packet and Vee Telecom.

Windows Phone 7 Devices Will Charge Only When Powered On

Mobile phones running under Microsoft’s new Windows Phone 7 operating system would charge only when powered on, as the charging process has been reportedly set to be controlled by the operating system.

Basically, this meant that, in case the handset is plugged in while turned off, it would turn on automatically. Moreover, if one tries to turn it offer while charging, the handset would only reboot.

When asked on Microsoft Answers why do the Windows Phone 7 devices behave this way, a moderator answered the following:

Personally I don’t like this behavior too but there are several reasons for it:

– main one would be that the charging process is now controlled by OS and therefore it must be running
– on many feature phones (including WP7) alarms are not working when the device is turned off
– wireless Zune synchronization

Basically, in case one user plugs in the Windows Phone 7 device for charging and it boots up, he/she should know that this is normal behavior.

Devices powered by other mobile operating systems out there enable users to charge them even at times when they are turned off, and this applies to handsets powered by Microsoft’s older Windows Mobile platform as well.

Of course, it is rather interesting that Microsoft decided to design the Windows Phone 7 OS this way, but those who would like to purchase and use such devices would have to accept this.

As for the reasons invoked for this state of facts, at least two of them stand up, including the OS control for a proper charging, and the wireless syncing with the PC, which would be performed only at times when the device is plugged in.

As for the fact that some features of the handset won’t work while it was turned off, such as the Alarm, this is the same behavior as with Windows Mobile, or even other mobile platforms out there, including Android, a recent article on Pocketnow reads.

Sony Ericsson Kicks Off Work on Android 2.3 Gingerbread

Japanese-Swedish mobile phone maker Sony Ericsson has already started the work on Android 2.3 Gingerbread, most probably getting ready for bringing to the spotlight the first handset based on this OS version.

Nothing was announced officially on any upcoming Android-based mobile phone, but the arrival of Android 2.3 Gingerbread in the company’s labs was already confirmed.

Simon Walker, the Head of the Developer Program for Sony Ericsson, seems pretty happy about this, and even announced on his Twitter account (via that the handset vendor started the work on Gingerbread.

“Android Gingerbread come out last week finally! Too much delay Google. Busy weeks to come for me and the team, but all worth it big time,” Simon Walker stated on Twitter.

As any other mobile phone maker which already released devices running under Android, Sony Ericsson was expected to adopt Android 2.3 too.

However, it seems that there’s more to mention here, as some of the latest rumors around the Internet suggested that the company is readying the release of some new handsets that would be based on this Android flavor.

Among them, we can count the long rumored PlayStation Phone, which supposedly sports the codename of Zeus Z1, as well as a Sony Ericsson ANZU, which was said at one point to be set to land on shelves as Xperia X12.

No official confirmation on the matter emerged, but the fact that Sony Ericsson started the work on Gingerbread could mean a lot.

Word on the street is that these devices are set to make an official appearance sometime in the first quarter of the next year, most probably at MWC in Barcelona.

If indeed real, and we have all the reasons to believe so, the PlayStation Phone should prove a nice addition to the company’s lineup, as it is expected to offer a great gaming experience to all users, through PlayStation integration.

Hopefully, Sony Ericsson won’t let us wait too long before making an official announcement on this device. Stay tuned for more.

Add a word in front or at the end of each line

Lets say that you have a file with 1000 lines and you want to add the word start in front of each line and the word end in the end of each line. What can you do?
Let’s assume that the file is named magic.txt the command will be:
sed ‘s/^/start/g;s/$/end/g’ magic.txt

So if you want to add only in front of file use:
sed ‘s/^/start/g’ magic.txt

and if you want to add a word only at the end of the file:
sed ‘s/$/end/g’ magic.txt

Isn’t it simple?

Problem in incoming calls

At trunk settings use the following:


User details

Leave it empty

Register string

If the problem continues:
At /etc/asterisk/sip_nat.conf use the following settings

externip= If you have dynamic IP, use current for testing
localnet= eg

If the problem is still there then:
Check qos of your router in order to tune settings for VOIP.

Connect multiple skype accounts under one account

Create a shortcut to Skype.exe and place it on Desktop or start menu. Use a name the will help you clarify which account is which. Start Skype using this shortcut and setup your first account.

Then create another shortcut to Skype.exe with a different name. Open the “Properties” of this shortcut by right-clicking on it. In the “Target” text field of the properties dialog box, append ” /secondary” (do not use the quotes) to the Skype.exe path that is already there.
For example: “C:Program FilesSkypePhoneSkype.exe” /secondary

Now you can change icons in order to identify easier each account

iPhone tethering without jailbreak

I was trying to find a way to use internet tethering again on my non jailbroken iPhones when I thought something simple.
What is preventing me to use iPhone tethering function? My carrier’s new settings that iTunes suggests me to update on my iPhone. So I restored my iPhone and set it up from scratch, without using iTunes backup. Now when iTunes asks me if I want to perform this update, I simply click “no” and voila… iPhone with tethering without the need to jailbreak it.

I was trying to find a way to use internet tethering again on my non jailbroken iPhones when I thought something simple.What is preventing me to use iPhone tethering function? My carrier’s new settings that iTunes suggests me to update on my iPhone. So I restored my iPhone and set it up from scratch, without using iTunes backup. Now when iTunes asks me if I want to perform this update, I simply click “no” and voila… iPhone with tethering without the need to jailbreak it.

This was tested at iPhone 3Gs and iPhone 4. Did not have the chance to test it at iPhone 3G but I think it should work.

UPDATE for Vodafone users:
Replace web.session with at tethering settings.