LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-13-2004, 08:49 PM   #1
Garibaldi3489
Member
 
Registered: Oct 2004
Posts: 172

Rep: Reputation: 30
Help writing a simple script


With my current setup the only way to shut down my linux install is by going to a konsole and typing:
su
password
halt
I would like otherusers (besides me, the admin) to be able to shut down linux. How could I write a simple script that when clicked by them would execute:
su
password
halt
automatically?
 
Old 12-13-2004, 09:38 PM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
OK, you don't actually want to do that for the simple reason that you would be making root's password visible to anyone looking at the script and that would give them the ability to log in as root and cause unending mayhem. The better way is to give users access to the halt command using sudo. Sudo is desinged to do exactly what you want to do, namely give normal users acces to specific commands with root privileges. The upside is that they don't need to know root's password and they can only execute the commands that they've explicitly been allowed to execute. You edit the /etc/sudoers file using the visudo command and would enter in a line like this:

%users computername=NOPASSWD: /sbin/halt


That would allow any user in the users group to turn off the computer by typing sudo halt at the command prompt. Or you could write a script

Code:
#!/bin/bash
sudo halt
Be sure to read through man sudo and man visudo for more details.
 
Old 12-13-2004, 10:27 PM   #3
ddu_
Member
 
Registered: Dec 2004
Distribution: Slackware
Posts: 114

Rep: Reputation: 16
Not sure if this is exactly what you're looking for, but to allow all users to be able to shutdown or reboot you could:

chmod 4755 /sbin/shutdown
chmod 4755 /sbin/reboot

Users would be able to use /sbin/shutdown & /sbin/reboot commands.

Or as the previous user suggested you could add sudo entries using visudo as root.
 
Old 12-16-2004, 09:03 PM   #4
Garibaldi3489
Member
 
Registered: Oct 2004
Posts: 172

Original Poster
Rep: Reputation: 30
Quote:
Not sure if this is exactly what you're looking for, but to allow all users to be able to shutdown or reboot you could:

chmod 4755 /sbin/shutdown
chmod 4755 /sbin/reboot

Users would be able to use /sbin/shutdown & /sbin/reboot commands.

Or as the previous user suggested you could add sudo entries using visudo as root.
I tried that but it still doesn't work. Hmmm....

Quote:
Sudo is desinged to do exactly what you want to do, namely give normal users acces to specific commands with root privileges. The upside is that they don't need to know root's password and they can only execute the commands that they've explicitly been allowed to execute. You edit the /etc/sudoers file using the visudo command and would enter in a line like this:

%users computername=NOPASSWD: /sbin/halt


That would allow any user in the users group to turn off the computer by typing sudo halt at the command prompt. Or you could write a script
I opened up sudo in visudo... but where do I specifically put the command?
 
Old 12-17-2004, 07:15 AM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
I'm not at my linux box so I can't paste an example, but sudoers is just a text file. I think you can enter than line pretty much anywhere. Again, you really want to have a read through the man pages for sudo and visudo.
 
Old 12-18-2004, 10:54 AM   #6
Garibaldi3489
Member
 
Registered: Oct 2004
Posts: 172

Original Poster
Rep: Reputation: 30
Alright... I'll try again to change the sudo command..
I tried the chmod 4755 /sbin/ commands for:
halt
poweroff
shutdown
reboot
as root and as a user. Later I went to shutdown as a user and it said that I needed to be superuser, so I figured that it hadn't worked. I then went to root and typed halt, AND IT SAID I HAD TO BE SUPER USER! To my knowledge there isn't a user more super than root! What can I do to reverse this so I can shutdown my computer!!!???
 
Old 12-18-2004, 12:14 PM   #7
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
It sounds like the permissions are screwed up. You might post the output of ls -l and we can have a look. You could also try chmod 755 in the /sbin directory and see if that does the trick (do this as root).

If you want to try the sudo route (which is a much safer way to do this), here is my sudoers file as an example. This allows any user to shut down or reboot the macine and mount and unmount the cd drive. Note that the Slacktop name is the name of my laptop:



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

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification
root	ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel	ALL=(ALL)	ALL

# Same thing without a password
# %wheel	ALL=(ALL)	NOPASSWD: ALL

