A Django site.
May 9, 2008
» A Root Shell On Ubuntu : The Right Way

Just the other day we were having a discussion on using the root shell in Ubuntu.  Now, remember, the root user account is disabled with no assigned password on a default Ubuntu system so administrative tasks need to be done using the sudo command.  For nearly all of the administration you would need sudo will be adequate.  There are occasionally those fringe cases where you might require a root shell.  Below I have a few alternatives and then, if you must, the correct way of opening a root shell.

For more information please see the RootSudo page on the Ubuntu Community Wiki.

Alternatives To A Root Shell

One of the most common reasons that a user might need a root shell is due to output redirection not working as expecting while using sudo.  This can be bypassed fairly easily.  Let me outline an example:

sudo echo “foo” > /root/somefile

The above example will not work because the normal user does not have access to write to the root user home directory, and combining the redirection in the command we’ve lost sudo access.

An alternative that will work would look something like this:

echo "foo" | sudo tee /root/somefile

This will echo the output on the console but the tee command ('man tee‘ for more information) will also take that output and write it to the file as expected.  Also note that 'tee -a' will work in the same fashion as >>, appending the data to the current file vs overwriting.

The Proper Way To A Root Shell

If you still need a root shell (perhaps you’ve come across a different scenario? perhaps you’re just lazy? perhaps you’re coming from another distribution?) let me outline the proper way to gain a root shell.

DISCLAIMER: This should be avoided if at all possible.  It is not suggested to run a root shell on an Ubuntu system.  Use at your own risk.  See examples above, etc.

sudo -i

The command sudo -i is the equivalent to the 'su -' command.  This will properly change to the root user, switch to the root user’s home directory, use his (her?) environment values, etc.

sudo -s

The command sudo -s is the equivalent to the 'su' command.  This will change to the root user but will not properly use his (her?) environment values, etc.

The WRONG Way To A Root Shell

Please DO NOT use the following methods to gain root access:

sudo bash, sudo sh, sudo su -, sudo su, sudo -i -u root

If you currently do use these methods this post was written for you!

UPDATE: Based on the feedback in the comments for this post I’ll try to expand the reasoning on *why* the right way is the preferred way.

First of all we need to understand some background information.  When a user creates a session there are a number of environment values that are set.  To have a look at some of these try this command:

env

This will output a number of details about the current working environment.  These environment values may be different for different users.  Some of the values are generated by way of the .bashrc file (assuming a bash shell, of course), the .bash_profile, etc.  Take a look at the .bashrc in your users home directory and compare it with the .bashrc in root’s home directory.

diff -u ~/.bashrc /root/.bashrc

You should see some differences, and this is just from one of the multiple files that are read during a proper login.

When creating a root shell by using ‘sudo bash‘ you are not incorporating the root environment properly.  You are creating a shell with root privileges but the env output is still that of your user.  Each user, whether unprivileged or root, should have unique environment settings to truly be that user.  This will be the case for ‘sudo bash‘, ‘sudo su‘ and ‘sudo sh‘.

Random Posts

May 15, 2008

Clint Savage
herlo
Sexy Sexy Penguins » Tech
» Utah Fedora/Ubuntu Linux Release Party Outtakes

Well, usually I forget to take pictures, because either A) I forget my camera [I brought it this time] or 2) I get wrapped up in the event and forget to bring it with me.  But this release party, I plain just forgot to charge my batteries for my camera, oops!

Fortunately, I was able to snap a few pictures with some of the spare, also not fully-charged, batteries I did have on hand.  However, others took many pictures and I’ve listed them below.

To summarize the party, much celebration was had with foosball, a chess game on one of the largest chess boards around, video games, air hockey and much more was provided by CodeGreene.  The FedoraProject and Utah Open Source sponsored the food and prizes.  If you’ve never had a Chipotle burrito, they are the best burritos around.

I was able to spend time with about 5-7 people myself sharing the Preview Release of Fedora 9 (codename Sulphur) including two who had never had previous success with Fedora or Linux in general.  It was very satisfying to see things work for them.

The Ubuntu folks were there in strength as well.  The Hardy Heron (8.04) CDs were being passed out, while we Fedoran’s provided LiveUSB versions.  I even saw people taking advantage and obtaining both!  Its great to see communities come together and celebrate together.

The party continued at Salt Lake Pizza & Pasta for another couple hours.  Lot’s of talk about the releases, upcoming events, and general mayhem took place including having Heartsbane shoot beer through his nose when I swore at him!

All in all, quite a successful evening and I look forward to helping others in November at our next release party.

Cheers,

Herlo

UPDATE: Another 70+ pictures have been added, check them out!

May 4, 2008

Tristan Rhodes
no nic
The Open Source Advocate
» Utah Release Party: Ubuntu, Fedora, OpenBSD

Yesterday we held a release party in Salt Lake City, Utah to celebrate the release of several open source operating systems. The original announcement only mentioned Ubuntu 8.04 LTS and Fedora 9, but we realized during the party that OpenBSD 4.3 was released on May 1st.

We were all happy to celebrate the goodness of open source, without arguing over which distro was better. The Fedora guys showed us some cool improvements, and the Ubuntu guys also demonstrated some neat improvements. The great thing about open source is that all of these improvements will be shared by both distributions in a future release.

I want to say thank you to our excellent sponsors who made this party a success. First, the amazing location was provided by the web-development company Code Greene. Second, the delicious Chipotle burritos were donated by the Utah Open Source Foundation, ran by Clint Savage. Lastly, thanks to the Fedora project who contributed funds, and Ubuntu/Canonical who contributed swag (including hundreds of 8.04 CDs).

Here is a picture of the three Ubuntu babies! This is the second release party for my girl Chloe (on the right).

We had an estimated 50 people at this party, but there is not one shot that includes them all. We do have physical evidence that 32 burritos were eaten and many people did not get one.

Here is Clint Savage doing his best impression of a good speaker. Just kidding Clint, you did a great job! Thanks for helping foster open source communities in Utah.
Notice the Fedora posters and foosball table in the background. This web-development company also has a kitchen, ping-pong table, an air-hockey table, a gigantic over-sized chess set, and a high-def theater that was playing the original Star Wars. Sounds like a great place to work!

May 1, 2008

=Utah Open Source=
Utah Open Source
The Utah Open Source Foundation
» Reminder: Linux distro release party THIS SATURDAY! Woo!

In case you haven’t heard or read already, Ubuntu 8.04 (Hardy Heron) was released just a few days ago (April 24). I certainly have noticed plenty of talk about it on blogs and tech news sites. Fedora 9 (Sulphur) was scheduled for release right about now, but the fine folks at the Fedora Project decided they needed a couple more weeks to work out some kinks. In the meantime, there is a fine Fedora 9 Preview release available which can be updated to the official release when it is out (May 13, or so they say).

So what does all this mean? It means it’s time to party like it’s v0.99!

Code Greene, a programming shop located in Salt Lake City, is graciously hosting a release party THIS SATURDAY to celebrate these two latest distribution releases. What?! You’re a OpenSUSE enthusiast? A long-time Slackware user? That’s okay! You can still come and enjoy good food, good company, and fun and games. (Rumor has it these Code Greene people don’t actually do any real work, they just play foosball and videogames all day.)

Here are the vital details:

  • Date/time: Saturday, May 3, 6pm to 8pm
  • Address: Code Greene, 44 Exchange Place Salt Lake City, UT 84111

Now, if you’re coming, you should take a moment and RSVP via this friendly and easy-to-use Upcoming link.

This release party is being sponsored by us- the Utah Open Source Foundation, the Fedora Project, and Ubuntu Utah.

April 26, 2008

Tristan Rhodes
no nic
The Open Source Advocate
» Synching the open source release schedule

Introduction

Both Mark Shuttleworth and myself have discussed this idea before. Because Mark brought it up again in a recent interview, I feel compelled to developer this idea further.

The main concept is that Linux distributions, and open source in general, have a lot to gain by synchronizing their release schedules.

Positive impact on the image of open source

Can you imagine the news articles that would be written if Ubuntu, Fedora, and OpenSuse all released a new version on the same day? Every six months, the world would see that open source has successfully delivered a new version on schedule. Mark Shuttleworth made a great point when he stated:

"We know when the next LTS will be probably with better confidence than we know when Windows 7 will ship. I would take that bet."
Once the distro releases become synchronized, it would create a huge incentive for upstream projects to synchronize on the same schedule.

