Glass Onion Blog

Cheat sheets, post-its and random notes from the desk of a programmer

Linux: Renaming multiple files from command line

Posted by walrus on September 12, 2008

How to rename multiple files at a shell prompt under Linux? The rename command is quite useful.

Rename command usage:

rename oldname newname *.files

Some examples:

Rename all *.abc file as *.xyz:

$ rename .abc .xyz *.abc

Remove .txt file extension:

$ rename 's/\.txt$//' *.txt

Convert all uppercase filenames to lowercase:

$ rename 'y/A-Z/a-z/' *

Posted in Software, linux | Tagged: , , , , | Leave a Comment »

Wireless protocols IEEE 802.11 A B G N compared

Posted by walrus on August 4, 2008

When buying a wireless router or a wireless network card, have you ever wondered what do these letters next to the protocol 802.11 (a, b, g, and n) really mean? What is the difference between these protocols?

IEEE 802.11 is a set of standards for wireless local area network (WLAN) computer communication. The terms 802.11 and Wi-Fi are often used interchangeably but there is slight difference between the two.

(A) 802.11a
Frequency- 5 GHz  
Typical Data Rate - 23 Mbit/s  
Max Data rate – 54 Mbit/s  
Range – 115 feet

(B) 802.11b
Frequency - 2.4 GHz  
Typical Data Rate - 4.5 Mbit/s  
Max Data rate – 11 Mbit/s  
Range - 115 feet

(G) 802.11g
Frequency - 2.4 GHz  
Typical Data Rate – 19 Mbit/s  
Max Data rate - 54 Mbit/s  
Range – 125 feet

(N) 802.11n
Frequency - 5GHz and/or 2.4GHz  
Typical Data Rate - 74 Mbit/s  
Max Data rate - 300 Mbit/s (2 streams)
Range – 230 feet

Posted in Networking, Technology | Tagged: , , , , , , , , , | 5 Comments »

Back up and Restore MySQL database from the command line

Posted by walrus on July 30, 2008

Backing up via the command line:

Type the following at the prompt with the appropriate USERNAME and DATABASE name:

mysqldump -u USERNAME -p DATABASE > dump.sql

You will be prompted for your database password and then the DATABASE will be dumped to a plain-text file called dump.sql.

Restoring via the command line:

First drop and recreate the database as needed:

Drop the database

mysqladmin -u USERNAME -p drop DATABASE

Recreate the database

mysqladmin -u USERNAME -p create DATABASE

Import the backup data

mysql -u USERNAME -p DATABASE < dump.sql

Posted in MySQL, Software, linux | Tagged: , , , , | Leave a Comment »

Linux: Setting JAVA_HOME for a single user and all users

Posted by walrus on July 21, 2008

Here is how to setup JAVA_HOME and PATH environment variables for a single user or all users on Fedora Linux system

Setting JAVA_HOME and PATH for a single user

# vi ~/.bash_profile
# export JAVA_HOME=/opt/jdkx.x.x_xx
# export PATH=$PATH:$JAVA_HOME/bin

Setting JAVA_HOME and PATH for all users

# vi /etc/profile
# export JAVA_HOME=/opt/jdkx.x.x_xx
# export PATH=$PATH:$JAVA_HOME/bin

Posted in Software, Technology, java, linux | Tagged: , , | Leave a Comment »

Linux – How to find out which Shell you are using?

Posted by walrus on July 21, 2008

Here are three quick ways to find out which shell you are currently using:

Method 1:

command:

# echo $SHELL

output:

/bin/bash

Method 2:

command:

# echo $0

output:

-bash

Method 3:

command:

# ps -p $$

output:

 PID TTY               TIME CMD
1447 tty1          00:00:01 bash

Posted in Software, Technology, linux | Tagged: , , | 1 Comment »