Linux Blog

Keeping your Firefox Bookmarks Synced

Filed under: General Linux — Owen at 12:37 am on Thursday, July 3, 2008

Keeping your FireFox bookmarks synced between multiple computes is a great concept. We sync everything else from e-mail to contacts to music so why not keep our bookmarks in a central location? In this post I’ll describe the method I’ve been using without any problems for the past three months or so. Feel free to contribute how you achieve the same thing. The only requirement for me is that the bookmarks be cross platform, so I can log into any sort of machine that runs FireFox and view my bookmarks.

I looked into using sshfs to sync my bookmarks folder also, but this seemed like a lot of work. So I decided to scout out the online bookmarking services. There are the big ones like del.icio.us, Google bookmarks and then countless other smaller ones. The major ones looked promising, so it was difficult to choose one. The deciding factor for me was the actual FireFox plugin its self. The GMarks plugin for FireFox seems to be very stable and simple to use. It works well on Windows, Linux and MacOSX. It has an export feature and is based off of the Google Bookmarks service so I don’t have to worry about losing my bookmarks.

Check out: https://addons.mozilla.org/en-US/firefox/addon/2888 for more information and screenshots.

Managing Services on Fedora

Filed under: Linux Software — Owen at 12:01 am on Wednesday, July 2, 2008

Fedora is a great desktop system, it has a pretty good services manager called service. It can be used to turn on, off and restart most services that run on the system. Should you want to manage running services all you have to do is type:

service <service name> <stop | start | restart>

If you don’t know the service name it can normally be found by issuing the –status-all switch. Doing so will output a long list of services so you may want to grep it or use a pager such as less:

[root@linux-blog ~]# service –status-all | less

[root@linux-blog ~]# service –status-all | grep snmp
capi not installed - No such file or directory (2)
JAVA_EXECUTABLE or HSQLDB_JAR_PATH in ‘/etc/sysconfig/hsqldb’ is set to a non-file.
snmpd is stopped
snmptrapd is stopped

While service is a great utility to manage services it does not stop them from running at startup. To manage services that start up when you boot you can use a handy little dialog script called “ntsysv”:

[root@linux-blog ~]# ntsysv

This will give you a nice dialog which is intuitive and similar to those of text based installers. Select the services you want to start up and then tab over to OK. I turn a lot of services off that I don’t use, if you’re unsure of what you need, try stopping it with the services command first and see if anything breaks. If after test it works well just turn it off.

Since I don’t use SELinux on my development machine, I always turn off setroubleshootd. I used ntsysv to stop it from starting at bootup and if I need it I can use the service command to start it.

Here is a screenshot of ntsysv in action:

managing services with ntsysv on Fedora

tweeting from the command line

Filed under: Shell Script Sundays — Owen at 12:25 pm on Sunday, June 29, 2008

This is a subject that has been covered time and time again but I don’t think that it will hurt one more time. Twitter is a very popular “Microblogging” site where you can constantly change your status to let those who “follow” you know what you are doing. Since I just signed up for twitter for The Linux Blog I figured I’d write this post on how I update my twitter feed. While I’m at it I might as well invite you over to my feed URL: http://twitter.com/linuxblog

So here is the script:

#!/bin/bash
echo “Enter Tweet: “;
read inputline; TWEET=”$inputline”;
curl -u user:password -s -F status=”$inputline” http://twitter.com/statuses/update.xml http://twitter.com/account/end_session

This is a very basic twitter script, it does no error checking and probably doesn’t escape characters properly. None the less it works. The part that gets input from the shell is the following line:

read inputline; TWEET=”$inputline”;

If you’d like more information on how this works read this article: Shell Script to get user input

Curl is used to send the data to Twitter, to view curl tutorials and how-to’s visit the Curl Man Page which has a wealth of information at the bottom.

Until next time, happy tweeting!

Apache “Directory index forbidden by Options directive:”