Currently, we have upstream releases happening all over the calendar. For example, the newest version of Ubuntu includes a beta version of Firefox 3. It also includes OpenOffice 2.4, which is soon to be replaced by OpenOffice 3.0. With the power of a synchronized release, these upstream projects would work hard to get their newest versions into the distributions so that their users can start using the code sooner.

Creates efficiencies in software development

Open source is a very unique software development model, in that the code is freely shared between anyone who wants to work on it. This usually leads to great productivity from the worldwide development team that is formed.

However, there are some friction points in this model. Specifically, this friction happens when Linux distributions are working on different versions of an open source application at the same time. Mark addressed this point in his interview:
"Timing your releases drives a whole bunch of things. It means a greater ability to collaborate on bug fixes. If we are on the same versions of the Linux kernel, it is a lot easier for us to say, 'Hey, here is this patch to make this device work. Do you know any reason why we shouldn't put it in?'

You could just get so much more done at an engineering level between the teams. My engineers regularly collaborate with Novell and Red Hat and, of course, Debian. Barriers to that sort of collaboration are sometimes ideological but, in most cases, are just practical things. We are just on a different version so someone else's patch isn't going to apply. There's a bit of friction there."
How do we accomplish this?

I agree with Mark's short answer to this question. Simply set a hard date and modify your goals to make that release date. That greatly oversimplifies things, but it demonstrates that the long-term benefits of a regular release schedule greatly outweigh any negatives caused by postponing a feature into the next release.

In reality, there are a number of questions that need to be answered before this can happen.

1. On what date will the releases happen? Does it have to follow the current Ubuntu schedule of releasing every April and October?

Mark answered this question in his interview:
"We would be quite willing to revisit the elements of our release schedule in order to make that synchronicity possible, if the fact that we happen to do April and October wouldn't work for the majority of the distros. We would be flexible in that regard."
2. What amount of time should there be between regular releases?

Periodic releases every six months has worked very well for Ubuntu, but not all distributions are currently following that schedule. Six months also works great from a marketing perspective, because the release would always happen in the same months every year. Lastly, the open source motto is to "release early, release often". Six months is an attainable goal that balances the need for incorporating new features with the need for stability and quality assurance.

Call for civility

I understand that a post like this could lead to a distro war in the comment section. Please keep your comments civil and always show respect for other people's ideas. Hopefully, we can come up with some great ideas on how to improve open source software!

April 23, 2008
» Upgrade Ubuntu 6.06 to Ubuntu 8.04

With Ubuntu 8.04 being the second LTS (Long Term Support) release it is also possible to upgrade from LTS to LTS releases.  This means upgrading Ubuntu 6.06 to Ubuntu 8.04.  I have tested this in a previous post, “Dapper 6.06 to Hardy 8.04 Direct Server Upgrade“, which you might also be interested in (that post is regarding the Server and not the Desktop release.)

Upgrading via Update Manager

Step 1: It is suggested that you make sure your BIOS is up-to-date before you try such an upgrade.  This is based on some changes in the latest kernel releases which can conflict with older BIOS firmware.

Step 2: You’ll need to make sure that the dapper-updates software channel is activated.  (See my previous post linked above for an example of which repositories can/should be enabled.)

Step 3: Press Alt-F2 and type gksu "update-manager -d"

Upgrade Ubuntu 6.06 to 8.04 via Update Manager

Step 4: Click the Check button to check for new updates.

Step 5: A message will appear informing you of the availability of the new release.

Step 6: Click Upgrade

Upgrading to the latest version

Step 7: Follow the instructions as the Update Manager utility will walk you through each step of the upgrade.  You will still have a chance to back out after clicking Upgrade if you feel you’re not yet ready.

For more information and other information from the Wiki see: Upgrade Notes

Related


Aaron Toponce
atoponce
Aaron Toponce
» XFS vs Reiser

Last night, Christer and I were playing with the Ubuntu 8.04 installer, trying to break it, and get any last bugs reported before final is released tomorrow.

What I noticed last night, during the install really surprised me. ReiserFS is a screaming filesystem compared to XFS. After doing the install 3 times on 2 identical machines (Dell Precision 490), in every case, ReiserFS was nearly twice as fast completing the install. Didn’t matter how the disk was partitioned either. It is a screaming speed machine. Further, launching applications, and playing with KVM, it was also noticeably faster than it’s XFS competition.

However, XFS did have much better storage management in the way of sqeezing out every last byte on the drive. In fact, on bare bones installs, XFS gave me 10% more storage space than ReiserFS.

Conclusion? If you’re after speed, from what I gathered last night, ReiserFS screams. If you’re looking for maximized disk space, XFS is the clear winner there. Was the disk space gain worth the wait of the install? Yeah, probably. But man, post-install, launching applications with ReiserFS was still noticeably faster than XFS.

I’m curious about these, and will be benchmarking some more in the future. Expect follow-up posts on this topic.

April 20, 2008
» Origami (previously folding.sh): Now In PPA!

Its been a while since I’ve blogged about my Folding@Home management tool, now called Origami.  There was a lull there in development for a while, but this last week I’ve done probably 20+ commits, which puts us up to version 0.6.6.1.  There are now also two branches being maintained on Launchpad (bzr).  One for trunk, which has the latest-greatest features, and another branch called debian which will track the package source files.  As usual, if anyone would like to check out the code and offer improvements feel free.

I also wanted to announce that it is now available in package form via my Launchpad PPA!  Launchpad FTW!  The current .deb is based on the current debian branch.  If any packagers want to take a look and tell me how to improve the package (this is my first one afterall) I’d be very interested.

I should also mention that with the rename there has bit a bit of an overhaul in the code base.  Origami is not directly backwards compatible with folding.sh! I have to say that the simplest method for the transition is uninstalling folding.sh (sudo folding.sh erase) and then installing the Origami package.  This will cause you to lose your current work progress, so maybe wait until you’ve just started a new work-unit and give it a go.

Installing Origami via Launchpad PPA

To install Origami using Launchpad’s Personal Package Archive system, simply add the following line to your /etc/apt/sources.list file or “Add” in System > Admin > Software Sources.

deb http://ppa.launchpad.net/christer.edwards/ubuntu hardy main

Once that line is in your config file make sure to update (sudo apt-get update) and then install the origami package.  Currently it is only built for Ubuntu 8.04 “Hardy”, but by the end of the week I’ll have the other supported releases built as well.  (To install for a previous release simply replace “hardy” with “release” in your configuration.)

I’ve been happy with all the feedback so far.  Thanks to those that have reported bugs and helped me make Origami even better.  If anyone finds any additional bugs or has feature requests please let me know!

April 18, 2008

Clint Savage
herlo
Sexy Sexy Penguins » Tech
» I guess we’ll wait

As many of you may already know, Fedora 9 (codename: Sulphur) has been pushed back 2 weeks to May 13.  Being the organizer of the Utah Fedora/Ubuntu Linux Release Party on May 3, its kind of hard to push it back because Ubuntu’s release is still on time.

I’m glad though that the major parts of this release are feature complete and its just a few blocker bugs holding it back.  I’m also really happy to point out that because the folks at the Fedora Project are willing to push the date back, the release will be much better off in the end.

This also goes to show that while many businesses would consider releasing anyway.  Mainly because they promised something, and not releasing would cost them revenue and possible customers.  Open source people don’t follow the same mantra, and I’m proud to say that while I like meeting deadlines, if deadlines slips a little to make a better product, timelines should slip.

In the meantime, enjoy the preview release made available yesterday.  Utah will party with this preview.  Shortly after the party, an update will be made available via yum.  There are some amazing things coming out in a few weeks.  Keep your ear to the ground and enjoy the new Sulphur in your life!

Cheers,

Herlo

» Announcing the Release Candidate for Ubuntu 8.04 LTS

The Ubuntu team is pleased to announce the Release Candidate for Ubuntu 8.04 LTS (Long-Term Support) on desktop and server.  Codenamed “Hardy Heron”, 8.04 LTS continues Ubuntu’s proud tradition of integrating the latest and greatest open source technologies into a high-quality, easy-to-use Linux distribution.

We consider this release candidate to be complete, stable, and suitable for testing by any user.

Ubuntu 8.04 LTS Desktop Edition features incremental improvements to familiar applications, with an emphasis on stability for this second Ubuntu long-term support release, and is easier than ever to try out with the new Wubi installer.

Ubuntu 8.04 LTS Server Edition follows in the footsteps of Ubuntu 7.10 with even more virtualization support and security enhancements - enabling AppArmor for more applications by default, improving protection of kernel memory against attacks, and supporting KVM and iSCSI technologies out of the box.

