LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-09-2008, 10:04 PM   #1
z31200n3
Member
 
Registered: Sep 2006
Distribution: Slackware 12
Posts: 41

Rep: Reputation: 15
give user "shutdown -h now" permission


Hello All,

I'm using Slackware 12.

I'm trying to give my user permission to shutdown the machine, so that I dont have to logout as user, log back in as root, and then issue:

"shutdown -h now" to get the machine to power off.

HELP!!!!
 
Old 02-09-2008, 10:11 PM   #2
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313

Rep: Reputation: 212Reputation: 212Reputation: 212
Have a look at man shutdown.
 
Old 02-09-2008, 10:23 PM   #3
jens
Senior Member
 
Registered: May 2004
Location: Belgium
Distribution: Debian, Slackware, Fedora
Posts: 1,465

Rep: Reputation: 299Reputation: 299Reputation: 299
Quote:
Originally Posted by z31200n3 View Post
Hello All,

I'm using Slackware 12.

I'm trying to give my user permission to shutdown the machine, so that I dont have to logout as user, log back in as root, and then issue:

"shutdown -h now" to get the machine to power off.

HELP!!!!
Do you need this just in X or with your full system.
It really depends on what you're using.

The actual command is /sbin/halt (with many links).
I guess you could do something like "chmod +s /sbin/halt".

EDIT: Don't do the above on a productive server though, allowing everyone to shut it down is really a bad (and insecure) habit

Last edited by jens; 02-09-2008 at 10:34 PM.
 
Old 02-09-2008, 10:43 PM   #4
z31200n3
Member
 
Registered: Sep 2006
Distribution: Slackware 12
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jens View Post
Do you need this just in X or with your full system.
It really depends on what you're using.

The actual command is /sbin/halt (with many links).
I guess you could do something like "chmod +s /sbin/halt".

EDIT: Don't do the above on a productive server though, allowing everyone to shut it down is really a bad (and insecure) habit

being the total linux virgin that I am, I have been logging out of X, logging out of my user in CLI, logging in as root, and then issuing:

"shutdown -h now"

to poweroff the system.

To be totally honest, I didn't know you could power off the system from X using "/sbin/halt" in terminal. BUT, seems I can do that :-) Thanks.

I'm used to DOS, having to log out of windows first before the system is safe to power off.
 
Old 02-09-2008, 11:21 PM   #5
Andy Alt
Member
 
Registered: Jun 2004
Location: Minnesota, USA
Distribution: Slackware64-stable, Manjaro, Debian64 stable
Posts: 528

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by z31200n3 View Post
Hello All,

I'm using Slackware 12.

I'm trying to give my user permission to shutdown the machine, so that I dont have to logout as user, log back in as root, and then issue:

"shutdown -h now" to get the machine to power off.

HELP!!!!
Check out the commands 'sudo' and 'visudo' and instead of using shutdown, try /sbin/powerdown (no switches to power off) and 'halt -p'
 
Old 02-10-2008, 12:17 AM   #6
bcwagne
Member
 
Registered: Feb 2008
Distribution: Debian Testing
Posts: 169

Rep: Reputation: 32
I have to second the sudo approach. It is much safer than having to login as root.
 
Old 02-10-2008, 02:57 PM   #7
z31200n3
Member
 
Registered: Sep 2006
Distribution: Slackware 12
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bcwagne View Post
I have to second the sudo approach. It is much safer than having to login as root.
Security is not really an issue for this particular machine (however I do understand the need for it in a corporate / business environment). It is my personal box, and my roommates have no clue what a CLI is, much less how to use one.

I was under the impression that halting a machine simply shut down all of the processes, and essentially 'locked' the box, but didnt actually kill the power (which is what I was trying to accomplish with "shutdown -h now")

I tried halt several times, and when it said the machine was down (I have forgotten the actual terms CLI used) and I then manually killed the power, upon the next reboot I had to run fsck because "the power had been interrupted" and it thought that the disks were not cleanly unmounted.

Thank you everyone for your input. I'm learning. Slowly, and painfully, but still learning :-)
 