Filed under: Quick Linux Tutorials — Owen at 9:29 pm on Friday, June 27, 2008

This is a common problem with the Apache web server. It is considered a security risk to show the directory contents by default. Especially those in the root directory. The way to fix this is pretty simple, you first need to make sure that there are no -Index directives in any of the configuration files. In your httpd configuration directory grep with a line number for Options like so:

grep -n Options *

If you don’t see any -Indexes then its possible there are included files. Check these directories if you know them, if you don’t grep your configuration file for the Includes:

grep -n Include *

If you’re still getting the test page or a permission denied error after removing the directive that disables Indexes then it may be a permissions issue. Apache needs +x access for all users to enable directory listings. Change the permissions and it should work.

On Fedora there is a file called welcome.conf in the conf.d directory. This can be removed and if you have Options All set, then you should be good to go. On other distributions like Slackware it is easier to accomplish. I wouldn’t recommend allowing any sort of directory listing in a production environment but in my development case, where I only allow access to my test server on a per host basis this is not a big problem.

Also, remember to restart the server after making changes.

Hope this helps, if it doesn’t be sure to drop a comment!

Bash Aliases

Filed under: General Linux, Linux Software, Quick Linux Tutorials — Owen at 12:23 pm on Wednesday, June 25, 2008

Have you ever wanted to make a command for something that did not exist? Perhaps modify the functionality of a particular application to something more suitable? I know I have. For example, and I know that there is probably a better way to do this, but on certain Linux machines (such as servers), I like to clear the output before exiting. While I can type the command:

clear; exit

this still leaves me with a line at the top of the screen. Some distributions clear this automatically, for those that don’t an alias can be used.The basic principal for a bash alias is easy. You set an alias up and then use that alias instead of the command.
It appears that aliases have precedence over any already existing applications in the path so it becomes handy if you wish to override a command or perform a task before launching a built in command. I’m sure that this option can be changed if needed.

Now you know what aliases are here is how to use an alias to override the exit command in bash.

alias exit=”clear; exit > /dev/null 2> /dev/null”

Aliases with parameters can get tricky, the best workaround I have found is to write a shell script and put it in your local bin directory.

Some notes on DD-WRT

Filed under: General Linux, Linux Hardware, Linux Software — Owen at 1:44 am on Saturday, June 21, 2008

For those of you that don’t know DD-WRT is a modified version of firmware somewhat like that of the Linksys NSLU2 except more geared towards wireless routers, it runs on over 80 models.

I needed to finally set my home office / desk up with my home wireless network. I currently have a Belkin running DD-WRT and was very happy with the versatility. I have temporarily used it as a wireless bridge in other applications, so I thought I’d add another DD-WRT box to my network and use it as a bridge as I had previously done.

As noted above DD-WRT does support a large variety of wireless routers, the problem is finding a supported model. I purchased another cheap Belkin as it was on the known working hardware and came to realize that it was not possible to get DD-WRT set up on it. It was an version that was specifically put on the not supported list which I had failed to check.

A lot of Netgear routers are supported, but be careful. I noticed that the Model numbers do work, but the newer Netgear versions of the same model are not supported. I oped to buy a WRT54G for a modest $49.99. It has slightly less ram, and flash memory meaning that it can not support the full version but it has more then enough features in the micro version that it can run.

The Linksys WRT54GL retails about $65-$90 and can be purchased from most computer stores that have a decent selection. It features some pretty good specs, like the WRT54GS except it has more RAM and more flash. Again, this depends on the version you get. If you purchase the WRT54GL you are guaranteed to get a working version of DD-WRT on it though. It took me a while to find my WRT54G, I shopped at Best Buy, Circuit City, Office Max, Staples and they all had the “latest and greatest” models that are not yet supported by DD-WRT and were incredibly over priced. At one point I was very desperate and almost purchased an overpriced WAP54G which is the same thing without the built in switch. I am very happy that I didn’t as I would have also had to wire up my 16 port switch to a power supply since it went bad.