The Ubuntu 8.04 LTS family of variants, Kubuntu, Xubuntu, UbuntuStudio, and Mythbuntu, also reach RC status today.

The final release of Ubuntu 8.04 LTS is scheduled for 24 April 2008 and will be supported for three years on the desktop and five years on the server.

Before installing or upgrading to Ubuntu 8.04 LTS please read http://www.ubuntu.com/getubuntu/releasenotes/804

About The Release Candidate
—————————
The purpose of the Release Candidate is to solicit one last round of testing before the final release. Here are ways that you can help:

  • Upgrade from Ubuntu, Kubuntu, or Edubuntu 7.10 to the Release Candidate by following the instructions given above.
  • Participate in installation testing using the Release Candidate CD images, by following the testing and reporting instructions at http://wiki.ubuntu.com/Testing/ISO

Desktop Features
—————-
Improved application selection: the GNOME desktop sports a number of improvements to the default applications, including more feature-full clients for BitTorrent and VNC, as well as an advanced UI for mastering CDs and DVDs.

File browsing: an enhanced filesystem layer brings greater performance and flexibility to Nautilus, the GNOME file browser.

Pluggable audio and video output: the PulseAudio sound server is integrated in the GNOME desktop for more flexible sound output, and a new Screen Resolution utility allows easier configuration of multiple video displays.

Wubi installer: a new Windows-based installer option makes it easier than ever to try out Ubuntu, letting users install a full desktop on Windows systems without needing to partition their hard drive.

Server Features
—————
AppArmor profiles: a greater number of server applications are now protected by default with AppArmor, a kernel technology that limits the resources an application is allowed to access, providing added protection against undiscovered security vulnerabilities.

Memory protection: additional protection now prevents direct access to system memory through /dev/mem and /dev/kmem, and the lower 64K of system memory is no longer addressable by default, changes which help to defend against malicious code.  The kernel now also loads Position Independent
Executables at randomized addresses, making it harder for application security vulnerabilities to be exploited.

Virtualization and iSCSI: KVM is now an officially maintained option, which combined with libvirt (CLI) and virt-manager (GUI) management tools allows for a simple and efficient virtualization option on hardware that supports virtualization extensions (AMD-V or Intel-VT).  Mounting iSCSI targets is
now supported (including in the installer), allowing Ubuntu to interoperate with this class of cost-efficient Storage Area Network solutions.

Ubuntu Education Edition
————————
Add-on configuration: Edubuntu is now provided as an add-on to Ubuntu rather than a separate stand-alone flavor, permitting even greater reuse of Ubuntu technologies.

Kubuntu Features
—————-
Kubuntu comes with the rock solid KDE 3 for those who want a commercially supported desktop.

For those who want something more exciting, a KDE 4 Remix is available bringing this cutting edge new version to you first.

Please see https://wiki.kubuntu.org/HardyHeron/RC/Kubuntu for details.

Xubuntu Features
—————-
Xubuntu comes with the light-weight Xfce 4.4.2 desktop environment for those who want to a desktop that is easy to use, but places particular emphasis on conserving system resources.

New Additions To The Family
—————————
Two new variants join us for this Ubuntu release.  UbuntuStudio and Mythbuntu have done releases separately in the past, and with Hardy Heron we’re happy to be able to welcome these fine community projects into the main Ubuntu release process.

For a more in-depth tour of the features new in 8.04 LTS, see http://www.ubuntu.com/testing/804rc

About Ubuntu
————
Ubuntu is a full-featured Linux distribution for desktops, laptops, and servers, with a fast and easy install and regular releases.  A tightly-integrated selection of excellent applications is included, and
an incredible variety of add-on software is just a few clicks away.

Professional technical support is available from Canonical Limited and hundreds of other companies around the world.  For more information about support, visit http://www.ubuntu.com/support

To Get the Ubuntu 8.04 LTS Release Candidate CD
——————————

To perform a new installation or try out 8.04 LTS “live” from CD, download the Ubuntu 8.04 LTS Release Candidate (choose the mirror closest to you):
Europe:

http://ftp.belnet.be/mirror/ubuntu.com/releases/8.04 (Belgium)
http://ubuntu.linux-bg.org/releases/8.04 (Bulgaria)
http://hr.releases.ubuntu.com/8.04 (Croatia)
http://mirror.u-soft.dk/ubuntu-releases/8.04 (Denmark)
http://ftp.crihan.fr/releases/8.04 (France)
http://gb.releases.ubuntu.com/8.04 (Great Britain)
http://ftp.ntua.gr/pub/linux/ubuntu-releases/8.04 (Greece)
http://ie.releases.ubuntu.com/8.04 (Ireland)
http://it.releases.ubuntu.com/8.04 (Italy)
http://nl.releases.ubuntu.com/8.04 (The Netherlands)
http://ftp.snt.utwente.nl/pub/linux/ubuntu-releases/8.04 (The Netherlands)
http://no.releases.ubuntu.com/8.04 (Norway)
http://neacm.fe.up.pt/pub/ubuntu-releases/8.04 (Portugal)
http://es.releases.ubuntu.com/8.04 (Spain)
http://se.releases.ubuntu.com/8.04 (Sweden)

Asia/Pacific:

http://tw.releases.ubuntu.com/8.04 (Taiwan)
http://ubuntu-releases.optus.net/8.04 (Australia)
http://nz.releases.ubuntu.com/8.04 (New Zealand)

Africa:

http://za.releases.ubuntu.com/8.04 (South Africa)

North America:

http://us.releases.ubuntu.com/8.04 (United States)

South America:

http://br.releases.ubuntu.com/8.04 (Brazil)

Rest of the world:

http://releases.ubuntu.com/8.04 (Great Britain)

Please download using Bittorrent if possible.  See https://help.ubuntu.com/community/BitTorrent for more information about using Bittorrent.

Upgrading from Ubuntu 7.10 and Ubuntu 6.06 LTS
———————————————-
To upgrade to Ubuntu 8.04 LTS Release Candidate from Ubuntu 7.10 or Ubuntu 6.06 LTS, follow these instructions:

https://help.ubuntu.com/community/HardyUpgrades

Feedback and Helping
——————–
If you would like to help shape Ubuntu, take a look at the list of ways you can participate at http://www.ubuntu.com/community/participate/

Your comments, bug reports, patches, and suggestions will help turn this release into the best release of Ubuntu ever. Please report bugs through the Launchpad bug tracker: https://bugs.launchpad.net/ubuntu/+bugs

If you have a question, or if you think you may have found a bug but aren’t sure, first try asking on the #ubuntu IRC channel on FreeNode, on the Ubuntu Users mailing list, or on the Ubuntu forums:

http://www.ubuntuforums.org/

More Information
—————-

You can find out more about Ubuntu and about this preview release on our website, IRC channel, and wiki. If you are new to Ubuntu, please visit: http://www.ubuntu.com/

April 17, 2008

Tristan Rhodes
no nic
The Open Source Advocate
» Win the desktop, and you will win the server

Or, "Why Red Hat is pursuing the wrong business strategy"

Red Hat has recently announced that they have "No plans for a traditional consumer desktop". Let me explain why I think Red Hat needs to change their business strategy.

First, a short history lesson. Before the arrival of Windows NT Server, Novell Netware claimed 90% of the market for PC based servers. However, Netware made a near fatal mistake when they did not provide a GUI interface soon enough. This comes from the same Wikipedia page linked above:

While the design of NetWare 3.x and later involved a DOS partition to load NetWare server files, this feature became a liability as new users preferred the Windows graphical interface to learning DOS commands necessary to build and control a NetWare server.
So server administrators became familiar with Windows 95 on their desktop, and they naturally preferred Windows NT 4.0 which included the same interface.

Challenged by Ubuntu

Red Hat is in a similar position to what Novell faced, in that Red Hat is facing a time when server administrators will choose to run their desktop operating system on their servers. Specifically, I believe that Ubuntu will soon become the de facto Linux desktop. This means that server administrators will become familiar with Ubuntu and develop a trust for the brand. Eventually, they may choose to migrate to an Ubuntu standard on servers and desktops.

Most people agree that the real money is in server operating systems. If Red Hat wants to keep capturing that server money, they must provide a supported, free desktop operating system as part of a loss leader strategy.

Fedora is great, but it doesn't solve this problem

Don't misunderstand me, I know that Fedora is an excellent piece of software, but it has two fundamental problems. First, most average computer users do not know that Fedora is sponsored by Red Hat. This means that the Red Hat brand is not directly benefiting from the popularity and success of Fedora.