Old 02-10-2008, 03:15 PM   #8
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
I think using sudo would be a good option. You can run visudo and then add a line similar to
Code:
%users  localhost=/sbin/shutdown -h now
Change "users" to the group which you want to be able to shut down the computer.
 
Old 02-10-2008, 03:48 PM   #9
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
alias halt='sudo /sbin/halt'?
 
Old 02-10-2008, 04:14 PM   #10
bcwagne
Member
 
Registered: Feb 2008
Distribution: Debian Testing
Posts: 169

Rep: Reputation: 32
Also with sudo you can set users up to be able to use command without having to enter a password, which is very inconvenient when shutting down the machine. For example:
Code:
Defaults        env_reset

# Uncomment to allow members of group sudo to not need a password
# %sudo ALL=NOPASSWD: ALL

# Host alias specification

# User alias specification
User_Alias OWNER = username

# Cmnd alias specification
Cmnd_Alias SHUTDOWNALLOWED = /sbin/shutdown, /sbin/reboot, /usr/sbin/xfsm-shutdown-helper
 
# User privilege specification
root    ALL=(ALL) ALL
OWNER   ALL=ALL
OWNER   ALL=NOPASSWD: SHUTDOWNALLOWED
I set myself as OWNER, the commands shutdown, reboot, and xfsm-shutdown-helper (which is for XFCE) as SHUTDOWNALLOWED, then tell sudo I can shutdown the computer without a password, while all other commands require one. It is very handy.
 
Old 02-10-2008, 04:35 PM   #11
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,416
Blog Entries: 43

Rep: Reputation: 36
This is often desirable for me too. You might want to look at the page http://www.linuxquestions.org or check out the book "Linux Quick Fix Notebook" from your local library. This tells what sudoers commands mean. It also tells some other useful stuff about Linux for someone trying to use it securely for the first time.
 
Old 02-10-2008, 05:35 PM   #12
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
on my slack ware i can do a logout and the kdm asks if I want to shut down or reboot from user. if I do not use kdm then xdm gives me the same options. or you can as a user push the control alt back buttons that turns off the xserver then tell them to push control alt delete.
there is a place in the kde control center to configure so you can boot striate to the the strait to the kdm login then the user login then he can logout and turn the computer of from the kdm option.
 
Old 02-11-2008, 02:52 AM   #13
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 15.0 (multilib)
Posts: 1,350

Rep: Reputation: 75
If you are running Slackware I suggest that you edit the runlevel in /etc/inittab.

Slackware defaults to multiuser non graphical mode which means you log on to X with startx If you change to the multiuser graphical mode (Ithink this means going from 3 to 4 or vice versa) you will boot into X and be able to close down from X.
 
Old 02-11-2008, 03:10 PM   #14
z31200n3
Member
 
Registered: Sep 2006
Distribution: Slackware 12
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by arubin View Post
If you are running Slackware I suggest that you edit the runlevel in /etc/inittab.

Slackware defaults to multiuser non graphical mode which means you log on to X with startx If you change to the multiuser graphical mode (Ithink this means going from 3 to 4 or vice versa) you will boot into X and be able to close down from X.

so by editing the /etc/inittab, i can have the computer boot into X instead of CLI? Interesting. When I get home from work I'll have to check that out.

And I'll be able to shut down from X as well? (a 'shutdown' button as well as the normal 'log off' button)
 
Old 02-12-2008, 05:10 AM   #15
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 15.0 (multilib)
Posts: 1,350

Rep: Reputation: 75
Indeed you will.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Permission Denied" while accessing ntfs partition in user mode funkymunky Linux - General 3 01-31-2009 08:03 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
"Forbidden / You don't have permission to access /~user/index.html on this server." honglin_8 Linux - Newbie 8 10-30-2007 08:41 AM
Submount, "permission denied" when writing to floppy as normal user DaneM Linux - Software 5 02-22-2006 02:05 PM
Can't "shutdown -a -r now" as a normal user, though shutdown.allow exists mnemonic Linux - Software 5 08-15-2005 06:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration