You are not logged in.

#1 2011-01-05 05:27:05

Who'sThere?
Member
From: Middle-Of-Nowhere-USA
Registered: 2010-12-09
Posts: 59

Running commands as normal user

Hi.

Is it possible to do these things?

Run audio without sudo...
(Un)mount partitions without sudo...
Poweroff, or reboot, without sudo...

For instance, If I run:

adduser myusername audio

I'm told that the user already exists. I'm pretty sure nobody would design a system where everything you do needs to be sudo'ed. What am I doing wrong?


Arch Linux: x86_64, Default Kernel.
Repos: Core, Extra, Community, Multilib.

Offline

#2 2011-01-05 06:14:58

SimpleKiwi
Member
From: Ashburton, New Zealand
Registered: 2010-10-11
Posts: 20

Re: Running commands as normal user

To add yourself to a group you need to use gpasswd:

sudo gpasswd -a yourusernamehere audio

Offline

#3 2011-01-05 06:16:36

MadTux
Member
Registered: 2009-09-20
Posts: 553

Re: Running commands as normal user

Did you read

https://wiki.archlinux.org/index.php/Beginners'_Guide#Part_IV:_Sound

The appropriate command for adding your user to the audio group is

gpasswd -a myusername audio

For additional groups see

https://wiki.archlinux.org/index.php/Groups

Offline

#4 2011-01-05 09:49:16

Mr. Alex
Member
Registered: 2010-08-26
Posts: 623

Re: Running commands as normal user

Poweroff, or reboot, without sudo...

# chmod a+s `which reboot`

will let you reboot without root privileges. The same for other commands. It's insecure though.

Offline

#5 2011-01-05 10:16:18

bharani
Member
From: Karaikudi, India
Registered: 2009-07-12
Posts: 202

Re: Running commands as normal user

Mr. Alex wrote:

Poweroff, or reboot, without sudo...

# chmod a+s `which reboot`

will let you reboot without root privileges. The same for other commands. It's insecure though.

A better way is to edit sudoers file to run them without password ,then add bunch of aliases to run them easily.


Tamil is my mother tongue.

Offline

#6 2011-01-05 13:50:40

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: Running commands as normal user

Mr. Alex wrote:

Poweroff, or reboot, without sudo...

# chmod a+s `which reboot`

will let you reboot without root privileges. The same for other commands. It's insecure though.

Nasty. Better to use consolekit/upower.

Add on udisk and/or hal, and you got rootless mounting too.

Last edited by Mr.Elendig (2011-01-05 13:51:29)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#7 2011-01-05 14:28:30

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Running commands as normal user

You can check pmount for mounting as a user.

Offline

#8 2011-01-05 14:30:55

makos
Member
From: Toruń, Poland
Registered: 2010-11-29
Posts: 9

Re: Running commands as normal user

You can mount partitions without using sudo by adding "user" to the "<options>" section in your fstab file.

Part of my fstab for my other disk:

/dev/sda1  /mnt/backup  ext4  noauto,user  0  1

I can mount that disk by using "mount /dev/sda1" as a normal user without any problems.


Arch + LXDE

Offline

#9 2011-01-05 14:35:28

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: Running commands as normal user

makos wrote:

You can mount partitions without using sudo by adding "user" to the "<options>" section in your fstab file.

Has never worked here... Something else must be needed.

Edit: Ok, I tried harder and it _does_ work at least for my /boot (ext2.) It doesn't work for NTFS partitions and most of my disks use that...

Last edited by stqn (2011-01-05 14:51:41)

Offline

#10 2011-01-05 14:38:51

makos
Member
From: Toruń, Poland
Registered: 2010-11-29
Posts: 9

Re: Running commands as normal user

stqn wrote:

Has never worked here... Something else must be needed.

Weird. I did chown /mnt/backup so I'm the owner of that dir (and anything that's mounted there), but I don't know if that's the case.


Arch + LXDE

Offline

#11 2011-01-05 14:42:44

BaconPie
Member
Registered: 2010-08-11
Posts: 209

Re: Running commands as normal user

I use pmount/pumount for mounting/unmounting as user.

I've edited my sudoers file to give my user account access (only on this computer) to issue certain commands without a password. As far as I'm concerned, system commands such as shutdown should only be allowed to run as root. It's just a convenience for me not to have to type my password when using sudo.

# less /etc/sudoers
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# 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

# Runas alias specification

# User privilege specification
root    ALL=(ALL) ALL
tom     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  localhost=/sbin/shutdown -h now

tom     kiwi = NOPASSWD: /sbin/halt
tom     kiwi = NOPASSWD: /sbin/reboot
tom     kiwi = NOPASSWD: /usr/bin/eject
tom     kiwi = NOPASSWD: /usr/sbin/pm-suspend
tom     kiwi = NOPASSWD: /home/tom/bin/backup
tom     kiwi = NOPASSWD: /etc/rc.d/httpd

Which says: For the user tom on the computer kiwi allow him to run command /sbin/halt without a password.

Last edited by BaconPie (2011-01-05 14:43:09)

Offline

#12 2011-01-05 14:54:00

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: Running commands as normal user

makos wrote:

Weird. I did chown /mnt/backup so I'm the owner of that dir (and anything that's mounted there), but I don't know if that's the case.