Secondly, Red Hat does not provide any support for Fedora. This means that many business cannot seriously consider running it on their desktops. How will these business get support if a problem comes up? How will they know that their applications are certified to run on Fedora? What if they want long-term support for older versions, without having to upgrade all the time? All of these questions are being answered by the Ubuntu ecosystem.

Red Hat, let me give you a hint. (If you want more hints, I am always available for consulting). Here it is: Change the name of Fedora to "Red Hat Enterprise Desktop" and begin to sell support for it. If you are lucky, it may not be too late to capture a large percentage of the desktop operating system market.

Remove the need for CentOS

Red Hat, I will even give you one more hint for free. Why do let CentOS steal your thunder? You have already published 99.999% of CentOS (everything except the branding). You graciously publish the source code to RHEL to abide by the GPL, but then you let another brand take credit for your work. How can you fix this? Easy! Simply provide a free version of Red Hat Server that is compiled and ready to be installed. Now your users will see even more of RedHat. RedHat on their desktop, RedHat on their servers, and they can buy support for all of it if they so desire.

April 15, 2008

Tristan Rhodes
no nic
The Open Source Advocate
» Most embarrasing meme ever...

What if this was your response to the command history meme?

$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn
2184 dir
1631 copy
560 edit
486 type
430 makedir
343 move
281 ipconfig
273 deltree
201 erase
164 format
And how come we never see a meme like this?
cat /etc/passwd;sudo cat /etc/shadow;netstat -plunt;ifconfig;sudo iptables -L
Note: Please do not post funny memes if they have destructive commands. The meme above will display private information about your system that should never be posted online.

April 10, 2008
» Ehh, What The Hell

I figure I’d join the band-wagon too, but I’ll use *readable* $() vs the absolutely unreadable-horrible-habit `.  (Yes, that is a `.  What?  You can’t tell what character that is?  Yeah, neither can I when you use it in your code!  Its a back-tick and shouldn’t be used because its unreadable!)

christer@007:~$ history | awk $({a[$2]++ } END{for(i in a){print a[i] " " i}})|sort -rn|head
96 ls
87 vim
70 cd
60 bzr
25 sudo
16 rm
14 ssh
13 grep
13 cat
11 scp

April 8, 2008

Tristan Rhodes
no nic
The Open Source Advocate
» Why do people make software for free?

When I first tell people about open source software, one of the most common questions I get is this:

"I just don't understand why people would create software if they don't get paid for it! How does that work?"
This question makes sense, because we all know that people need to make money to provide for their families. And every good capitalist knows that the profit incentive is what drives people to create and innovate. This is true for many industries, but it does not explain why open source software is created. Here is how I answer this question:

The birth of an open source project

Most open source software projects were created by a programmer who needed a piece of software to accomplish a certain task. Rather than purchasing a commercial software product (assuming that one existed), this programmer decided to create the software from scratch. This programmer might have been paid by their employer to create the software, or the work might have been done on personal time. Instead of hording the newly created software, the programmer decided to share it with the world by publishing it under an open source license.

The birth of an open source community

This is where the open source story gets interesting. It is likely that somewhere else in the world, a second programmer has a need for some software that provides the same functionality. Rather than starting from scratch, this second programmer discovers the open source project that was recently created. This second programmer uses the source code to add new features and fix some bugs that they found in the application. This second programmer then submits these improvements to the first programmer, who gladly accepts them and incorporates them into the original project.

This cycle continues as more and more people start using the software. Most people will simply use the software, but a small percentage will contribute to the project. These contributions will be made by programmers, documentation writers, translators, beta testers, artists, web administrators, and many other important roles.

The birth of an open source business

As the community of users grows into the thousands, the size of the community eventually reaches a critical mass. This happens when a need develops for a commercial entity to provide professional services related to the open source project. This need is driven by businesses who require a support contract before they will use open source software. The commercial open source company is driven by a profit motive, but their success is directly beneficial to the open source community.

The future of an open source project?


I hope this post explains how many open source projects were created, matured, and became supported by open source businesses. Not all open source projects followed this particular evolution, but I think it is the most common life-cycle for open source projects.

What does the future hold for open source? It is always hard to predict the future, but if you have been watching closely you will see that traditional software companies have been investing in or purchasing these commercial open source companies. This means that in the near future, your traditional software vendors will actually be developing open source software, and trying to implement a successful business model based on open source.

April 3, 2008
» Dapper To Hardy Direct Server Upgrade Works!

The other day I thought I’d give the Ubuntu 6.06 LTS to 8.04 LTS direct upgrade path a try on my Ubuntu 6.06 server.  It ran smoothly (over ssh no less), until I ran into one bug at the end.  I reported it, with a reply back the next day.  Two days later it has been fixed and I tried an upgrade again.  I’m happy to say that the direct upgrade path worked perfectly on a fresh install of Ubuntu 6.06 Server.  Here is how I did it:

Ubuntu 6.06 to Ubuntu 8.04 Upgrade (Server)

I verified that my current install was completely up to date:

sudo aptitude update
sudo aptitude upgrade
sudo aptitude dist-upgrade

Also, to be thorough, this is what my sources.list looked like (each ‘deb’ entry should be one single line):

deb http://archive.ubuntu.com/ubuntu dapper main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu dapper-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu dapper-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu dapper-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse

Once I had applied all updates (if you’re already up to date, you don’t need a reboot) I then installed the server-based update utility:

sudo aptitude install update-manager-core

Once this is installed you’re ready to begin the upgrade process.  You can start the upgrade using:

sudo do-release-upgrade -d

note: once Ubuntu 8.04 final is released the -d option will no longer be needed.

At this point it’ll do some checking, verify and update the newer repository and ask you a few questions along the lines of “There is no going back from here, are you sure you want to upgrade?”  After that its smooth sailing.

If you do run into any issues during the upgrade please report them against the update-manager-core package in Launchpad.


=Utah Open Source=
Utah Open Source
The Utah Open Source Foundation
» Utah Open Source Foundation and Ubuntu Utah bring you a release party of gigantic proportion

Fedora 9 (Sulphur) will be released April 29, 2008
Ubuntu 8.04 (Hardy Heron) will be released April 24, 2008

All are welcome to join in the celebration of newly released Fedora and Ubuntu distributions. Ubuntu Utah has been gracious to allow revelers from the Fedora camp join in with the Ubuntu Utah team.  The entire event will be sponsored by the Utah Open Source Foundation who will also provide food.

FOOD IS FIRST COME FIRST SERVE, SO COME EARLY AND COME HUNGRY!

If you’ve never been to a release party, they are a blast, and this one proves to be nothing less than spectacular.  In fact, Code Greene’s owner Mac Newbold has offered up his office (or rather playground) for us to hold our party.  Code Greene has foosball, video games, pool, music and more for all to enjoy.

Why: Release of Ubuntu Hardy Heron (8.04) and Fedora Sulphur (F9)
When:  May 3, 2008, 6-8pm (or thereabouts)
Where: Code Greene, 44 Exchange Place Salt Lake City, UT 84111

Please RSVP via upcoming.org if you are participating.

Cheers,

Clint Savage / Aaron Toponce
UTOSF / Ubuntu Utah

April 1, 2008
» April Fools Reminder

After going through my feeds for the morning I thought I’d post a reminder about April Fool’s.  Geek’s love April Fools.  Don’t believe anything you read today! The way I see it, if the news is still around tomorrow and the next its likely valid, otherwise its an April Fool’s joke.

I’ve seen some pretty tasteless jokes today too.  Shame on you, you know who you are.

March 31, 2008

Kevin Kubasik
nonic
For Once I Oneder
» Sound problems in Ubuntu Hardy

So if your like me, you’ve been suffering through some painful sound problems in Ubuntu Hardy, apparently its a known kernel issue, so just sit tight. However, if your like me (or 90% of nerds) then you need some sort of music to code. A little digging revealed that I did not in fact have any of the alsa kernel modules installed for my current kernel. apt-get left me high and dry (also without an nvidia driver yet, but that’s an easy fix).

The simple remedy is to just build the alsa modules yourself, a pretty painless task. The problem is, if you want to have any hope of keeping your install halfway clean, then you need to get those files tracked by dpkg so we avoid conflicts when the modules are fixed. There’s a simple solution:

sudo apt-get install module-assistant
sudo m-a update
sudo m-a prepare
sudo m-a a-i alsa

This utilizes the handy module-assistant package to automatically build alsa for you. :) Reboot and enjoy!

March 28, 2008
» Plan and Announce Your Release Party!

The release of the next Ubuntu LTS (8.04 “Hardy Heron”) is just around the corner and as a community of Ubuntu members its our responsibility–nay, our obligation– to celebrate!  What are you planning to do for the greatest release to date?