# Samples
#%users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom 
#%users ALL=/sbin/reboot     NOPASSWD: ALL
%users Slacktop = NOPASSWD: /sbin/reboot,/sbin/halt,/bin/mount /dev/cdrom,/bin/umount /dev/cdrom

Last edited by Hangdog42; 12-18-2004 at 12:16 PM.
 
Old 12-18-2004, 12:26 PM   #8
Garibaldi3489
Member
 
Registered: Oct 2004
Posts: 172

Original Poster
Rep: Reputation: 30
Quote:
It sounds like the permissions are screwed up. You might post the output of ls -l and we can have a look. You could also try chmod 755 in the /sbin directory and see if that does the trick (do this as root).
Thanks... I'm currently running winblows.. let me restart real quick here and I'll post the results.

I'm guessing that sudo can only be edited in visudo, right?
 
Old 12-18-2004, 01:00 PM   #9
Garibaldi3489
Member
 
Registered: Oct 2004
Posts: 172

Original Poster
Rep: Reputation: 30
Here's ls -l, but its in my home dir, is that where you want it?
Quote:
total 211020
-r-xr-xr-x 1 andrew users 51324416 2004-10-20 14:10 Car.avi*
-rw-r--r-- 1 andrew users 151611392 2004-12-09 19:40 Cars.mpg
drwxr-xr-x 3 andrew users 4096 2004-12-03 21:14 Desktop/
drwxr-xr-x 2 andrew users 4096 2004-12-11 16:06 Documents/
drwxr-xr-x 8 andrew users 4096 2004-12-17 18:34 Downloads/
drwxr-xr-x 5 andrew users 4096 2004-10-28 22:41 GNUstep/
-rw-r--r-- 1 andrew users 11964656 2004-12-01 19:56 IfYouWant.mov
drwx------ 7 andrew users 4096 2004-11-15 19:21 Mail/
lrwxrwxrwx 1 andrew users 54 2004-10-28 21:40 My\ Documents -> /mnt/windows/Documents\ and\ Settings/Owner/My\ Documents/
drwxr-xr-x 6 andrew users 4096 2004-12-16 22:27 Pictures/
lrwxrwxrwx 1 andrew users 26 2004-10-28 21:41 Program\ Files -> /mnt/windows/Program\ Files/
drwxr-xr-x 9 andrew users 4096 2004-12-17 15:46 Programs/
drwxr-xr-x 2 andrew users 4096 2004-12-12 13:45 School/
-r-xr-xr-x 1 andrew users 10167 2004-11-22 00:25 SuperDragAndGo-0.2.4.xpi*
-rw-r--r-- 1 andrew users 304 2004-12-02 21:14 applications.txt
-rw-r--r-- 1 andrew users 23364 2004-12-05 21:09 apps.txt
-rw-r--r-- 1 andrew users 372956 2004-11-07 00:54 cdrecord-prodvd-2.01b31-i686-pc-linux-gnu
-rw-r--r-- 1 andrew users 2177 2004-12-16 21:13 civics.rtf
-rw-r--r-- 1 andrew users 22585 2004-11-20 21:08 commands.kwd
-rw-r--r-- 1 andrew users 19416 2004-11-20 20:54 commands.kwd~
-rw-r--r-- 1 andrew users 4160 2004-12-16 22:10 cristinaarticle.rtf
drwxr-xr-x 2 andrew users 4096 2004-08-16 19:54 install/
-rw-r--r-- 1 andrew users 2222 2004-12-16 20:59 news.rtf
-rw------- 1 andrew users 275 2004-12-10 22:33 pico.save
-rw-r--r-- 1 andrew users 23168 2004-11-21 19:34 programs.txt
-rw-r--r-- 1 andrew users 741 2004-12-09 20:42 slide.slide
drwxr-xr-x 8 andrew users 4096 2004-08-16 19:54 usr/
-rw-r--r-- 1 andrew users 383685 2004-10-30 02:28 varsha.jar
lrwxrwxrwx 1 andrew users 12 2004-10-28 21:40 windows -> /mnt/windows/
Here is ls -l in /sbin/ as well
Quote:
total 12376
-rwxr-xr-x 1 root bin 4920 2003-02-23 00:47 accton*
-rwxr-xr-x 1 root bin 35048 2004-11-03 22:43 adjtimex*
-rwxr-xr-x 1 root bin 14492 2004-11-03 22:43 agetty*
-rwxr-xr-x 1 root bin 38648 2004-11-04 04:54 arp*
-rwxr-xr-x 1 root bin 24384 2004-09-19 01:54 arpd*
-rwxr-xr-x 1 root bin 10548 2004-11-04 04:55 arping*
-rwxr-xr-x 1 root bin 63872 2003-02-27 06:27 arytst*
-rwxr-xr-x 1 root bin 18160 2004-04-12 01:40 badblocks*
-rwxr-xr-x 1 root bin 6700 2004-04-12 01:40 blkid*
-rwxr-xr-x 1 root bin 8840 2004-11-03 22:43 blockdev*
-rwxr-xr-x 1 root bin 14276 2004-10-28 05:30 cardctl*
-rwxr-xr-x 1 root bin 42972 2004-10-28 05:30 cardmgr*
lrwxrwxrwx 1 root root 7 2004-12-04 07:17 clock -> hwclock*
-rwxr-xr-x 1 root bin 52776 2004-06-20 02:47 convertquota*
-rwxr-xr-x 1 root bin 60524 2004-04-12 01:40 debugfs*
-rwxr-xr-x 1 root bin 204756 2004-09-12 05:12 debugreiserfs*
-rwxr-xr-x 1 root bin 66232 2004-02-29 20:25 depmod*
-rwxr-xr-x 1 root bin 579688 2004-02-29 20:25 depmod.old*
-rwxr-xr-x 1 root bin 68848 2003-02-27 06:27 detect_multipath*
-rwxr-xr-x 1 root bin 340548 2004-10-03 02:53 dhclient*
-rwx------ 1 root bin 6285 2004-10-03 02:53 dhclient-script*
-rwxr-xr-x 1 root bin 36188 2003-01-28 20:17 dhcpcd*
-rwxr-xr-x 1 root bin 44220 2004-06-14 21:29 dosfsck*
-rwxr-xr-x 1 root bin 22628 2004-10-28 05:30 dump_cis*
-rwxr-xr-x 1 root bin 9908 2004-04-12 01:40 dumpe2fs*
-r-xr-xr-x 1 root bin 15872 2004-04-04 20:53 e2fsadm*
-rwxr-xr-x 1 root bin 134604 2004-04-12 01:40 e2fsck*
-rwxr-xr-x 1 root bin 10108 2004-04-12 01:40 e2image*
lrwxr-xr-x 1 root root 7 2004-10-22 13:59 e2label -> tune2fs*
-rwxr-xr-x 1 root bin 5968 2004-11-03 22:43 elvtune*
-rwxr-xr-x 1 root bin 1321 2003-03-05 07:38 explodepkg*
-rwxr-xr-x 1 root bin 85832 2004-11-03 22:43 fdisk*
-rwxr-xr-x 1 root bin 6012 2004-04-12 01:40 filefrag*
lrwxr-xr-x 1 root root 7 2004-10-22 13:59 findfs -> tune2fs*
-rwxr-xr-x 1 root bin 18328 2004-04-12 01:40 fsck*
-rwxr-xr-x 1 root bin 11348 2004-11-03 22:43 fsck.cramfs*
-rwxr-xr-x 1 root bin 36 2004-04-12 01:40 fsck.ext2*
-rwxr-xr-x 1 root bin 36 2004-04-12 01:40 fsck.ext3*
lrwxr-xr-x 1 root root 9 2004-10-22 13:59 fsck.hpfs -> /bin/true*
lrwxr-xr-x 1 root root 8 2004-10-22 13:59 fsck.jfs -> jfs_fsck*
-rwxr-xr-x 1 root bin 23260 2004-11-03 22:43 fsck.minix*
lrwxr-xr-x 1 root root 9 2004-10-22 13:59 fsck.msdos -> /bin/true*
lrwxrwxrwx 1 root root 10 2004-12-04 07:16 fsck.reiserfs -> reiserfsck*
lrwxr-xr-x 1 root root 9 2004-10-22 13:59 fsck.umsdos -> /bin/true*
-rwxr-xr-x 1 root bin 2616 2004-05-29 18:49 fsck.xfs*
-rwxr-xr-x 1 root bin 6340 2004-10-28 05:30 ftl_check*
-rwxr-xr-x 1 root bin 7488 2004-10-28 05:30 ftl_format*
-rwxr-xr-x 1 root bin 8715 2004-02-29 20:25 generate-modprobe.conf*
-rwxr-xr-x 1 root bin 450848 2004-02-29 20:25 genksyms*
-rwxr-xr-x 1 root bin 10260 2003-09-21 01:27 genpowerd*
-rwxr-xr-x 1 root bin 2181 2003-09-21 01:27 genpowerfail*
-rwxr-xr-x 1 root bin 4292 2003-09-21 01:27 gentest*
-rwxr-xr-x 1 root bin 31764 2003-02-20 22:50 getty*
-rwsr-xr-x 1 andrew users 8768 2004-06-21 16:33 halt*
-rwxr-xr-x 1 root bin 1160 2004-11-04 06:48 hotplug*
-rwxr-xr-x 1 root bin 31740 2004-11-03 22:43 hwclock*
-rwxr-xr-x 1 root bin 4396 2004-10-28 05:30 ide_info*
-rwxr-xr-x 1 root bin 51128 2004-11-04 04:54 ifconfig*
-rwxr-xr-x 1 root bin 4160 2004-10-28 05:30 ifport*
-rwxr-xr-x 1 root bin 20800 2004-09-19 01:54 ifstat*
-rwxr-xr-x 1 root bin 5124 2004-10-28 05:30 ifuser*
-rwxr-xr-x 1 andrew users 472820 2004-06-21 16:33 init*
-rwxr-xr-x 1 andrew users 710 2004-06-21 16:33 initscript.sample*
-rwxr-xr-x 1 root bin 6496 2004-02-29 20:25 insmod*
-rwxr-xr-x 1 root bin 626744 2004-02-29 20:25 insmod.old*
-rwxr-xr-x 1 root bin 419044 2004-02-29 20:25 insmod.static*
-rwxr-xr-x 1 root bin 626744 2004-02-29 20:25 insmod.static.old*
-rwxr-xr-x 1 root bin 359 2004-02-29 20:25 insmod_ksymoops_clean*
-rwxr-xr-x 1 root bin 16590 2004-05-30 00:20 installpkg*
-rwxr-xr-x 1 root bin 117584 2004-09-19 01:54 ip*
-rwxr-xr-x 1 root bin 10452 2004-11-04 04:54 ipmaddr*
-rwxr-xr-x 1 root bin 14888 2004-11-04 04:54 iptunnel*
-rwxr-xr-x 1 root bin 42720 2002-02-22 02:08 isapnp*
-rwxr-xr-x 1 root bin 28936 2004-06-07 07:22 iwconfig*
-rwxr-xr-x 1 root bin 19596 2004-06-07 07:22 iwevent*
-rwxr-xr-x 1 root bin 6800 2004-06-07 07:22 iwgetid*
-rwxr-xr-x 1 root bin 25872 2004-06-07 07:22 iwlist*
-rwxr-xr-x 1 root bin 21452 2004-06-07 07:22 iwpriv*
-rwxr-xr-x 1 root bin 18348 2004-06-07 07:22 iwspy*
lrwxrwxrwx 1 root root 7 2004-12-04 07:17 jaztool -> ziptool*
-rwxr-xr-x 1 root bin 83440 2004-05-11 02:57 jfs_debugfs*
-rwxr-xr-x 1 root bin 396472 2004-05-11 02:57 jfs_fsck*
-rwxr-xr-x 1 root bin 201052 2004-05-11 02:57 jfs_fscklog*
-rwxr-xr-x 1 root bin 242400 2004-05-11 02:57 jfs_logdump*
-rwxr-xr-x 1 root bin 55736 2004-05-11 02:57 jfs_mkfs*
-rwxr-xr-x 1 root bin 18272 2004-05-11 02:57 jfs_tune*
lrwxr-xr-x 1 root root 10 2004-10-22 14:00 kallsyms -> insmod.old*
-rwxr-xr-x 1 root bin 451 2004-02-29 20:25 kernelversion*
-rwxr-xr-x 1 andrew users 8960 2004-06-21 16:33 killall5*
lrwxr-xr-x 1 root root 10 2004-10-22 14:00 ksyms -> insmod.old*
-rwxr-xr-x 1 root bin 547084 2004-10-12 05:52 ldconfig*
-rwxr-xr-x 1 root bin 6056 2004-04-12 01:40 logsave*
-rwxr-xr-x 1 root bin 10644 2004-11-03 22:43 losetup*
-rwxr-xr-x 1 root bin 5764 2004-02-29 20:25 lsmod*
lrwxr-xr-x 1 root root 10 2004-10-22 14:00 lsmod.old -> insmod.old*
-rwxr-xr-x 1 root bin 36388 2004-03-22 20:40 lspci*
-rwxr-xr-x 1 root bin 67880 2003-02-27 06:27 lsraid*
-rwxr-xr-x 1 root bin 48572 2004-03-22 23:08 lsusb*
-r-xr-xr-x 1 root bin 16116 2004-04-04 20:53 lvchange*
-r-xr-xr-x 1 root bin 26576 2004-04-04 20:53 lvcreate*
-r-xr-xr-x 1 root bin 8508 2004-04-04 20:53 lvdisplay*
-r-xr-xr-x 1 root bin 16936 2004-04-04 20:53 lvextend*
-r-xr-xr-x 1 root bin 6468 2004-04-04 20:53 lvmchange*
-r-xr-xr-x 1 root bin 12593 2004-04-04 20:53 lvmcreate_initrd*
-r-xr-xr-x 1 root bin 8584 2004-04-04 20:53 lvmdiskscan*
-r-xr-xr-x 1 root bin 6588 2004-04-04 20:53 lvmsadc*
-r-xr-xr-x 1 root bin 6388 2004-04-04 20:53 lvmsar*
-r-xr-xr-x 1 root bin 14996 2004-04-04 20:53 lvreduce*
-r-xr-xr-x 1 root bin 12060 2004-04-04 20:53 lvremove*
-r-xr-xr-x 1 root bin 14364 2004-04-04 20:53 lvrename*
-r-xr-xr-x 1 root bin 9284 2004-04-04 20:53 lvscan*
-rwxr-xr-x 1 root bin 14123 2002-06-02 18:31 makebootdisk*
-rwxr-xr-x 1 root bin 7718 2004-05-30 00:19 makepkg*
-rwxr-xr-x 1 root bin 568856 2004-11-04 03:21 mdadm*
-rwxr-xr-x 1 root bin 10436 2004-11-04 04:54 mii-tool*
-rwxrwxrwx 1 root root 394 2004-10-12 23:43 mixer*
-rwxr-xr-x 1 root bin 23532 2004-06-14 21:29 mkdosfs*
-rwxr-xr-x 1 root bin 31328 2004-04-12 01:40 mke2fs*
-rwxr-xr-x 1 root bin 5180 2004-11-03 22:43 mkfs*
-rwxr-xr-x 1 root bin 8212 2004-11-03 22:43 mkfs.bfs*
-rwxr-xr-x 1 root bin 15780 2004-11-03 22:43 mkfs.cramfs*
lrwxr-xr-x 1 root root 6 2004-10-22 13:59 mkfs.ext2 -> mke2fs*
lrwxr-xr-x 1 root root 6 2004-10-22 13:59 mkfs.ext3 -> mke2fs*
lrwxr-xr-x 1 root root 8 2004-10-22 13:59 mkfs.jfs -> jfs_mkfs*
-rwxr-xr-x 1 root bin 15640 2004-11-03 22:43 mkfs.minix*
lrwxr-xr-x 1 root root 7 2004-10-22 13:59 mkfs.msdos -> mkdosfs*
lrwxrwxrwx 1 root root 10 2004-12-04 07:16 mkfs.reiserfs -> mkreiserfs*
-rwxr-xr-x 1 root bin 298204 2004-05-29 18:49 mkfs.xfs*
-rwxr-xr-x 1 root bin 4324 2004-04-12 01:40 mklost+found*
-rwxr-xr-x 1 root bin 67936 2003-02-27 06:27 mkraid*
-rwxr-xr-x 1 root bin 151400 2004-09-12 05:12 mkreiserfs*
-rwxr-xr-x 1 root bin 10808 2004-11-03 22:43 mkswap*
-rwxr-xr-x 1 root bin 52500 2004-02-29 20:25 modinfo*
-rwxr-xr-x 1 root bin 566584 2004-02-29 20:25 modinfo.old*
-rwxr-xr-x 1 root bin 64432 2004-02-29 20:25 modprobe*
lrwxr-xr-x 1 root root 10 2004-10-22 14:00 modprobe.old -> insmod.old*
lrwxrwxrwx 1 root root 10 2004-12-04 07:17 mount -> /bin/mount*
lrwxrwxrwx 1 root root 17 2004-12-04 07:16 mount.smbfs -> /usr/bin/smbmount*
-rwxr-xr-x 1 root bin 7592 2004-11-04 04:54 nameif*
-rwxr-xr-x 1 root bin 17461 2003-08-27 01:05 netconfig*
-rwxr-xr-x 1 root bin 12836 2004-09-19 01:54 nstat*
-rwxr-xr-x 1 root bin 28040 2004-10-28 05:30 pack_cis*
-rwxr-xr-x 1 root bin 8888 2004-10-28 05:30 pcic_probe*
-rwxr-xr-x 1 root bin 18768 2004-03-22 20:40 pcimodules*
-r-xr-xr-x 1 root bin 4820 2004-10-28 05:30 pcinitrd*
lrwxr-xr-x 1 root root 8 2004-10-22 14:00 pidof -> killall5*
-rwxr-xr-x 1 root bin 3136 2004-11-03 22:43 pivot_root*
-rwxr-xr-x 1 root root 20818 2004-11-04 03:32 pkgtool*
-rwxr-xr-x 1 root bin 4868 2004-11-04 04:54 plipconfig*
-rwxr-xr-x 1 root bin 38172 2002-02-22 02:08 pnpdump*
lrwxr-xr-x 1 root root 4 2004-10-22 14:00 poweroff -> halt*
-r-xr-xr-x 1 root bin 11024 2004-04-04 20:53 pvchange*
-r-xr-xr-x 1 root bin 12340 2004-04-04 20:53 pvcreate*
-r-xr-xr-x 1 root bin 11096 2004-04-04 20:53 pvdata*
-r-xr-xr-x 1 root bin 8516 2004-04-04 20:53 pvdisplay*
-r-xr-xr-x 1 root bin 17332 2004-04-04 20:53 pvmove*
-r-xr-xr-x 1 root bin 9412 2004-04-04 20:53 pvscan*
-rwxr-xr-x 1 root bin 81212 2004-06-20 02:47 quotacheck*
lrwxr-xr-x 1 root root 7 2004-10-22 14:00 quotaoff -> quotaon*
-rwxr-xr-x 1 root bin 56324 2004-06-20 02:47 quotaon*
lrwxr-xr-x 1 root root 6 2004-10-22 14:00 raid0run -> mkraid*
lrwxr-xr-x 1 root root 9 2004-10-22 14:00 raidhotadd -> raidstart*
lrwxr-xr-x 1 root root 9 2004-10-22 14:00 raidhotremove -> raidstart*
-rwxr-xr-x 1 root bin 67936 2003-02-27 06:27 raidreconf*
lrwxr-xr-x 1 root root 9 2004-10-22 14:00 raidsetfaulty -> raidstart*
-rwxr-xr-x 1 root bin 63840 2003-02-27 06:27 raidstart*
lrwxr-xr-x 1 root root 9 2004-10-22 14:00 raidstop -> raidstart*
lrwxrwxrwx 1 root root 4 2004-12-04 07:17 ramsize -> rdev*
-rwxr-xr-x 1 root bin 19640 2004-11-04 04:54 rarp*
-rwxr-xr-x 1 root bin 8128 2004-11-03 22:43 rdev*
lrwxr-xr-x 1 root root 4 2004-10-22 14:00 reboot -> halt*
-rwxr-xr-x 1 root bin 303512 2004-09-12 05:12 reiserfsck*
-rwxr-xr-x 1 root bin 150440 2004-09-12 05:12 reiserfstune*
-rwxr-xr-x 1 root bin 11415 2001-12-19 00:14 removepkg*
-rwxr-xr-x 1 root bin 3003 2004-06-13 01:33 rescan-scsi-bus*
-rwxr-xr-x 1 root bin 23808 2004-04-12 01:40 resize2fs*
-rwxr-xr-x 1 root bin 150220 2004-09-12 05:12 resize_reiserfs*
-rwxr-xr-x 1 root bin 8632 2004-02-29 20:25 rmmod*
lrwxr-xr-x 1 root root 10 2004-10-22 14:00 rmmod.old -> insmod.old*
lrwxr-xr-x 1 root root 16 2004-10-22 14:00 rmt -> /usr/libexec/rmt*
lrwxrwxrwx 1 root root 4 2004-12-04 07:17 rootflags -> rdev*
-rwxr-xr-x 1 root bin 44456 2004-11-04 04:54 route*
-rwxr-xr-x 1 root bin 60 2004-09-19 01:54 routef*
-rwxr-xr-x 1 root bin 1262 2004-09-19 01:54 routel*
-rwxr-xr-x 1 root bin 28480 2003-09-13 23:38 rpc.portmap*
-rwxr-xr-x 1 root bin 20472 2004-09-19 01:54 rtacct*
-rwxr-xr-x 1 root bin 18240 2004-09-19 01:54 rtmon*
-rwxr-xr-x 1 root bin 5992 2004-09-19 01:54 rtstat*
-rwxr-xr-x 1 andrew users 3236 2004-06-21 16:33 runlevel*
-rwxr-xr-x 1 root bin 5044 2004-10-28 05:30 scsi_info*
-rwxr-xr-x 1 root bin 23480 2004-03-22 20:40 setpci*
-rwxr-xr-x 1 root bin 17056 2004-11-03 22:43 setserial*
lrwxr-xr-x 1 root root 20 2004-10-22 14:15 setup -> /initrd/coTopo/setup*
-rwsr-xr-x 1 andrew users 15272 2004-06-21 16:33 shutdown*
-rwxr-xr-x 1 root bin 52196 2004-11-21 22:38 slapt-get*
lrwxrwxrwx 1 root root 8 2004-12-04 07:03 sln -> /bin/sln*
-rwxr-xr-x 1 root bin 51784 2004-09-19 01:54 ss*
-rwxr-xr-x 1 root bin 15180 2002-02-24 20:30 stinit*
-rwxr-xr-x 1 root bin 15608 2004-06-21 19:20 sulogin*
lrwxrwxrwx 1 root root 6 2004-12-04 07:17 swapoff -> swapon*
-rwxr-xr-x 1 root bin 8472 2004-11-03 22:43 swapon*
-rwxr-xr-x 1 root bin 8552 2004-08-17 02:42 sysctl*
-rwxr-xr-x 1 root bin 127424 2004-09-19 01:54 tc*
lrwxr-xr-x 1 root root 4 2004-10-22 14:00 telinit -> init*
-rwxr-xr-x 1 root bin 22368 2004-04-12 01:40 tune2fs*
-rwxr-xr-x 1 root bin 68104 2004-11-01 04:20 udev*
-rwxr-xr-x 1 root bin 8900 2004-11-01 04:20 udevd*
-rwxr-xr-x 1 root bin 6928 2004-11-01 04:20 udevsend*
lrwxrwxrwx 1 root root 10 2004-12-04 07:17 udevstart -> /sbin/udev*
lrwxr-xr-x 1 root root 7 2004-10-22 14:00 udosctl -> umssync*
lrwxrwxrwx 1 root root 11 2004-12-04 07:17 umount -> /bin/umount*
lrwxr-xr-x 1 root root 7 2004-10-22 14:00 umssetup -> umssync*
-rwxr-xr-x 1 root bin 19060 2001-02-04 05:44 umssync*
-rwxr-xr-x 1 root bin 5944 2004-11-03 22:43 update*
-rwxr-xr-x 1 root bin 10454 2004-05-30 00:22 upgradepkg*
-rwxr-xr-x 1 root bin 9264 2004-03-22 23:08 usbmodules*
-rwxr-xr-x 1 root bin 34248 2003-02-20 22:50 uugetty*
-r-xr-xr-x 1 root bin 7480 2004-04-04 20:53 vgcfgbackup*
-r-xr-xr-x 1 root bin 13368 2004-04-04 20:53 vgcfgrestore*
-r-xr-xr-x 1 root bin 18580 2004-04-04 20:53 vgchange*
-r-xr-xr-x 1 root bin 8720 2004-04-04 20:53 vgck*
-r-xr-xr-x 1 root bin 16792 2004-04-04 20:53 vgcreate*
-r-xr-xr-x 1 root bin 10448 2004-04-04 20:53 vgdisplay*
-r-xr-xr-x 1 root bin 9920 2004-04-04 20:53 vgexport*
-r-xr-xr-x 1 root bin 11888 2004-04-04 20:53 vgextend*
-r-xr-xr-x 1 root bin 15344 2004-04-04 20:53 vgimport*
-r-xr-xr-x 1 root bin 12992 2004-04-04 20:53 vgmerge*
-r-xr-xr-x 1 root bin 7092 2004-04-04 20:53 vgmknodes*
-r-xr-xr-x 1 root bin 12548 2004-04-04 20:53 vgreduce*
-r-xr-xr-x 1 root bin 9480 2004-04-04 20:53 vgremove*
-r-xr-xr-x 1 root bin 13160 2004-04-04 20:53 vgrename*
-r-xr-xr-x 1 root bin 12520 2004-04-04 20:53 vgscan*
-r-xr-xr-x 1 root bin 15364 2004-04-04 20:53 vgsplit*
lrwxrwxrwx 1 root root 4 2004-12-04 07:17 vidmode -> rdev*
-rwxr-xr-x 1 root bin 31824 2004-11-01 04:20 wait_for_sysfs*
-rwxr-xr-x 1 root bin 494916 2004-05-29 18:49 xfs_repair*
-rwxr-xr-x 1 root bin 5176 2004-05-29 18:49 xfsdq*
-rwxr-xr-x 1 root bin 228688 2004-05-29 18:49 xfsdump*
-rwxr-xr-x 1 root bin 251688 2004-05-29 18:49 xfsrestore*
-rwxr-xr-x 1 root bin 9924 2004-11-03 22:43 ziptool*
Im in visudo now but I cannot seem to add a line... and I think it just deleted a line.. how can I exit it without saving changes?
 
