Sunday, April 20th, 2008

rpl - A Find & Replace Terminal Tool

Tonight I have mainly been working on Whird. I have been rewriting large chunks of code in an effort to optimise a bunch of functions. As a result of this, I had to change a series of strings in a number of files. As per normal when it comes to fiddly grep, sed and awk commands, I fired up Google and searched for some pointers. Whilst refreshing my memory, I came across a comment by an anonymous reader who suggested using the rpl command.

I had not previously come across rpl before, so I investigated. Turns out that rpl is a really handy text replacement tool — it makes recursive text replacement commands really simple; as simple as:

rpl [options] old_string new_string target_file(s)

Available options are:

--version          show program's version number and exit
-h, --help         show this help message and exit
-L, --license      show the software license
-x SUFFIX          specify file suffix to match
-i, --ignore-case  do a case insensitive match
-w, --whole-words  whole words (old_string matches on word boundaries only)
-b, --backup       make a backup before overwriting files
-q, --quiet        quiet mode
-v, --verbose      verbose mode
-s, --dry-run      simulation mode
-R, --recursive    recurse into subdirectories
-e, --escape       expand escapes in old_string and new_string
-p, --prompt       prompt before modifying each file
-f, --force        ignore errors when trying to preserve permissions
-d, --keep-times   keep the modification times on modified files
-t, --use-tmpdir   use $TMPDIR for storing temporary files
-a, --all          do not ignore files and directories starting with .

rpl is available to install from the Ubuntu repositories, install with the following command:

sudo apt-get install rpl

For more information about rpl, see: http://www.laffeycomputer.com/rpl.html


Thursday, April 17th, 2008

Create MySQL User Accounts from the Command Line

I have my LAMP install process down to fine art, which is a good thing considering the amount of Linux installs I have been performing lately. Anyhow, just recently I have been experiencing some issues with creating MySQL user accounts. Normally, for ease of use, I would simply login to phpMyAdmin and create a new user account, but, for some unknown reason, this method has not been working; maybe there is a compatibility issue between the latest versions of MySQL Server and phpMyAdmin available from the Ubuntu repositories?

Anyway, to get around this little problem, I have been creating new MySQL user accounts via the command line. It is a fairly straightforward procedure, but like a lot of administration tasks, it is not something I do on a daily basis. With this in mind, I thought it would be a good idea to record the process for future reference.

Follow the steps below to create a new user MySQL account. Note, these instructions assume that you have already set-up Apache, MySQL and PHP.

1. Open a terminal and login to MySQL as root:

mysql --user="root" --password="your_root_password"

2. Create a new user and password with the following command:

CREATE USER 'new_username'@'localhost' IDENTIFIED BY 'password_for_new_username';

3. Assign privileges to the new user, enter the command:

GRANT ALL ON *.* TO 'new_username'@'localhost';

4. Exit MySQL interface, enter:

exit

Notes: The above instructions will create a new user account on "localhost" and grant the user all privileges. While this is safe for my development environment, you would obviously want to grant only the necessary permissions in a production environment.

For more developer information, including the MySQL Reference Manual, visit: http://dev.mysql.com/


Tuesday, December 18th, 2007

Configure Wireless on the Command Line

Today I have mainly been attempting to create a very light installation of Ubuntu on an old Pentium III. I started by installing a base system with the Ubuntu alternative install disk. After the base system was installed I then tried to configure my wireless card from the command line. I was half expecting this to be a difficult task, however it wasn't actually too difficult and thanks to some rather nifty instructions I managed to get my wireless card working in no time. For future reference here are the necessary commands:

1. Turn the interface on with the following command:

sudo ifconfig wlan0 up

2. Scan for a list of all the available access points:

iwlist wlan0 scanning

3. Select the access point with the following command:

sudo iwconfig wlan0 essid ACCESSPOINT

4. Set WEP or WPA passphrase, if needed:

sudo iwconfig wlan0 key PASSPHRASE

5. Finally, connect to DHCP server and obtain an IP address:

sudo dhclient

I'll post more details about the actual system install when I get more time, for now I just wanted to get these instructions down in case I end up having to start again from scratch.


Sunday, December 16th, 2007

PuTTY SSH Client for Nokia N95

Tonight I have mainly been playing with PuTTY for Symbian OS, an SSH client for my new Nokia N95. After figuring out the correct version to download, there are several versions available for the different editions of Symbian, the installation was super easy and simply consisted of clicking a few confirmation buttons. By the way, the correct version for the Nokia N95 is the S60 third edition.

Regarding usage, I found using PuTTY on my mobile phone to be a somewhat fiddly experience, mainly due to the fact that I have pig tits for fingers. Having said that, I can't really fault the software. Anyone with any experience of using an SSH client shouldn't experience any difficulties and should be able to get a connection up within a minute or two; I connected to one of my Ubuntu systems at home, impressive stuff, even if I do say so myself! For me, the ability to run an SSH client gives a whole new meaning to the term "smartphone". Is there anything this phone can't do?


Monday, September 24th, 2007

CPU Temperature via Terminal

Enter the following command in your Linux terminal to get the current running temperature of your CPU.

acpi -t

This is a handy command and one that I should be able to put to good use. My desktop is a little bit old and crusty and is forever overheating in the summer. It should be possible to use this command in conjunction with cron to set-up a warning system to let me know when my system is about to go into meltdown.

via the Ubuntu Forums


Browse Posts by Tag

13th advocacy antispam artwork bash bbc bcs bittorrent bloggers blogs boobs bookmarklets cli code colour commands comments conduit crontab crunchbanglinux debian design development email fluxbuntu fonts fun gedit gimp gnome google gos hack hacks hosting images javascript language launchpad life lincslug linux lugradio madness memes misc monkeys motu mysql n95 networking nokia openbox openoffice opensuse packaging penguins php phpmyadmin podcast ppa progbox programming projects puppy python random rants realplayer revu scripts security shell software ssh terminal terminator themes tools twitter typography ubuntu ubuntucse unitedhosting video virtualisation webdesign whird wiki windows woot xfce4 zombies