If you’re part of a LoCo Team (you know who you are!) you need to have a release party.  If you’re not party of a LoCo Team you really should be!  Fill a room with geeks, add good food and drinks and toss in a reason to celebrate and who knows what might happen!

I want to remind everyone (particularly those in US Teams) to get cracking and post your release party details online here.

What can we do for a release party?” you might ask.  Well, anything!  It can be as simple as meeting in a coffee shop with a few of your in-real-life buddies and celebrating Ubuntu’s latest achievement.  Perhaps meet up with your LoCo in a pub and have a toast to Ubuntu.  Maybe even go all out and have a big install fest in cooperation with your local university or LUG.  It doesn’t matter.  What does matter is that you’re celebrating the release and having a good time after six months of hard work!

It would be great if you could take pictures while you’re there and post them on blogs (and subsequent planets), flickr–even use twitter to share the fun.  Get the word out about where you’ll be, who can come and what’s involved.  Let’s really make it a big day and make sure the whole interweb hears about it!

If you’re looking for a local release party, or wondering if there is already one being planned, see the hardy release party list.


Aaron Toponce
atoponce
Aaron Toponce
» Ubuntu 8.04 LTS Countdown

March 27, 2008
» My Pet Bug

I’m generally not one to advertise bugs but this has been my pet bug since upgrading to hardy and using Firefox 3b.  I have been putting up with the issue, but I’d *really* like to figure out a fix for it.

I’d be very interested in any feedback the rest of the community can suggest.  Please see my pet bug for details.

February 27, 2008

Aaron Toponce
atoponce
Aaron Toponce
» Managing Services in Ubuntu, Part II: Managing Runlevels

In my last post, I gave you a glimpse to runlevels, their purpose, and how they affect the overall operation of your box. Today, in this post, I am going to dig deeper into runlevels, as well as manipulating services in specific runlevels. I’m going to show you why you want to do this, as well as how. We’ll learn about the ‘update-rc.d’ command mainly, spending a great deal of time with examples and demos.

Before I begin, however, I want to make something painfully clear. Linux gives you the awesome power to completely break your box. I’m talking to the point where not even a backup would work, and you’re left with the task of reinstalling the operating system. However, on the flip side, Linux gives you the awesome power to manage and administer your box. Intense flexibility and unbelievable portability. Today, if you’re following along with the examples given in this tutorial, it is possible to leave your box in an unbootable state, or in a state of undesired operation. Of course, this is not what we want. So, if you are going to follow along, I would recommend following along in an Ubuntu virtual machine. Otherwise, take extra care to follow the tutorial exactly, and all should be well.

Ok, in my last post, I talked about what a runlevel is and what it does to your box. However, I never really mentioned why you should care, or how to to manage a specific runlevel. I plan on discussing those items here. First, is why you should care about runlevels. I’ve seen the argument that runlevels add nothing to your box, and managing services is trivial, so runlevels just add an extra layer of complexity. I disagree. For me, runlevels add a layer of dependability. The whole idea of runlevels is to maintain a level of predictability with your box. I should be able, at any given time during the day, predict what is running on my box. If not, then I’ve given up a level of security. By not knowing how my box is performing, or what it is executing, I’ve opened a door for potential vulnerability. However, if I can predict the state of my box, regardless of time of day, stress it’s under or number of users logged in, then I’ve maintained a level of security and dependability. As such, I’ve done my job well as a system administrator. Runlevels give me that predictability, as well as flexibility in the state I want my box operating under.

As a review, let’s look at the runlevels in Ubuntu:

0: Halt / Shut down.  All processes are stopped, all filesystems are unmounted, and all users taken offline.  Power can now be safely removed.
1: Single user mode.  Only root allowed login (requires password).  All filesystems listed in /etc/fstab are mounted.  Limited set of services started.
2-5: Multi-user mode.  All filesystems listed in /etc/fstab mounted, graphical environment (if installed) brought up.  Full standard operational mode.
6: Reboot.  As with runlevel 0, all processes stopped, all filesystems unmounted, all users taken offline, the box rebooted, and taken to the default runlevel.

If you did your homework in the last post, you probably changed your default runlevel in your /etc/event.d/rc-default file. If you changed this to runlevel 6, you probably noticed a problem: your box infinitely rebooted. Unfortunately, I did not give you a way out in the last post. I’ll do that now.

When booting the box, you can bypass the defined default runlevel by passing ’s’ or ‘S’ as a kernel argument in GRUB. When your box is booting, press the [Esc] key before the timeout ends, and you’ll be taken to the GRUB menu. You’ll have the ability to use your arrow keys to highlight an entry. From there, there is a prompt at the bottom of the menu telling you what you can do to that entry that is highlighted. For example, you can press the ‘e’ key to edit that line. Go ahead, and do that to one of the highlighted entries. You’ll notice that it takes you to a new menu, showing an initrd (initial ramdisk, used by the kernel to load some necessary drivers for the system), the kernel itself, and a memory test for your RAM. Select the kernel entry, and hit the ‘e’ key again to edit the kernel. At the end of the line, enter ’s’ or ‘S’, and press enter. Press the ‘b’ key to boot the kernel now, and you will boot into an sulogin prompt. If you enabled the root account, which is disabled by default on an Ubuntu box, you will be prompted for the root password, WHICH IS IN PLAIN TEXT ECHOED TO THE SCREEN (it’s a bug, we’re working on it). If the root account is not enabled, then you’ll be thrown to a root prompt, at which you can edit your /etc/event.d/rc-default file to change the default runlevel to the appropriate entry.

Woah. Wait a minute. You mean, all I have to do is enter an ’s’ at the kernel line in GRUB, and I get root access to the machine?! Yes. Any box that is physically available can be easily compromised, even with harddrive disk encryption. So, considering the physical security of your box is something that you’ll obviously want to take into account as a system administrator. However, we’re off topic a bit, so let’s get back on target.

Runlevels are nothing more than your box running in a specific state. Fortunately, we can change the desired state that we want our box to be running in by adjusting the runlevel. This is done with the update-rc.d command.

At this point, let’s play with a package for this tutorial. I’ve chosen sendmail as our culprit, so if you don’t already have it installed, run the following command below. If you do have sendmail installed, and would rather use another service package, go for it. We’ll use sendmail in this post:

aaron@kratos:~ 1354 % sudo aptitude -R install sendmail
Password:

In my last post, sendmail was one of the services on my box that was starting when I enter runlevel 2. Maybe I don’t want sendmail to start, or rather, if it is already started, when I enter runlevel 2, I want to kill it. In other words, I don’t want it running for runlevel 2. How can I make this change?

Well, first, I could just delete the soft link from the runlevel directory /etc/rc2.d/:

aaron@kratos:~ 1355 % sudo rm /etc/rc2.d/S21sendmail
Password:

That would definitely keep it from starting when I enter runlevel 2, but what if I wanted to kill it if it was already started from a previous runlevel? Just deleting the soft link won’t do it. I need to turn it into a K-script. Further, deleting and creating soft links in my /etc/rc[0-6].d/ directories by hand is a bit of a pain. This is where the update-rc.d command comes in:

aaron@kratos:~ 1356 % sudo update-rc.d -f sendmail remove
Password:
 Removing any system startup links for /etc/init.d/sendmail ...
   /etc/rc0.d/K19sendmail
   /etc/rc1.d/K19sendmail
   /etc/rc2.d/S21sendmail
   /etc/rc3.d/S21sendmail
   /etc/rc4.d/S21sendmail
   /etc/rc5.d/S21sendmail
   /etc/rc6.d/K19sendmail
aaron@kratos:~ 1357 % sudo update-rc.d sendmail stop 20 0 1 2 3 4 5 6 .
 Adding system startup for /etc/init.d/sendmail ...
   /etc/rc0.d/K20sendmail -> ../init.d/sendmail
   /etc/rc1.d/K20sendmail -> ../init.d/sendmail
   /etc/rc2.d/K20sendmail -> ../init.d/sendmail
   /etc/rc3.d/K20sendmail -> ../init.d/sendmail
   /etc/rc4.d/K20sendmail -> ../init.d/sendmail
   /etc/rc5.d/K20sendmail -> ../init.d/sendmail
   /etc/rc6.d/K20sendmail -> ../init.d/sendmail

We’ll get into the syntax a bit later, but these commands, as observed, removed any existing soft links that previously existed, and created new K-scripts for all of my runlevels.

First off, why two separate commands? Well, by Debian policy, no package upgrade will ever overwrite a previous configuration. This includes updating soft links in the runlevel directories. This also ensures persistent changes and allows the system administrator to prevent daemons from launching. So, if soft links already exist, they first need to be removed, then new links created.

Second, you’ll notice that I need to specifically state when I want the service to start and when I want it to stop during the runlevel process. This is intentional, and offers a great deal of flexibility to the system administrator. Remember, that all the soft links either start with an S for starting the service, or a K for stopping (killing) the service. Each soft link is processed in alphanumeric order, so there is a number following the K or S telling the order in which I want the scripts to execute.

There is something to be said about logic behind the order of when you are starting and stopping services. For example, you may want to restore your firewall before enabling your network device. Further, you may want your network brought up before you begin starting services. Ultimately, the choice is up to you.

Let’s continue with managing our runlevels, and learn the syntax of the update-rc.d command. There are four possible ways in which I can use the update-rc.d command. Let’s start with the first- defaults. As our symlinks already exist, we’ll need to remove them:

aaron@kratos:~ 1358 % sudo update-rc.d -f sendmail remove
Password:
[... snip ...]
aaron@kratos:~ 1359 % sudo update-rc.d sendmail defaults
[... snip ...]

(I’ll be snipping some output from here on out). As we can see, the defaults for sendmail were to stop it at position 20 for runlevels 0, 1 and 6, and to start it at position 20 for runlevels 2 through 5. Actually, position 20 is the default for any package, regardless. This means apache, postfix, squid, ssh, etc. This may not be what we want. Maybe I want to affect sendmail at a different position.

The 2nd possible syntax of the update-rc.d command to to change that default position to another number for all runlevels. Remember to remove our soft links first, then create new ones:

aaron@kratos:~ 1360 % sudo update-rc.d -f sendmail remove
Password:
[... snip ...]
aaron@kratos:~ 1361 % sudo update-rc.d sendmail defaults 10
[... snip ...]

As we can see, I was able to change the position of stopping and starting sendmail from 20 to 10. This affected all runlevels 0 through 6. However, I may not want to affect all runlevels the same. Maybe I want to treat runlevels 0, 1 and 6 differently than 2 through 5.

Which brings us to our 3rd possible syntax for the update-rc.d command- using the default runlevels, but changing when it’s stopped and started. Again, let’s remove our symlinks, and create new ones:

aaron@kratos:~ 1362 % sudo update-rc.d -f sendmail remove
Password:
[... snip ...]
aaron@kratos:~ 1363 % sudo update-rc.d sendmail defaults 10 21
[... snip ...]

As we can see, the default runlevels 0, 1 and 6 were changed to stop sendmail at position 21, and the default runlevels 2 through 5 were changed to start sendmail at position 10. So, I can change the starting and stopping position using the default runlevels. Cool.

Finally, let’s look at our last usage of the update-rc.d command: full flexibility of when I start and stop the service in each individual runlevel. I bet you haven’t forgotten to remove your soft links before creating new ones, have you:

aaron@kratos:~ 1364 % sudo update-rc.d -f sendmail remove
Password:
[... snip ...]
aaron@kratos:~ 1365 % sudo update-rc.d sendmail start 10 2 3 . start 20 4 5 . stop 19 0 1 6 .
[... snip ...]

Here, as we can see, I affected the starting position for sendmail in runlevels 2 and 3 to be 10. For runlevels 4 and 5, I wanted sendmail to be at position 20. Finally, for runlevels 0, 1 and 6, I wanted to kill sendmail at position 19. You’ll also notice that the syntax is fairly straight-forward:

update-rc.d [service] start|stop [position] [runlevel] [runlevel] [runlevel] … [.]

The first argument, as has been consistent up to this point, is the service. Then, I mention whether or not I want to create K-scripts or S-scripts by calling either the start or stop option. Both start and stop have a set of arguments, the first being the position I’m going to affect. Then, following the position, I give a space-separated list of runlevels followed by a ‘.’ (dot) to terminate either that start or stop call.

Let’s look at a couple more examples of this 4th syntax, so we can get a better feel for it:

aaron@kratos:~ 1366 % sudo update-rc.d -f sendmail remove
Password:
[... snip ...]
aaron@kratos:~ 1367 % sudo update-rc.d sendmail start 45  2 3 4 5 . stop 1 0 1 6 .
[... snip ...]

The above example starts sendmail at position 45 for runlevels 2 through 5 and stops sendmail at position 1 for runlevels 0, 1 and 6. I should probably point out, that you most likely don’t want to start a service for runlevels 0 and 6, for obvious reasons. One more example:

aaron@kratos:~ 1368 % sudo update-rc.d -f sendmail remove
Password:
[... snip ...]
aaron@kratos:~ 1369 % sudo update-rc.d sendmail stop 0 0 1 2 3 4 5 6 .
[... snip ...]

In that example, I set sendmail to stop at position 0 for all runlevels, thus effectively disabling the service, regardless of the state of my box. If I wanted sendmail to start, I would need to call it directly:

aaron@kratos:~ 1370 % sudo /etc/init.d/sendmail start
Password:
 * Starting Mail Transport Agent (MTA) sendmail                          [ OK ]

One final note about managing runlevels. All this is fine and dandy with the update-rc.d command, however, we’re just removing and creating soft links. We are not affecting the running process at all. In other words, just because I’ve configured sendmail to start in runlevels 2-5 doesn’t mean that I’ve started the service. If sendmail is not running, I will still have to start it by hand. Same goes for creating K-scripts in those directories. The service won’t be stopped because I have created those K-scripts. I’ll still have to stop it by hand. All we’re doing is affecting if it starts or stops when I enter a new runlevel.

There is some philosophy about when to start and stop services, and definitely some logic behind the order. However, the position at when to start and stop these services is entirely up to you. If you find that you’re starting a service too early (or too late), change the soft links. It may be of interest to you to start your X display manager first, before starting services. Now that you’re familiar with the update-rc.d command, you know how to do this (this approach may have some consequences as some services, such as xfs or gdm may provide dependency to X).

At this point, we’ll stop here with this post in the series, and pick up again tomorrow with more service management. If you followed both of these posts, you should be fairly comfortable with runlevels, and managing when to start and stop services in specific runlevels. You’re turning into a system adminstrator.

February 26, 2008

Aaron Toponce
atoponce
Aaron Toponce
» Managing Services in Ubuntu, Part I: An Introduction to Runlevels

As many of you are probably already aware, I’m a Linux trainer for Guru Labs. We do all Linux training, including Red Hat, Fedora, SUSE, and others. If your company is looking for good, solid Linux training, Gurus at Guru Labs are the cream of the crop, and I’d highly recommend it. I’ve been doing a lot of Red Hat training lately, and during the training, I cover how to manage services on a Red Hat system. Lately, I’ve been meaning to translate this over to Ubuntu, and put it in a series of posts. As a result, the subject of this post is all about learning runlevels, and how to manage services effectively, such as Apache, Squid, SSH, and so on, in Ubuntu. So, let’s get started.

First off, to understand services, we need to understand runlevels. Runlevels are a way to automatically start and stop services, thus effectively controlling what is running on your box. When you enter a specific runlevel, you are telling your box that you want to stop a specific set of services and/or start a specific set of services. In other words, think of runlevels as categorizing your system. For example, if I enter runlevel 1, I may want to tell my box to go into “single user mode”, thus effectively knocking everyone off except for the root user. Also, I may want to stop all services, including networking, taking my box off the network for troubleshooting reasons. Thus, stop Apache, Squid, SSH, and so on, leaving my box in maintenance mode.

On all Linux and Unix systems, runlevels are treated differently. For example, runlevels in Red Hat have different meaning than runlevels in OpenBSD which have a different meaning than Solaris which finally have a different meaning for Ubuntu. Of course, in this post, I’m only gong to worry about Ubuntu runlevels. If you’re curious about the runlevels on other systems, there is a great page here dscribing the differences.

So, let’s look at the runlevels that affect Ubuntu. They are as follows:

0: Halt / Shut down.  All processes are stopped, all filesystems are unmounted, and all users taken offline.  Power can now be safely removed.
1: Single user mode.  Only root allowed login (requires password).  All filesystems listed in /etc/fstab are mounted.  Limited set of services started.
2-5: Multi-user mode.  All filesystems listed in /etc/fstab mounted, graphical environment (if installed) brought up.  Full standard operational mode.
6: Reboot.  As with runlevel 0, all processes stopped, all filesystems unmounted, all users taken offline, the box rebooted, and taken to the default runlevel.

