LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-18-2011, 05:03 PM   #1
Owndapwn
Member
 
Registered: Jan 2011
Posts: 38

Rep: Reputation: 1
Custom Keyboard Commands


So, I found that Linux Ubuntu has custom keyboard commands.
This is awesome.

What I'm trying to do, is make a command that will shut down the computer with a single button with no dialog windows.
For you know, being grounded nd stuff.

I found the command for it is "shutdown" with a few options.
But when I tested it, being bound to pause/break, it did nothing.

Am I writing the wrong code, as I'm not using any options, or is this not possible?
 
Old 04-18-2011, 06:25 PM   #2
ruehara
LQ Newbie
 
Registered: Mar 2011
Posts: 3

Rep: Reputation: 0
Quote:
Originally Posted by Owndapwn View Post
So, I found that Linux Ubuntu has custom keyboard commands.
This is awesome.

What I'm trying to do, is make a command that will shut down the computer with a single button with no dialog windows.
For you know, being grounded nd stuff.

I found the command for it is "shutdown" with a few options.
But when I tested it, being bound to pause/break, it did nothing.

Am I writing the wrong code, as I'm not using any options, or is this not possible?
The command you should map to is telinit 0. This requires no options but you do need to be superuser.
 
Old 04-18-2011, 06:29 PM   #3
elucches
Member
 
Registered: Jan 2011
Posts: 91

Rep: Reputation: 8
Hi,
Did you try to run that command in a console terminal to see what happens, before binding it to a key?
Do you run shutdown with appropriate privileges?
The manual says the time argument is mandatory (try "shutdown now", or "halt").
Regards,
E
 
Old 04-19-2011, 12:11 PM   #4
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 4,165

Rep: Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223
The command you want is "sudo shutdown now". Normally, this will prompt for a password. To fix that, enter

EDITOR=gedit
sudo visudo

That will enable you to edit the file /etc/sudoers and check your alterations before saving them. You can then add

yourname ALL=NOPASSWD:/sbin/shutdown

Last edited by DavidMcCann; 05-03-2011 at 11:53 AM. Reason: Horrible error corrected
 
Old 04-19-2011, 04:55 PM   #5
Owndapwn
Member
 
Registered: Jan 2011
Posts: 38

Original Poster
Rep: Reputation: 1
I don't think I'm doing it right, as it is still asking for a password.

When I add what you say, it just says it has a syntax error, I'm adding it to the last line (27).
I tried to bypass the password for all commands, but it doesn't seem to be working, but it doesn't say my syntax is wrong.
What's broken here?

Code:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL
sawducum ALL=(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
%sawducum ALL=(ALL) ALL
 
Old 04-20-2011, 12:31 PM   #6
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 4,165

Rep: Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223Reputation: 1223
I never use sudo now, so I may be a bit rusty! Have a look at the manual page for sudoers.
 
Old 04-20-2011, 01:08 PM   #7
elucches
Member
 
Registered: Jan 2011
Posts: 91

Rep: Reputation: 8
I think you have to write ALL=(ALL) NOPASSWD: ALL instead of only ALL=(ALL) ALL
 
Old 04-20-2011, 04:51 PM   #8
Owndapwn
Member
 
Registered: Jan 2011
Posts: 38

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by elucches View Post
I think you have to write ALL=(ALL) NOPASSWD: ALL instead of only ALL=(ALL) ALL
Thank you!
It works flawlessly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Custom Commands KLIK Linux - Newbie 4 07-27-2009 09:59 AM
custom commands saikoushik Linux - Newbie 2 12-23-2008 03:21 AM
Custom Bash Commands tryLinux&see Linux - General 8 02-26-2007 08:16 AM
PHP running custom commands Tralce Linux - Server 10 11-20-2006 01:04 PM
Useful custom commands for Slackware thegeekster Slackware 56 03-08-2005 12:16 PM


All times are GMT -5. The time now is 06:43 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration