Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Custom Runlevels and Console Login

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
mojoman
Posts: 598
Joined: 2006-10-15 18:43
Contact:

Re: Custom Runlevels and Console Login

#16 Post by mojoman »

Thanks for this howto. I set up a console login by altering runlevel 3 using sysv-rc-conf and editing grub. Quite useful and very easy.
/mojoman
http://www.debianuserforums.org
By the community. For the community.

Polaris96
Posts: 555
Joined: 2009-06-17 18:37

Re: Custom Runlevels and Console Login

#17 Post by Polaris96 »

This is an old time UNIX trick for adjusting runlevels:

The basic idea is that you don't want to alter rc*.d any more than you absolutely have to. You do this by never erasing anything from rc*.d. Instead, you prepend a neutral character to the link name. Using underscore "_" for this purpose is the usual etiquette. Here's how it works:
~/#mv S99sshd _S99sshd
The preceeding command changes the title of the symlink "Start Process number 99 as secure shell server (sshd)" to "ignore this link"
This is because when init runs through rc*.d it only cares about starting processes prepended with an 'S' and shutting down processes prepended with a 'K'.
By using this technique you never have to remember what you started with and it gives you a neat "toggling ability" to tweak out your runlevel.

I don't know if it's widely used in debian, or in LINUX, generally. But it works just fine and it's a very sane way to work. I also like it very much, even now, because your only using mv, ls, su, and cd to do all your work. If you like KISS, I really don't know of a better way.

And thanx very much to GOfree for digging into the grub menu.lst options - I didn't know you could hang a run level at the end of the boot list. It's a very elegant way to do it.
for as long as the world remains. for as long as time remains. so, too, will I remain. To serve. To help. And to make my contribution. Also, never forget our family at debianuserforums.org If we can't solve your problem, they probably can.

User avatar
GOfree
Posts: 80
Joined: 2009-05-23 05:45

Re: Custom Runlevels and Console Login

#18 Post by GOfree »

--> Polaris96:

Hey, that makes sense. Sounds easy.

I think I will try that on one of the spare runlevels, and see how it goes.

It's great that there are always so many different ways to do things. Your way seems pretty safe.

Thanks for the suggestion!

G

Polaris96
Posts: 555
Joined: 2009-06-17 18:37

Re: Custom Runlevels and Console Login

#19 Post by Polaris96 »

Glad to contribute.
for as long as the world remains. for as long as time remains. so, too, will I remain. To serve. To help. And to make my contribution. Also, never forget our family at debianuserforums.org If we can't solve your problem, they probably can.

Polaris96
Posts: 555
Joined: 2009-06-17 18:37

Re: Custom Runlevels and Console Login

#20 Post by Polaris96 »

This is a fun "alternative use" for runlevels. You can set up a basic terminal as your primary runlevel (RL 3 say). Then bump your x11-common and your GUI login links into an empty adjacent runlevel:

Code: Select all

su
cd /etc/rc4.d
rm *
cp -P /rcS.d/S[whatever it is]x11-common /etc/rc4.d/S20x11-common
mv /rcS.d/S[whatever it is]x11-common /etc/rcS.d/_S[whatever]x11-common
cp -P /rc2.d/S[whatever it is]kdm /etc/rc4.d/S30kdm
There's a bit of nuance, here. First, notice the -P flag in the cp calls. That preserves the symlinks. Everything in your rcN.d directories should be links not files. If you don't use cp -P the shell will follow the links into init.d and copy the shell scripts instead of the symlinks. It wil still work but it's WRONG and you shouldn't do it.

Notice I "toggled off" the x11-common link in rcS.d. This is to keep the terminal slick. You don't need anything X in a pure terminal so why load it? Remember you're loading rcS.d no matter what runlevel you use. If you had previously removed it from rcS.d when you built your custom rl, you just need to copy the link from an rc directory that has it.

Alternatively, you could use the ln -s command to create a link to the script in init.d. This is the "proper" way, but either will work and I'm trying to keep the directions simple.

Notice, finally, that I'm calling kdm(KDE) as my GUI. yours may be different (gnome will be gdm).

Also, I named the first link S20 not S10. This isn't standard UNIX practice, but I've found it's a good thing to leave lots of margin for sticking in extra links when you're building your own runlevels. I could add 20 elements to the top of the list before I need to rename all my links. That's convenient.

To launch the GUI from runlevel 3 is easy:

Code: Select all

su
telinit 4
one interesting use for this is switching between WMs. If you're unning gnome and want to play around with, say enlightenment, you can hang gdm on rl4 and e16 on rl5. Remeber you can add more runlevels than the standard 6 if you want. I wouldn't, though. It's best to keep your system relatively standard in the broad strokes.

If you like playing with scripts. This would be the perfect place for a BASH menu to select which (if any) WM the user would like to launch. Just leave all the WM links in rc4.d but "toggled off" and gen up a script to "toggle on" the selected item and then telinit 4. THAT would be both useful and very sane to another admin's eye.

This is intended more as an exercise than a final topology. But it's fun to play with. cheers
for as long as the world remains. for as long as time remains. so, too, will I remain. To serve. To help. And to make my contribution. Also, never forget our family at debianuserforums.org If we can't solve your problem, they probably can.

Post Reply