DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Installation and Upgrading

OpenBSD Installation and Upgrading Installing and upgrading OpenBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 12th July 2014
cravuhaw2C cravuhaw2C is offline
Port Guard
 
Join Date: Jul 2014
Posts: 45
Default Shutdown/power off the machine?

After a successful installation and typing reboot at the command prompt, I was taken to a login screen that states:

Quote:
Welcome to example.my.domain

Login:
Password:
After typing in the word root and the password, the next screen shows an xterm and nothing else.

At this stage, I wish to shutdown/power off the machine.

I issued the command: sudo shutdown -h now
and an error message appeared.

How do I shutdown the machine?
Reply With Quote
  #2   (View Single Post)  
Old 12th July 2014
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by cravuhaw2C View Post
How do I shutdown the machine?
# shutdown -hp now
Reply With Quote
  #3   (View Single Post)  
Old 12th July 2014
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

Quote:
Originally Posted by cravuhaw2C View Post
I issued the command: sudo shutdown -h now
and an error message appeared.
What makes you think you are in sudoers?
Reply With Quote
  #4   (View Single Post)  
Old 12th July 2014
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Quote:
Originally Posted by ibara View Post
What makes you think you are in sudoers?
+1

I would add what make you think that even if you are sudoer you can execute any command? Contrary to how sudo work on Ubuntu, sudo on UNIX is intended to give you a power to execute one possibly several commands without having a root access to the system. Imagine that you are junior system admin and I ask you to do something on the system but I don't want to give you root access. That is realy purpose of sudo.
Reply With Quote
  #5   (View Single Post)  
Old 12th July 2014
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by ibara View Post
What makes you think you are in sudoers?


Thanks, ibara. I missed that sudo(8) had been specified.

cravuhaw2C, ibara is right. Unless you have manually granted yourself additional access though visudo(8), you will be unable to execute shutdown(8).

Even use of su(1) will be restricted unless you are a member of the wheel group.
Reply With Quote
  #6   (View Single Post)  
Old 12th July 2014
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

Quote:
Originally Posted by ocicat View Post
Even use of su(1) will be restricted unless you are a member of the wheel group.
We actually can assume this one: if you add a user during the install, that user is automatically granted staff class and has su(1) access.
Reply With Quote
  #7   (View Single Post)  
Old 13th July 2014
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,503
Default

I'll throw my 2 cents into this. The shutdown command varies between the BSD;s and various LInux versions. Sometimes even between different linux versions.

What should always get you to the righ place is to read the man (manual) page.
Code:
man shutdown
will show
Quote:
SHUTDOWN(8) System Manager's Manual SHUTDOWN(8)
NAME
shutdown — close down the system at a given time
SYNOPSIS
shutdown [-] [-dfhknpr] time [warning-message ...]
DESCRIPTION
shutdown provides an automated shutdown procedure for superusers to nicely notify users when the system is shutting down, saving them from system administrators, hackers, and gurus, who would otherwise not bother with such niceties. When the shutdown command is issued without options the system is placed in single user mode at the indicated time after shutting down all system services.

The options are as follows:

-d
When used with -h or -r causes system to perform a dump. This option is useful for debugging system dump procedures or capturing the state of a corrupted or misbehaving system. See savecore(8) for information on how to recover this dump.
-f
Create the file /fastboot so that the file systems will not be checked by fsck(8) during the next boot. (See rc(8)).
-h
The system is halted at the specified time when shutdown execs halt(8).
-k
Kick everybody off. The -k option does not actually halt the system, but leaves the system multi-user with logins disabled (for all but superuser).
-n
When used with -h or -r prevents the normal sync(2) before stopping the system.
-p
The -p flag is passed on to halt(8), causing machines which support automatic power down to do so after halting.
-r
shutdown execs reboot(8) at the specified time.
time
time is the time at which shutdown will bring the system down and may be the word now (indicating an immediate shutdown) or specify a future time in one of two formats: +number, or yymmddhhmm, where the year, month, and day may be defaulted to the current system values. The first form brings the system down in number minutes and the second at the absolute time specified.
warning-message
Any other arguments comprise the warning message that is broadcast to users currently logged into the system.
-
If ‘-’ is supplied as an option, the warning message is read from the standard input.

