Stream of Ry

Yet Another Geek In The World

Archive for the ‘linux’ tag

Linux startup process from 30k-feet high

leave a comment

Here’s a nice explanation of the (Debian) boot process (from the Debian Administration)

There are a lot of misconceptions voiced here about the sysvinit system. It is complex because it HAS to be. To quote Eistein, “Make things as simple as possible, and no simpler.”

Sysvinit is the best way known to manage all the complexity involved in making any combination of the 10,000+ Debian packages load the various daemons they need, in the order they need, only to the extent they are installed, and have them all work smoothly together. The older BSD init system was simpler, but less capable– the init scripts had to be edited for every package you added that needed to start at boot time, and the order was always a potential source of a problem. That is why most Linux distributions use sysvinit– it has proven its value over many years.

Each package that needs to load at a certain runlevel puts one script in /etc/init.d, usually named with the package name. This allows you to start, stop, restart, reload, etc. it by typing “/etc/init.d/mypackage start” (or stop or reload or whatever). If you write a script, use others as a template, and change what you need to change. Test the script by typing these commands manually (probably at a root shell). If the script works properly here, it should work in runlevels. However, to answer the last plea for help, this script does NOT start anything automatically at ANY runlevel. We still need one more thing for that.

To do that, we create symlinks to these scripts in the various runlevel directories. For example, if we normally run at runlevel 2 (as Debian does by default) and we want mypackage to run as start, then create two links in /etc/rc2.d, one named S99mypackage and one named K99mypackage. S means Start, and K means Kill (stop) the process. When the system goes into runlevel 2, all the start links in /etc/rc2.d will be run one after another. The 99 tells the system WHEN it should be run– they run in numerical order from 01-99 (and in alpha order within those numeric levels, I think). So 99 will be run last, and everything should basically already be up by then, usually a good choice for your personal stuff. But if you want it run before thing1 and after thing2, then pick a more appropriate number. If you want it started first and stopped last, then name the links S01mypackage and K99mypackage. You can also disable the link temporarily by renaming the uppercase S or K to lowercase– only the uppercase letters will be run.

As to “why so many runlevels, if Debian only uses two?”– you can use them any way you want. Runlevel S (or 1) is single-user maintenance mode (which may not even mount your disks). Runlevel 2 (in Debian) is multi-user. Some distributions once used runlevel 3 for networking, or 5 for X windows. Now both (networking and X) seem to be nearly universal, and are not usually put on separate runlevels. But if you want to do that, you can. It’s your system, do what you want. Maybe you have a system needs to be configured differently at home and work, or when the kids are using it. You can set runlevels for these different modes.

If you want the simpler “just run this at boot time” of BSD, just add your script to the /etc/rc.local script which runs after the rest of the boot process is complete. So you CAN have it both ways.

Hope this clears up some of the confusion. I’d say RTFM, but sometimes the manuals are long on detail and short on 30,000 foot-level explanation of the concepts.

Written by rystraum

July 6th, 2010 at 6:10 pm

Forcing monitor to sleep from keyboard

leave a comment

One thing I’d like you to know about me is that I’m lazy.
In fact, lazy enough that the extra step of extending my hand from the keyboard to my monitor to turn it off before I go out for a bit (and doing the reverse when I come back) is already bothersome for me.

So, in typical Linux fashion, I looked for a way to force my monitor to sleep.. and map it on my keyboard.

In System > Preferences > Keyboard Shortcuts, I have:

Name: Monitor Sleep
Command: xset +dpms dpms force off

and I mapped it to, aptly, Pause / Break.. which is what I do when I press the button.

Try the command via CLI first before mapping it since I’m not sure if it came with the default X11 installation. If not, you can install it via:

# apt-get install x11-server-utils

Laziness is a virtue, methinks.. sometimes. D:

Written by rystraum

June 13th, 2010 at 8:11 pm

Posted in Software

Tagged with , ,

Youtube MP4 files to m2ts

one comment

So, I got the 1080p version of Taeyang – Wedding Dress (really sad MV there) and decided that I’d stream it (via VLC) to our Canmore. However, the transcoding is rather inefficient and thus a lot of frames are being dropped. VLC even makes it a point to tell me that my CPU is slow T_T. I decided to just convert the thing to m2ts and copy it over instead of streaming it via the network.

ffmpeg -i ~/Videos/WeddingDress.mp4 -f mpegts -vcodec libx264 -b 3721216 -bf 2 -acodec libfaac -ab 131072 -y /home/rystraum/wd.m2ts

-b and -ab should be adjusted according to the video and audio bitrate accordingly. libx264 and libfaac are the video and audio encoders for h264 and aac, respectively. The ffmpeg version that comes with VLC doesn’t have them out-of-the box and requires a recompile from source.

I should be able to enjoy my HD Youtube downloads now (after transcoding everything). :D

Written by rystraum

June 13th, 2010 at 10:56 am

Posted in Software

Tagged with , , , , ,

Setting shortcut keys for Rhythmbox

leave a comment

I used to avert using Rhythmbox as my music player and usually resorts to VLC. Today, however, I just wanted a shuffle play of my whole music files and decided to use Rhythmbox for it.

It’s actually convenient enough since it’s integrated with Ubuntu already so it neatly stays at my taskbar. There was a catch though, it did not have shortcut keys support (at least, out of the box, it doesn’t)

It’s easy enough to add though, through System >> Preferences >> Keyboard Shortcuts.

Just add a new shortcut, mine’s:

Name: Rhythmbox Next
Command: rhythmbox-client --next


Name: Rhythmbox Play-Pause
Command: rhythmbox-client --play-pause

and then assign a shortcut key/combination for it. That easy!

A bit of a background:
rhythmbox-client is a CLI utility that controls a running Rhythmbox instance. You can view all the other different options through the man pages.

man rhythmbox-client

Written by rystraum

June 13th, 2010 at 7:13 am

Posted in Software

Tagged with , , ,

Ubuntu workarounds / fixes — 1 of many

one comment

This is mostly a personal list of fixes I encountered (whether by via compiling or daily usage) and I’ll try to post the link to where I got the fix from, as much as I can.

Read the rest of this entry »

Written by rystraum

May 12th, 2010 at 9:57 am