If your considering purchasing a router to run DD-WRT just check the black list first and take a print out of the supported and not supported lists from DD-WRT.com (The employees of big box retail stores don’t like it when you take every model they have to a computer with Internet and compare the models / versions one by one only to take them all back.)

Switch! The Linux Blog Dog

Filed under: The Linux Blog News — Owen at 10:57 am on Friday, June 20, 2008

So, after a long time with no posts I think I figured out why I haven’t been writing as much. You see, I recently got a dog, she is a 7 month old border collie - whippet mix. Her name is switch and she currently demands a lot of attention or she gets into mischief, but after a long walk she does a really wicked FireFox impression which makes up for it.

I’ll be writing as much as I can, but again if any one would like to write on this blog or is interested in guest blogging just let me know.

Below are some pictures of Switch! The Linux Blog Dog

Linux Blog Dog
Linux Blog Dog

iPhone SSH Client

Filed under: General Linux — Owen at 2:34 pm on Monday, June 9, 2008

For those of you that have been following me for a while may remember my post titled Phones Meet Linux on iPhone alternatives and how I probably would not buy an iPhone. Today the iPhone has another alternative: its self. Apple announced the release of a new version of the iPhone. I’m sure your all familiar with this by now since its been rumored for months but now its been announced.

So, with the announced release of the iPhone I’m happy to see that developers can now develop and distribute applications for the iPhone. Now I’m wondering how long it will be before there is a SSH client in the application database for the iPhone. System monitoring applications would also interest me. Among this they have also dropped the price, it will only be a matter of time before they run out.

What does this mean for open source developers? I cannot say I know the answer to this question yet. Is Apple going to allow open source projects to be distributed through their network? Wouldn’t it be nice? Free applications for the iPhone that are better than paid versions would be killer. What are your thoughts on this?

Parse ifconfig data with shell scripts

Filed under: Shell Script Sundays — Owen at 2:25 pm on Sunday, June 8, 2008

This week in TheLinuxBlogs.com’s Shell Script Sundays article I’m going to show you how you can use basic UNIX commands to parse networking data. As always there are a number of different methods of achieving this, and I am in no way saying that this is absolutely the way you must do it, or the best way. Its just an example of how you can use shell scripts to your advantage.

Firstly most know that Linux uses the ifconfig command to get information about networking interfaces. If you issue the ifconfig followed by the interface name you get information just about that interface as follows:

# /sbin/ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:0E:35:7F:E2:98 inet addr:192.168.2.13 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::20e:35ff:fe7f:e298/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1146 errors:0 dropped:39 overruns:0 frame:0 TX packets:1 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:23748601 (22.6 MiB) TX bytes:507899 (495.9 KiB) Interrupt:11 Base address:0×4000 Memory:fceff000-fcefffff

This information is not in the best format to parse (it has also been distorted by my blogging software.) To solve this problem we are going to search for the whitespaces at the beginning of each line and replaces them with commas. By doing this:

# /sbin/ifconfig eth1 | sed ’s/ /,/’
eth1 Link encap:Ethernet HWaddr 00:0E:35:7F:E2:98 ,inet addr:192.168.2.13 Bcast:192.168.2.255 Mask:255.255.255.0 ,inet6 addr: fe80::20e:35ff:fe7f:e298/64 Scope:Link ,UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 ,RX packets:1344 errors:0 dropped:39 overruns:0 frame:0 ,TX packets:1 errors:0 dropped:0 overruns:0 carrier:0 ,collisions:0 txqueuelen:1000 ,RX bytes:23809630 (22.7 MiB) TX bytes:507899 (495.9 KiB) ,Interrupt:11 Base address:0×4000 Memory:fceff000-fcefffff

That gives us a nice comma after every line. In order to grab fields from this line the tr command can be used to replace spaces with pipes.

