0

I made absolutely no change except for running password <user> as root. After logging back in as <user> and running, for example, su pkg install rsync mtr I am returned the following su([39208]): BAD SU <user> to pkg on /dev/tty0
su: sorry

running id shows that i my user is still in usergroup wheel.

also: running just plain su with no command returns a root shell with no problems.

the /etc/passwd : here's the line regarding my user

<username redacted>: *:1002:0:curnc:/home/<user>:/usr/local/bin/bash

what is curnc? i dont remember ever associating my user with such a reference.

I have no idea how to troubleshoot this.

  • 1
    su -c 'pkg install rsync mtr' – Tom Yan Dec 2 at 5:59
1

what is curnc?

man 5 passwd says the fifth field is "user name or comment field". It's designed to contain human-readable information about the user. It's not important to the issue.


su is not sudo. The first operand (see this) is interpreted as user you want to become.

su [options] [username]

The su command is used to become another user during a login session. Invoked without a username, su defaults to becoming the superuser. […]

Additional arguments may be provided after the username, in which case they are supplied to the users login shell. In particular, an argument of -c will cause the next argument to be treated as a command by most command interpreters. The command will be executed by the shell specified in /etc/passwd for the target user.

(source)

Your command

su pkg install rsync mtr

means "change user to pkg and run /login/shell/of/this/user install rsync mtr". Probably no user named pkg exists, hence BAD SU <user> to pkg. Note <user> to pkg corresponds with the fact the command tried to change <user> to pkg.

This is not what you wanted in the first place. I think you wanted

su -c 'pkg install rsync mtr'

(credits to this comment, although it lacks explanation).


With sudo the syntax could be more like what you tried:

sudo pkg install rsync mtr

The most visible difference is sudo asks for the current user's password (unless configured otherwise); su asks for the target user's password. More about differences: here.

  • in my five years using linux, i've never needed to do this. why now that i've changed my password? is it a coincidence / or is uranus in retrograde in the house of aquarius? – Andrew Dec 2 at 18:53
  • this doesn't work. when i use su -c 'cmd' i am asked for the root password, not my user password. secondly, after giving the root password i am returned the error 'only root may use sudo -c' – Andrew Dec 2 at 18:56
  • my user is in wheel, and has permission to run su with its user password, but is not root. – Andrew Dec 2 at 18:57
  • @Andrew (1) Have never needed to do what? (2) With su -c 'cmd' the target user is root, so you've been asked for the the root password. (3) Where did sudo come from ("only root may use sudo -c")? Was it in cmd? (4) Groups like wheel may matter to sudo, su doesn't care. (5) What command exactly do you want to run? Is it pkg install rsync mtr? – Kamil Maciorowski Dec 2 at 19:06
  • 1
    @Andrew If su used to work like sudo then this was wrong. The current behavior is standard. You should not try to restore the old behavior. Frankly I suspect it was sudo pkg install rsync from the very beginning and you just confused su with sudo. – Kamil Maciorowski Dec 4 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.