At intervals, becoming more frequent as apocalypse approaches and starting at ten hours before shutdown, warning messages are displayed on the terminals of all users logged in. Five minutes before shutdown, or immediately if shutdown is in less than 5 minutes, logins are disabled by creating /etc/nologin and copying the warning message there. If this file exists when a user attempts to log in, login(1) prints its contents and exits. The file is removed just before shutdown exits.

At shutdown time a message is written in the system log, containing the time of shutdown, who initiated the shutdown and the reason. A terminate signal is then sent to init to bring the system down to single-user state (depending on above options). The time of the shutdown and the warning message are placed in /etc/nologin and should be used to inform the users about when the system will be back up and why it is going down (or anything else).

You can cancel a scheduled shutdown with the kill(1) command by killing the shutdown process.
FILES

/etc/nologin
tells login not to let anyone log in
/etc/rc.shutdown
run by rc(8) before the system is shutdown
/fastboot
tells rc(8) not to run fsck(8) during the next boot

SEE ALSO
kill(1), login(1), wall(1), halt(8), rc.shutdown(8), reboot(8)
STANDARDS
The hours and minutes in the second time format may be separated by a colon (‘:’) for backward compatibility.
HISTORY
The shutdown command appeared in 4.0BSD.
November 19, 2007 OpenBSD-current
This is even getting more inconsistent with Redhat. Fedora 20 actually uses a separate systemd call, "systemctl halt" that I think will show up in RHEL7/Centos7

If you run the same command in Debian 6 /7 it will specify that the 'p' flag needs to be upper case, ie in Debian
Quote:
shutdown -hP now
Debian 8 will use systemd.

Last edited by shep; 13th July 2014 at 03:14 AM. Reason: added systemctl halt
Reply With Quote
  #8   (View Single Post)  
Old 13th July 2014
cravuhaw2C cravuhaw2C is offline
Port Guard
 
Join Date: Jul 2014
Posts: 45
Default

Quote:
Originally Posted by ibara View Post
What makes you think you are in sudoers?
Because.....

during installation I did not create a user account. I only entered a password for the root account?
Reply With Quote
  #9   (View Single Post)  
Old 13th July 2014
cravuhaw2C cravuhaw2C is offline
Port Guard
 
Join Date: Jul 2014
Posts: 45
Default

Quote:
Originally Posted by Oko View Post

I would add what make you think that even if you are sudoer you can execute any command?
You have confused me. Isn't that what sudoers are allowed to do?

Quote:
Originally Posted by Oko View Post
Contrary to how sudo work on Ubuntu, sudo on UNIX is intended to give you a power to.....
I'm baffled again. Ubuntu, Debian, ArchLinux, Gentoo, FreeBSD and OpenBSD are all variants of *NIX OSes. Are you saying that OpenBSD is a UNIX OS while Debian, Ubuntu, ArchLinux and Gentoo are not?
Reply With Quote
Old 13th July 2014
cravuhaw2C cravuhaw2C is offline
Port Guard
 
Join Date: Jul 2014
Posts: 45
Default

Quote:
Originally Posted by ocicat View Post
cravuhaw2C, ibara is right. Unless you have manually granted yourself additional access though visudo(8), you will be unable to execute shutdown(8).
During installation I did not create a user account. What I did was to give a password to the root account only.

Does the root account have permission to execute shutdown?

Suppose I did create a user account during installation and suppose I invoked the visudo command, how do I give myself additional access? I have read the man pages and FAQs and I am still unable to make sense of all the parameters stated therein. I don't have IT, computer or technical qualifications.

Quote:
Originally Posted by ocicat View Post
Even use of su(1) will be restricted unless you are a member of the wheel group.
Thanks for the info. Could you tell me what those restrictions are on the use of su?

Gentle note to ocicat: I know you were trying to help me as much as you could and I appreciate it. However the hypertext links that you created for sudo(8), visudo(8), shutdown(8) and su(1) led me to a "Bad Request - You specified an invalid manpath."
Reply With Quote
Old 13th July 2014
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

Quote:
Originally Posted by cravuhaw2C View Post
During installation I did not create a user account. What I did was to give a password to the root account only.