Ubuntu does have one extra special runlevel that in processed before entering any of the regular runlevels above. It’s known as ’sulogin’, and it is considered an emergency mode if the system will not boot, or there are other troubles. it is denoted by “S” as it’s runlevel characterization. We will not worry about runlevel S in this post.

Each Unix and Linux operating system has a default runlevel in which it will boot into. If init is the daemon manager for your system, then you will find an /etc/inittab file that will specify your default runlevel. However, Ubuntu has replaced init with Upstart, an event-driven daemon manager. As such, there is no /etc/inittab file. However, there is an /etc/event.d/rc-default file, which as probably guessed, specifies your default runlevel. Let’s take a look at the file:

aaron@kratos:~ 1346 % cat /etc/event.d/rc-default
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.

start on stopped rcS
 
script
        runlevel --reboot || true
 
        if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
            telinit S
        elif [ -r /etc/inittab ]; then
            RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
            if [ -n "$RL" ]; then
                telinit $RL
            else
                telinit 2
            fi
        else
            telinit 2
        fi
end script

Parsing through that file, we see that first, it tests to see if we are running in runlevel S, or ’sulogin’. If not, then we have a series of checks to find our default runlevel. The first check is to see if there is in fact an /etc/inittab file existing. If so, we look for the line that says “id:?:initdefault:”, where “?” could be any valid number 0 through 9. If that number exists, it is our default runlevel, otherwise, runlevel 2 will be our default, as none of the checks would pass.

So, as discovered, runlevel 2 is the default runlevel on Ubuntu. Furthermore, runlevels 2 through 5 are all exactly the same by default. Thus, entering runlevel 4 will have no effect on your box if already running in runlevel 2. What’s the point of having so many if they’re the same then? Well, a few reasons. First, if you followed that link above, showing the different runlevels on different systems, 0 through 6 is not uncommon, and many of the Unices and Linuxes take advantage of every one of them. So, I guess you could say they’re present for historical reasons. However, having that many runlevels gives the system administrator the flexibility to manage a specific runlevel at his/her convenience. For example, maybe runlevel 2 should be treated differently than 3 through 5, starting a different set of services than the rest. Maybe I don’t want runlevel 2 to start the graphical mode, but keep it text-based only. This could be useful in troubleshooting my graphical display without it running. You get the idea.

Ok, fine. The next question inevitably asked, is how can I tell what runlevel I’m currently in? Simple, just run the ‘runlevel’ command:

aaron@kratos:~ 1347 % runlevel
N 2

“N” tells me that there was “None” for my previous runlevel. In other words, this box was just booted into my current runlevel, which I can see as the 2nd identifier, “2″. This is one thing that you may like or hate about the ‘runlevel’ command, but it only shows you your current runlevel and the previous runlevel. No more, no less. However, generally, this is sufficient.

As such, the next question you are probably asking yourself, is how do I change runlevels? This is done with the ‘telinit’ command. The command tells Upstart, our services manager, what services to stop and start when we enter a specific runlevel. For example, if I wanted to reboot my box from the command line, knowing that runlevel 6 is a reboot, I could enter, as root:

aaron@kratos:~ 1348 % sudo telinit 6
Password:

Ok. So, now we’ve learned what runlevels are, how to check my current running runlevel, and even how to change to a different runlevel. The next concept in this post is to see what runlevels are doing to the system under the hood. In other words, how does the system know that I want to knock everyone off the box except for root in runlevel 1? How does the system know to start the graphical display in runlevels 2 through 5? The answers to these questions lie in simple shell scripts.

Each runlevel has it’s own directory, which contains what we call “K-scripts” and “S-scripts”. These directories reside in /etc. In fact, let’s get back to our terminal, and type the following, noticing the output:

aaron@kratos:~ 1349 % ls -ld /etc/rc*/
drwxr-xr-x 2 root root 4096 2008-02-16 18:06 /etc/rc0.d/
drwxr-xr-x 2 root root 4096 2008-02-16 18:06 /etc/rc1.d/
drwxr-xr-x 2 root root 4096 2008-02-16 18:06 /etc/rc2.d/
drwxr-xr-x 2 root root 4096 2008-02-16 18:06 /etc/rc3.d/
drwxr-xr-x 2 root root 4096 2008-02-16 18:06 /etc/rc4.d/
drwxr-xr-x 2 root root 4096 2008-02-16 18:06 /etc/rc5.d/
drwxr-xr-x 2 root root 4096 2008-02-16 18:06 /etc/rc6.d/
drwxr-xr-x 2 root root 4096 2007-10-15 17:36 /etc/rcS.d/

That’s interesting. I have directories that have the same number as runlevels. Could this be a coincidence? Hardly. When I enter “telinit 4″ on the command line, for example, I’m telling Upstart to enter /etc/rc4.d, and execute the K-scripts and S-scripts found in that directory in a specific order. Same goes for entering “telinit 2″, “telinit 0″ or “telinit 6″. Every directory having a specific set of shell scripts that it’s going to execute. So, let’s dig into one of these directories. Let’s start with /etc/rc0.d/:

aaron@kratos:~ 1350 % ls /etc/rc0.d/
K01gdm           K20postfix                          S15wpa-ifupdown
K01usplash       K25hwclock.sh                       S20sendsigs
K16avahi-daemon  K50alsa-utils                       S30urandom
K16dhcdbd        K59mountoverflowtmp                 S31umountnfs.sh
K18consolekit    K99laptop-mode                      S40umountfs
K19sendmail      README                              S60umountroot
K20apport        S01linux-restricted-modules-common  S90halt

Here, I can see only 20 scripts and a README file listed. I notice further that I have my K-scripts and S-scripts that I’ve mentioned earlier. In fact, the K-scripts and S-scripts are numbered. This has to do with order in which to execute those scripts. Let’s look at them in detail. First, Upstart is going to execute the K-scripts then it will execute the S-scripts. K-scripts stop a service, while S-scripts start a service. So, the first script it will execute when it enters this directory is “K01gdm”. This script manages my graphical display. In other words, I’m going to kill my X session before doing anything else. Next, I’ll stop usplash followed my avahi-doemon, etc.

Once all the K-scripts are executed, then I execute the S-scripts. Just as with the K-scripts, they are also executed in order. So, the first script I start is “S01-linux-restricted-modules-common”. This script manages my restricted drivers for the kernel, returning nothing more than the exit code for /sbin/lrm-manager, and logging the result. Looking further, I have “S15wpa-ifupdown” which is managing my WPA helper library for wireless devices. We notice further that the last script executed in this directory is “S90halt”, which shuts the box down fully. Each of those scripts, as mentioned before, are just shell scripts, and can be opened with any text editor. If you’re curious about what a script is doing, open it up and read it.

Let’s look at runlevel 2 this time:

aaron@kratos:~ 1351 % ls /etc/rc2.d
README                       S20hotkey-setup   S30gdm
S05vbesave                   S20makedev        S50ntp
S10acpid                     S20nvidia-kernel  S89anacron
S10powernowd.early           S20postfix        S89atd
S10sysklogd                  S20powernowd      S89cron
S10xserver-xorg-input-wacom  S20rsync          S98usplash
S11klogd                     S21sendmail       S99acpi-support
S12dbus                      S22consolekit     S99laptop-mode
S12hal                       S24avahi-daemon   S99rc.local
S19cupsys                    S24dhcdbd         S99rmnologin
S20apport                    S25bluetooth      S99stop-readahead

First off, we may notice that there are no K-scripts in the runlevel 2 directory. In other words, we aren’t interested in stopping any services when we enter runlevel 2. Rather, we are only interested in starting services. Second, we may notice a logical order to the scripts. For example, we start power management right out the gate with S10acpid and S10powernowd.early. Next, we start S10sysklogd, which is our generic logging daemon for logging services. It makes sense to start this daemon before starting specific services, as if they fail to start, I will have a log as to the reason. Also notice that anacron is starting before cron (S89anacron to S89cron). This makes sense, as we want to run any cron jobs that weren’t run before running them again. The other daemons start in their numerical order as specified.

Looking in that directory is a bit deceptive, however. Although we see our K-scripts and S-scripts in each directory, they are actually not separate scripts. They are one script actually residing in /etc/init.d/. Let’s take a look:

