Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133
Rep:
Allow unprivileged users to change runlevel
I have a Gentoo server that I occasionally have users who also need to use it as a desktop. Although it's not terribly short on RAM I don't like to have the X desktop running unless it's really needed, so the initdefault is 3. However I have unprivileged users who need to be able to start X (as well as ALSA services) by changing to runlevel 5.
A simple SUID script would theoretically work, but of course when I make one and try to execute it, the shell doesn't execute it directly, instead executing the interpreter (which has normal permissions) with the suid script as an argument, meaning the suid bit has no effect.
I just need a simple way for users to change to runlevel 5 without giving them root access. I've even tried compiling a tiny SUID C program that runs system("/sbin/init 5"); but it doesn't work and I'm not sure why.
I know I could do this easily with Sudo but I don't want to install that if I don't have to, because the machine already has more junk on it than I'd prefer. Is it possible to do this without it, or should I just suck it up and emerge sudo?
X will be started, and if I understand correctly not usually be used on your system.
If memory is tight, the kernel will send it to swap if noone is using it: No significant performance hit, apart form the kernel saying "I need some more RAM, what isn't being used..... X, so I'll swap it out".
When your user(s) need it, it'll be swapped back in. A few milliseconds. Who cares?
Try allowing the kernel to do what it was designed to do: manage the available reources for you
Let then log in at level 3 and do a startx. The only difference is that level 3 is a single user mode, and, if you only have one user at a time running, that's not a limitation.
Oh, you could set up a .bashrc for them so that startx would run automatically as soon as they logged in.
Or just have two GRUB entries, one with init level 3 and one with init level 5
For example:
Code:
title Your Linux (runlevel 5)
root (hd0,0)
kernel /vmlinuz26 root=/dev/sda6 ro 5
initrd /kernel26.img
title Your Linux (runlevel 3)
root (hd0,0)
kernel /vmlinuz26 root=/dev/sda6 ro 3
initrd /kernel26.img
Let then log in at level 3 and do a startx. The only difference is that level 3 is a single user mode, and, if you only have one user at a time running, that's not a limitation.
Oh, you could set up a .bashrc for them so that startx would run automatically as soon as they logged in.
run level 3 is multi-usermode
run level 1 is single user
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133
Original Poster
Rep:
tredegar has a good point, that it probably doesn't hurt all that much as long as I have enough swap. PTrenholme has a pretty good idea too, I probably should have thought of that, but I think I want a full desktop manager (xdm, in keeping with the minimalism, and I only have IceWM twm, and mwm installed). But chrism01 is right too, that sudo is small so I just stuck that on. I had thought about using grub, a'la moljac024's solution, but decided that I didn't want them rebooting my server whenever they wanted a desktop. So sudo it is. Thank you all!
tredegar has a good point, that it probably doesn't hurt all that much as long as I have enough swap. PTrenholme has a pretty good idea too, I probably should have thought of that, but I think I want a full desktop manager (xdm, in keeping with the minimalism, and I only have IceWM twm, and mwm installed). But chrism01 is right too, that sudo is small so I just stuck that on. I had thought about using grub, a'la moljac024's solution, but decided that I didn't want them rebooting my server whenever they wanted a desktop. So sudo it is. Thank you all!
I believe that startx starts the X-server, invokes the display manager (xdm, gdm, kdm, etc.), and then the DM starts the window manager. So having the user log in at level 3 (O.K. AceoSpades19, I misspoke. ) doesn't mean that you won't have a DM running after a startx.
The only "problem" with my proposed solution is that you can only exit the X-windows session to the session from which startx was run, so the user would need to do an exit, reboot or shutdown by hand when they terminated the X session.
I'm fairly familiar with the technique since I often need to use it when I boot Fedora from a USB drive on a non-Linux system, and the device drivers aren't set up properly for the "strange" hardware. So startx sometimes fails -- although, more often than not, it finds a driver in its list that does work -- and I need to "tweak" xorg.conf in the Midnight Commander editor to get it to work. Whilst "tweaking," I save the changed xorg.conf file and then try startx 'till I get it working.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.