#/sbin/ifconfig eth1 | sed ’s/ /,/’ | tr [:space:] \|
eth1||||||Link|encap:Ethernet||HWaddr|00:0E:35:7F:E2:98|||,inet|addr:192.168.2.13||Bcast:192.168.2.255||Mask:255.255.255.0|,inet6|addr:|fe80::20e:35ff:fe7f:e298/64|Scope:Link|,UP|BROADCAST|RUNNING|MULTICAST||MTU:1500||Metric:1|,RX|packets:1765|errors:0|dropped:39|overruns:0|frame:0|,TX|packets:1|errors:0|dropped:0|overruns:0|carrier:0|,collisions:0|txqueuelen:1000||,RX|bytes:23941275|(22.8|MiB)||TX|bytes:507899|(495.9|KiB)|,Interrupt:11|Base|address:0×4000|Memory:fceff000-fcefffff|||

Now that the fields are all delimited properly, lets use the cut command to grab a line from this. Since I am interested in the RX and TX bytes I’m going to grab data from line 8 by using the cut command as follows:

#/sbin/ifconfig eth1 | sed ’s/ /,/’ | tr [:space:] \| | cut -d , -f 8
RX|bytes:24014818|(22.9|MiB)||TX|bytes:507899|(495.9|KiB)|

That gave us a nice line of output which is easy to parse even further by using the cut command. You will notice the fields are delimited by a pipe (the | character) and are not always consistent since we replaced all spaces with a pipe. Take a look at the first two fields RX|bytes: This means that to get the RX bytes in bytes we need to cut yet again. Since I’m not to bothered about Bytes and the largest number is delimeted in fields 3 and 4 I will concentrate on those.

#/sbin/ifconfig eth1 | sed ’s/ /,/’ | tr [:space:] \| | cut -d , -f 8 | cut -d \| -f 3-4
(23.0|MiB)

This is a nice RX MiB output yet it has one last problem, the pipe between the characters. Sed can be used to replace this and any other characters if you wish. Just issue a sed find and replace like this:

#/sbin/ifconfig eth1 | sed ’s/ /,/’ | tr [:space:] \| | cut -d , -f 8 | cut -d \| -f 3-4 | sed ’s/|/ /’
(23.0 MiB)

That looks good for now. If you would like more information on how to parse data regarding this post or any other you can always leave me a comment and I’ll try my best to help. Especially if we can post the results on TheLinuxBlog in another Shell Script Sundays Article. Thanks for reading The Linux Blog and come back soon!

Eclipse - Around the World

Filed under: General Linux, Linux Software — Owen at 2:46 pm on Friday, June 6, 2008

Ganymede is coming! I’ve been using Eclipse for a little while now and would like to pass on some information about the Ganymede release.
In the past I have became accustomed to commercial IDE’s, what is bad about this is when a new release comes out often I’d have to either upgrade or be stuck with an old version. Eclipse gives me a standard development environment that works on multiple computer platforms. Through plug-ins often the exact same, or better functionality is added. What is great about Eclipse Ganymede is that it lets you get a preview of what the next generation of the IDE will look like. Eclipse Ganymede is not for every one, after all it is for testers and early adopters. Personally I like to download the Ganymede release every once in a while and test it out. After all some of the big players in the development industry sponsor or contribute to a number of projects that are based on eclipse and its nice to see what they are up to. Check out Ganymede Eclipse for yourself!

Sorting lists with Sort

Filed under: Quick Linux Tutorials — Owen at 11:11 pm on Wednesday, June 4, 2008

There comes a time when it is useful to know how to sort lists. Thankfully using open source software sorting text files can be very easy.

This example shows how to sort a file alphabetically using the sort command. I assume that you have a text file in mind so I will skip the creation of that. There are two ways to sort the file with the sort command. The first being the preferred method but not always suitable.

sort <textfile>

cat <textfile> | sort

Thats it! The second method can be useful if you would like to do any thing special, for example searching with grep, using cut or sed for data extraction or just out of convenience. Check out the man page for sort for more information on all of the options!

Next Page »