aaron@kratos:~ 1352 % ls -l /etc/rc2.d
total 4
-rw-r--r-- 1 root root 556 2007-10-04 05:17 README
lrwxrwxrwx 1 root root  17 2008-01-09 00:45 S05vbesave -> ../init.d/vbesave
lrwxrwxrwx 1 root root  15 2008-01-09 00:45 S10acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root  25 2008-01-09 00:45 S10powernowd.early -> ../init.d/powernowd.early
lrwxrwxrwx 1 root root  18 2008-01-09 00:45 S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx 1 root root  34 2008-01-09 00:45 S10xserver-xorg-input-wacom -> ../init.d/xserver-xorg-input-wacom
lrwxrwxrwx 1 root root  15 2008-01-09 00:45 S11klogd -> ../init.d/klogd
lrwxrwxrwx 1 root root  14 2008-01-09 00:45 S12dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root  13 2008-01-09 00:45 S12hal -> ../init.d/hal
lrwxrwxrwx 1 root root  16 2008-01-09 00:45 S19cupsys -> ../init.d/cupsys
lrwxrwxrwx 1 root root  16 2008-01-09 00:45 S20apport -> ../init.d/apport
lrwxrwxrwx 1 root root  22 2008-01-09 00:45 S20hotkey-setup -> ../init.d/hotkey-setup
lrwxrwxrwx 1 root root  17 2008-01-09 00:45 S20makedev -> ../init.d/makedev
lrwxrwxrwx 1 root root  23 2008-01-09 00:45 S20nvidia-kernel -> ../init.d/nvidia-kernel
lrwxrwxrwx 1 root root  17 2008-02-16 15:44 S20postfix -> ../init.d/postfix
lrwxrwxrwx 1 root root  19 2008-01-09 00:45 S20powernowd -> ../init.d/powernowd
lrwxrwxrwx 1 root root  15 2008-01-09 00:45 S20rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root  18 2008-02-16 18:06 S21sendmail -> ../init.d/sendmail
lrwxrwxrwx 1 root root  20 2008-01-09 00:45 S22consolekit -> ../init.d/consolekit
lrwxrwxrwx 1 root root  22 2008-01-09 00:45 S24avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root  16 2008-01-09 00:45 S24dhcdbd -> ../init.d/dhcdbd
lrwxrwxrwx 1 root root  19 2008-01-09 00:45 S25bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root  13 2008-01-09 00:45 S30gdm -> ../init.d/gdm
lrwxrwxrwx 1 root root  13 2008-01-12 13:41 S50ntp -> ../init.d/ntp
lrwxrwxrwx 1 root root  17 2008-01-09 00:45 S89anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root  13 2008-01-09 00:45 S89atd -> ../init.d/atd
lrwxrwxrwx 1 root root  14 2008-01-09 00:45 S89cron -> ../init.d/cron
lrwxrwxrwx 1 root root  17 2008-01-09 00:45 S98usplash -> ../init.d/usplash
lrwxrwxrwx 1 root root  22 2008-01-09 00:45 S99acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root  21 2008-01-09 00:45 S99laptop-mode -> ../init.d/laptop-mode
lrwxrwxrwx 1 root root  18 2008-01-09 00:45 S99rc.local -> ../init.d/rc.local
lrwxrwxrwx 1 root root  19 2008-01-09 00:45 S99rmnologin -> ../init.d/rmnologin
lrwxrwxrwx 1 root root  24 2008-01-09 00:45 S99stop-readahead -> ../init.d/stop-readahead

Ahh. We can see that each script in the /etc/rc2.d/ directory is actually a soft link pointing to a script of the same name in the /etc/init.d/ directory. This is consistent with /etc/rc[0-6].d/ directories as well. Every file in those directories just pointing to a single script residing in /etc/init.d/. This makes it easy to manage runlevels, as I’m sure you could guess. Because there is only one script, I can create symbolic links in each runlevel directory to start and stop that specific service. As mentioned before, if it’s a K-script, it will stop the service in /etc/init.d/, if it’s an S-script, it will start the service in /etc/init.d/. This would be the same as calling the script directly:

aaron@kratos:~ 1353 % sudo /etc/init.d/sendmail start
Password:
 * Starting Mail Transport Agent (MTA) sendmail                          [ OK ]

The above is exactly the same as S21sendmail in the /etc/rc2.d/ directory. In fact, if you call the script directly, with no arguments, you can see that it contains a list of valid options, where start and stop are the only requirements:

aaron@kratos:~ 1354 % sudo /etc/init.d/sendmail
Password:
Invalid command <>
Usage: /etc/init.d/sendmail <command>
        Where <command> is one of the following
          start|stop|restart|restart-if-running
          reload-if-running|reload|force-reload
          newaliases|hoststat|purgestat|mailstats|mailq|runq|control
          status|debug|clean

As we can see, the sendmail script has start, stop, restart, restart-if-running, reload-if-running, reload, force-reload, newaliases, hoststat, purgestat, mailstats, mailq, runq, control, status, debug and clean as valid arguments. However, we’ll talk more about the /etc/init.d/ directory in the next post in this series. For now, suffice it to say that the /etc/init.d/ directory contains all my shell scripts that a bunch of soft links point to from /etc/rc[0-6].d/. Specifying a runlevel to enter just means to either call the /etc/init.d/ script with a start option, or with a stop option, pending on whether or not it is an S-script or K-script respectively.

This is a good stopping point before continuing on to the next part of the series: Controlling Runlevels. Hopefully now, you understand the different runlevels, how to enter a runlevel, and what a specific runlevel is doing to your box. We looked at the various commands for identifying what runlevel the box is running in and how to change runlevels. We looked at some shell scripts, seeing what arguments are available when calling a daemon directly, and we found out how to tell what our default runlevel is. In other words, you should be fairly fluent on identifying runlevels now.

For the second post in this series, we’ll talk about how to manage those runlevels, giving us the flexibility to control exactly what is started and stopped when I enter a specific runlevel. We’ll pretty much be spending our entire time on one command, running through lots of examples.

I now have some homework for you to familiarize yourself with the concept of runlevels:

1) Spend some time looking through the various /etc/rc[0-6].d/ directories, identifying K-scripts and S-scripts.  Do not make any changes or modify any files.
2) Open up and read the shell scripts found in those directories, and see if you can figure out what is happening with each daemon when that script stops or starts the service.
3) Spend some time changing runlevels with the ‘telinit’ command, and see how it affects your box.
4) Change your default runlevel by changing the /etc/event.d/rc-default file (MAKE A BACKUP BEFORE CHANGING THE FILE).  Reboot your box, to see if it worked.
5) If you have access to a Fedora or Red Hat-based distribution, see how the runlevels differ, and see if you can do the previous 4 steps with that distro as well.

February 8, 2008

Joseph Hall
no nic
blog.josephhall.com
» Context Menu Extensions for Firefox

This morning I stumbled upon something interesting in Firefox. I clicked on Tools >> Add-ons >> Get Ubuntu Add-ons. One of the items available for installation was called "Context Menu Extensions for Firefox/Iceweasel". It promised, among other things, the ability to add custom items to context menus (aka the "right-click menu") in Firefox, including external programs. I've long wanted something like this, so I decided to take a look.

I checked the box and clicked Apply. It looked like it was doing something, but when it finished the menu option was gone, and I couldn't find any trace of it having installed anything. I bit of searching and hassling Christer led me to discover that the package name in both Debian and Ubuntu was actually called mozilla-ctxextensions. I also discovered that I should have new menu options under my Tools menu, but I couldn't find any.

I tried running "aptitude install mozilla-ctxextensions", but it said it was already installed. I ran "updatedb; locate ctx-extensions" and only found one file: /usr/share/app-install/desktop/mozilla-ctxextensions.desktop. That file didn't give me any hints to anything. I ran "aptitude remove mozilla-ctxextensions" and then installed it again. This time locate found lots of files, so I figured I must be good to go. Unfortunately, restarting my browser still revealed no extra options.

I finally found what looked to be the problem. When it installed, it created a symlink called /usr/lib/iceweasel/extensions/{4C4D8A1D-1E3C-439e-9298-16073A5C4851} that pointed to /usr/share/mozilla-extensions/ctxextensions. No such link existed in /usr/lib/firefox/. So much for having it work in both Iceweasel and Firefox. I made another symlink with the same name, pointing to the same location, in the /usr/lib/firefox/extensions/ directory and restarted Firefox. Bingo!

Not only do I have extra options in my Tools menu, I also have an additional Extensions menu. Looking through the preferences, this looks like an extremely customizable tool. And in the spirit of open source, I have been able to find absolutely no documentation as of yet, except for a few random bug reports from Debian developers saying that they won't fix something or other with it. I was able to find the author's homepage, http://piro.sakura.ne.jp/, which is of course mostly in Japanese.

Has anyone else played with this tool? I'm interested in using it, but it would be nice to have some documentation to save me some time in learning it.