Old 12-18-2004, 02:41 PM   #10
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Here is ls -l in /sbin/ as well
I think I see the problem. Several of the commands are owned by andrew and in the users group. At very least you want to chown them to root users, if not root root or root bin and then use sudo.

Quote:
Im in visudo now but I cannot seem to add a line... and I think it just deleted a line.. how can I exit it without saving changes?
Visudo uses the vi editor, which in my opinion is one of the most horrible editors ever created. Anyway, you get out with :q. Also, you may want to bookmark a vi help page like this one.
 
Old 12-18-2004, 06:22 PM   #11
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
This is how I do it:

This is my sudoers file, giving my user (slight) specific permission to execute the shutdown command.

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

# Host alias specification

# User alias specification

User_Alias TRUSTED = slight

# Cmnd alias specification

Cmnd_Alias SHUTDOWN = /sbin/shutdown

# Defaults specification

# User privilege specification
root    ALL=(ALL) ALL
TRUSTED ALL=SHUTDOWN
I then wrote this little script that uses Xdialog to make a little gtk+ window popup when the script is called:
Code:
#!/bin/sh
DIALOG=Xdialog

$DIALOG --title "SHUTDOWN" \
        --radiolist "choose:" 0 0 3\
        "-h"    "Shutdown" off \
        "-r"    "Restart" on 2>/tmp/checklist.tmp.$$

retval=$?
choice=`cat /tmp/checklist.tmp.$$`
rm -f /tmp/checklist.tmp.$$

case $retval in
  0)
    sudo /sbin/shutdown $choice now ;;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac
The script produces this:


Hope this helps. Feel free to copy and paste if you wish.

slight
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a simple auto-reconect script for KInternet in SUSE 9.3 tomazN Linux - Networking 0 07-11-2005 10:21 AM
writing simple acpi program bucovaina78 Linux - Laptop and Netbook 1 04-27-2005 07:46 PM
Need help writing a simple program justintime32 Mandriva 8 03-04-2005 08:12 PM
Simple script writing help - digital camera EuroJovi Linux - General 2 02-01-2004 04:01 PM
Writing a simple KDE application yapp Programming 1 12-10-2003 03:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:52 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