Friday, October 22, 2010

Howto: Linux kill and logout users

There is a package called procps. It includes various useful (read as nifty) utilities. One of such utility is skill which is responsible to send a signal to users and process such as:
  • Halt user terminal
  • Kill user and logout
Also note that these are utilities to browse the /proc filesystem, which is not a real file system but a way for the kernel to provide information about the status of entries in its process table.

Task: How to halt/stop user called didi

Type the skill command as follows:
# skill -STOP -u didi
You muse be root to stop other users.

Task: How to resume already halted user called didi

Send CONT single to user didi, type the following command:
# skill -CONT -u didi

Task: How to kill and logout user called didi

You can send KILL single, type the following command:
# skill -KILL -u didi

Task: Kill and logout all users

The ultimate command to kill and logout all users, type the following command:
# skill -KILL -v /dev/pts/*



Please note that send users warning message or logout notice using wall command to avoid data loss.

Tuesday, October 19, 2010

How to configure kannel --SMS & WAP gateway

Kannel is an open source WAP  and SMS gateway.  With the help of kannel ,one can connect with the operators SMSC to send and receive SMS.

Kannel  also operates as Push Proxy Gateway , or PPG, making possible for content servers to send data to the phones.

HowTo: Reset Mysql root password

We can reset the Mysql database server password with following 5 easy steps.


1) Stop the MySQL server demon process.
#/etc/init.d/mysql stop
2) Start the MySQL (mysql) server/daemon process with the --skip-grant-tables option so that it will not prompt for password
#mysqld_safe - -skip-grant-tables &
3) Connect to mysql server as the root user
#mysql -u root
4) Setup new root password
mysql> use mysql;
mysql> update user set password=PASSWORD("anypassword") where User='root';
mysql> flush privileges;
mysql> quit
5) Exit and restart MySQL server
/etc/init.d/mysql stop
/etc/init.d/mysql start


Linux: Seach & Replace String in any/multiple files

Search & Replace in multiple files:
perl -n -i -e 's/originalword/newword/i; print;' *.txt
Where *.txt means all the files in the directory having extension .txt.
Search & Rrplace in single file:
a) sed -i s/originalword/newword/g filename.txt
b) replace originalword newword <original.txt >new.txt
Replace command always creates new file with new replaced string.