Sorry, I was wrong: it actually works, just not for NTFS partitions. Directory ownership is not required (I tried with /boot which is owned by root.)

Offline

#13 2011-01-05 15:32:28

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: Running commands as normal user

Try something like this in your fstab:

/dev/sdx  /mnt/win  ntfs-3g   gid=users,umask=0022    0       0

That will allow people in the group 'users' access to the ntfs partition.

Offline

#14 2011-01-05 16:20:26

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Running commands as normal user

@stqn
Please check the wiki and let's not make OT here.

Offline

#15 2011-01-06 19:20:53

Who'sThere?
Member
From: Middle-Of-Nowhere-USA
Registered: 2010-12-09
Posts: 59

Re: Running commands as normal user

After adding my normal user with the 'gpasswd -a' to groups 'audio', 'power', and 'disk', I still can't do any of the original questions.

I don't want to use fstab as my drive configuration is often changing, and I don't want it to do any auto-mounting outside of /. That's a negative on 'pmount' as an option as well. I need to do everything from the command line, with as few apps running as possible.


Arch Linux: x86_64, Default Kernel.
Repos: Core, Extra, Community, Multilib.

Offline

#16 2011-01-06 19:34:02

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: Running commands as normal user

karol wrote:

@stqn
Please check the wiki and let's not make OT here.

You are off topic, not me.

Offline

#17 2011-01-07 11:19:43

hokasch
Member
Registered: 2007-09-23
Posts: 1,461

Re: Running commands as normal user

Pmount is not doing any auto-mounting nor dos it run in the background, but AFAIK you can not change the default parent mount point.

What is your objection against sudo (e.g. posts #5 and #11) for these tasks? What do you mean by "running audio" as user? For shutdown, also have a look at /etc/shutdown.allow (shutdown manpage).

Offline

#18 2011-01-07 12:22:28

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: Running commands as normal user

Simply learn how to alias commands job done!

alias foo='string of commands'

In .bashrc


Mr Green

Offline

#19 2011-01-07 21:28:44

xxxspuddy
Member
Registered: 2007-05-15
Posts: 57

Re: Running commands as normal user

I know that Solaris has a nice way of adding privileges to a user account - role based access control (RBAC) that should achieve everything OP requested

I haven't tried it, but t looks like SELinux has something similar:

https://wiki.archlinux.org/index.php/Gr … chset#RBAC


A temporary file is just a pipe with an attitude and a will to live.

Offline

#20 2011-01-07 21:39:12

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: Running commands as normal user

@Who'sThere?, which DE/WM are you using?


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#21 2011-01-07 22:27:06

Who'sThere?
Member
From: Middle-Of-Nowhere-USA
Registered: 2010-12-09
Posts: 59

Re: Running commands as normal user

hokasch wrote:

What do you mean by "running audio" as user?.

I don't have working audio with any apps that use it, unless I run them with sudo.

loafer wrote:

@Who'sThere?, which DE/WM are you using?

I do almost everything from the command line, but I use Openbox + Tint2 when I absolutely have to run X.


Arch Linux: x86_64, Default Kernel.
Repos: Core, Extra, Community, Multilib.

Offline

#22 2011-01-07 22:31:49

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Running commands as normal user

Did you log out/in again after adding yourself to the relevant groups? Group additions need to be activated that way.

Offline

#23 2011-01-08 19:38:32

Who'sThere?
Member
From: Middle-Of-Nowhere-USA
Registered: 2010-12-09
Posts: 59

Re: Running commands as normal user

Sorry for the late return. I'd been jumping back and forth between various Linux distros.

- Okay, it seems that audio is playing now, good.

- Mounting still needs sudo.

- Powering off, and reboot, still need sudo.

- And after trying to add my user to the group 'dialout', I'm told it doesn't exist.

I'd like to run wvdial as an user. Even with sudo, wvdial will not work aka 'sudo wvdial &'. I have to 'sudo su', and then run 'wvdial &' for it to work.

Last edited by Who'sThere? (2011-01-08 19:38:58)


Arch Linux: x86_64, Default Kernel.
Repos: Core, Extra, Community, Multilib.

Offline

#24 2011-01-08 21:27:02

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Running commands as normal user

All of your issues could be solved if you followed the advice already offered in the thread.

Posting a menu of items that you still have issues with (when the solutions are in the posts above) is tantamount to help vampirism. Please at least try some of the solutions before posting again.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#25 2011-01-08 21:38:41

Who'sThere?
Member
From: Middle-Of-Nowhere-USA
Registered: 2010-12-09
Posts: 59

Re: Running commands as normal user

Okay. I'm not installing any more services/apps that'll take away processing time, or RAM. This is an older PC.

So my only option is to run with sudo (albeit without password prompts)? No way around it...

Is there any reason I should not remove my user from the 'optical', 'power', and 'disk' groups then?

Also, I don't seem to be able to run wvdial, even with sudo. I end up having to run it from a different console where I've already logged in as root.

Last edited by Who'sThere? (2011-01-08 21:39:18)


Arch Linux: x86_64, Default Kernel.
Repos: Core, Extra, Community, Multilib.

Offline

Board footer

Powered by FluxBB