Does the root account have permission to execute shutdown?
You need to be more clear in the future. If you're root, why would you bother invoking sudo? What error message did you receive? These are things that will get your question answered correctly the first time. Of course root can issue shutdown.

Quote:
Originally Posted by cravuhaw2C View Post
Suppose I did create a user account during installation and suppose I invoked the visudo command, how do I give myself additional access? I have read the man pages and FAQs and I am still unable to make sense of all the parameters stated therein. I don't have IT, computer or technical qualifications.
Log in as root and invoke visudo. If you just want your user to be able to shut down the system, uncomment the very last line:
Code:
# %users  localhost=/sbin/shutdown -h now
Though I'd probably change that to -hp so you get the auto-poweroff.

If you want your user to do everything root can do, you'll see this line:
Code:
root    ALL=(ALL) SETENV: ALL
copy that on a blank line below, changing root to whatever your username is.

If you actually care about doing things securely, learn something about sudo. There's even a book appropriately titled Sudo Mastery: User Access Control for Real People by one of the most (if not the most) respected author in BSD books.

Quote:
Originally Posted by cravuhaw2C View Post
Thanks for the info. Could you tell me what those restrictions are on the use of su?
If your user is not in the wheel group then you can't use su(1). Full stop.

Quote:
Originally Posted by cravuhaw2C View Post
Gentle note to ocicat: I know you were trying to help me as much as you could and I appreciate it. However the hypertext links that you created for sudo(8), visudo(8), shutdown(8) and su(1) led me to a "Bad Request - You specified an invalid manpath."
We changed our online man page format. The administrators here have not updated their commands for that. But the change happened only recently; give them some time to catch up.

However, you're clearly running OpenBSD so you have no excuse not to type 'man X page' yourself.
Reply With Quote
Old 13th July 2014
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Quote:
Originally Posted by cravuhaw2C View Post
I'm baffled again. Ubuntu, Debian, ArchLinux, Gentoo, FreeBSD and OpenBSD are all variants of *NIX OSes. Are you saying that OpenBSD is a UNIX OS while Debian, Ubuntu, ArchLinux and Gentoo are not?
This thread is the wrong place to discuss Unix history, which goes back more than thirty years. But I will state this much regarding all of these systems you mention:
  1. None of the them are Unix.
  2. All of them are considered Unix-like.
  3. Most are Linux distributions. Two are BSD operating systems.
  4. They all appear similar, yet all have differences.
  5. The Linux distributions are closer to each other than they are to the BSD operating systems. BSDs have a completely different history and a very different internal technical structure to Linux distributions.

Last edited by jggimi; 13th July 2014 at 07:13 AM. Reason: corrected BSD counts
Reply With Quote
Old 13th July 2014
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

Quote:
Originally Posted by jggimi View Post
  1. All but one are Linux distributions. The last is a BSD operating system.
Finally the truth comes out: FreeBSD is a Linux distro
Reply With Quote
Old 13th July 2014
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Oops. I shouldn't type when exhausted. I'll correct my text.
Reply With Quote
Old 13th July 2014
cravuhaw2C cravuhaw2C is offline
Port Guard
 
Join Date: Jul 2014
Posts: 45
Default

Quote:
Originally Posted by jggimi View Post
  1. None of the them are Unix.
  2. All of them are considered Unix-like.
  3. Most are Linux distributions. Two are BSD operating systems.
  4. They all appear similar, yet all have differences.
  5. The Linux distributions are closer to each other than they are to the BSD operating systems. BSDs have a completely different history and a very different internal technical structure to Linux distributions.
Thanks. This post of yours is very informative. I feel more educated already and I appreciate your effort in this.
Reply With Quote
Reply

Tags
shutdown

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do we need password to shutdown the box ? sw2wolf FreeBSD General 3 22nd May 2012 04:35 PM
shutdown message derf FreeBSD General 5 14th December 2010 04:57 PM
openbsd shutdown phill OpenBSD General 3 27th October 2009 12:27 PM
shutdown message Mr-Biscuit FreeBSD General 1 16th November 2008 11:59 PM
Shutdown problems radtek FreeBSD General 11 13th September 2008 12:42 AM


All times are GMT. The time now is 07:25 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick