Tag Info

New answers tagged

4

/etc/environment is a file used by PAM, meaning it is processed by a log in, which sudo bash does not do, and (from man sudoers): Command environment Since environment variables can influence program behavior, sudoers provides a means to restrict which variables from the user's environment are inherited by the command to be run. There are ...


7

Why is it happening? Because you use su with no username, su default switch to root, so you must type root's password correctly. Need to execute su or sudo command after login if I have sudo access? You must use sudo. Need to prefix sudo with every command? Yes, you should type sudo before every command which you want to run with root ...


4

Don't use process substitution like that. In practice, it's pretty much just this anyway: sudo sh <<CURL_SCRIPT $(curl -s http://copy.com/gLVZIqUubzcS/popcorn) CURL_SCRIPT Or: curl -s http://copy.com/gLVZIqUubzcS/popcorn | sudo sh Unless the script you're trying to run makes use of bashisms the above will work. If it does use bash-only syntax ...


4

sudo closes all open file descriptors other than stdin, stdout and stderr (see man sudo) so process substitution does not work OOTB with sudo. Compare $ sudo bash <(echo echo foo) bash: /dev/fd/63: No such file or directory and $ bash <(echo echo foo) foo You can work around this (or use the -C flag to sudo), but doing what you are trying to do ...


9

I think you can use UDEV to do what you want. Creating a rules file such as/etc/udev/rules.d/99-thumbdrives.rules you'd simply add a rule that will allow either a Unix group or user access to arbitrary USB thumb drives. KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", OWNER="<user>", GROUP="<group>", MODE="0660" Would create the device ...


1

You need sudo or root privileges to edit the /etc/hosts file in your local host. If you don't, there is no way of editing this file. Then you must add an entry to /etc/hosts so that your local host can resolve properly the hostname of the remote host. This is the format of the lines in /etc/hosts 127.0.0.1 localhost.localdomain localhost 10.10.2.9 ...


2

You don't need sudo to fix that, try pkexec, pkexec nano /etc/hosts pkexec nano /etc/hostname After running pkexec nano /etc/hosts, add your new hostname in the line that starts with 127.0.1.1 like below, 127.0.0.1 localhost 127.0.1.1 your-hostname And also don't forget to add your hostname inside /etc/hostname file after running pkexec nano ...


0

I couldn't figure out the right combination of commands to place in visudo to allow a non privileged user to check the postfix status. Checking the /etc/init.d/postfix script it seems like the status command might call a bunch of other commands. In addition to that it seems the service is started using chroot which may be causing issues granting my account ...


0

To run commands via sudo you have to prefix it with sudo like that: sudo /sbin/service postfix status


2

Try the command "id" to see which groups you are in. This will give you an idea about the account you are using. id -a


4

Use sudo -l to determine what level of capabilities you have assigned within its configuration. From man 8 sudo -l[l] [command] If no command is specified, the -l (list) option will list the allowed (and forbidden) commands for the invoking user (or the user specified by the -U option) on the current host. If a ...


0

You can type groups to see you groups [user@system ~]$ groups users and you can just try to use sudo and see, wheater you have sudo access or not. You could try it with "ls". If you don't have sudo access you get an error: [user@system ~]$ sudo ls


0

To see which groups you are part of try groups. Whether or not you have access to sudo depends on your local configuration. If when running groups you don't see wheel or admins staff or a group specifically set up firsudo access then you likely haven't been automatically granted sudo-ing rights. Note that those can be added via the sudo configuration as ...


3

From the sudoers man page: An exclamation point (‘!’) can be used as a logical not operator in a list or alias as well as in front of a Cmnd. This allows one to exclude certain values. For the ‘!’ operator to be effective, there must be something for it to exclude. For example, to match all users except for root one would use: ALL,!root If the ALL, ...


3

All you can do is set targetpw as default, but this won't require root to enter any password. You can't configure sudo to do this and it wouldn't make any sense, either, since root may always do whatever he wants (su doesn't ask for a password either, does it‽). So put Defaults targetpw into your /etc/sudoers file and you should have su behavior.


6

That's because there must be a Defaults requiretty in /etc/sudoers or any file it includes. RedHat systems (RHEL, fedora...) have been known to have that in their default sudoers file. That provides no real security benefit and can be safely removed. RedHat has acknowledged the problem and it will removed in future releases.


2

By default, SUDO is configured to require a TTY. That is, SUDO is expected to be run from a login shell. You can defeat this requirement by adding the -t switch to your the SSH as: ssh -t someserver sudo somecommand The -t forces allocation of a pseudo-tty. If you want to perform this globally, modify /etc/sudoders to specify !requiretty. This can be ...


2

Use the -t flag to ssh to force tty allocation. $ ssh luci tty not a tty $ ssh luci -t tty /dev/ttys003 $


0

You could add a crontab to put a users in a sudo group, and then a second crontab to take that user out.


3

There are two (main) ways you can authorize a user to run commands as root via sudo: declare that “Alice may run commands as root”; declare that “Alice is a sysadmin” and that “sysadmins may run commands as root”. The way to declare “Alice is a sysadmin” is to make her a member of the sysadmins group, but there is no standard name for the sysadmins group ...


1

adduser username sudo works for me -- but then, I use Debian which has a sudoers file that defaults to giving everyone in the sudo group sudo access.


0

The method 2 and 4 will work on almost every Linux. Don't even try to use 3 on working system! It can damage the system. Method 1 can work, but don't have to. Why you should use visudo instead of manually editing /etc/sudoers? Once I had root access I used visudo to fix the sudoers file. Why visudo? Because that’s the program YOU ARE SUPPOSED TO USE. ...


20

I would question why 53 users need sudo to do their day to day work -- for most users (even developers), sudo should be a rare exception, not such a routine thing that someone would casually run a sudo rm -rf * command. Can you use group permissions (or even more advanced ACL's) to give people access to the files they need to get their work done, perhaps ...


19

sudo does its authentication through PAM, like pretty much everything else on a Linux box. So you should be able to use pam_time.so to do this. By default on Debian at least, that module isn't enabled. You need to add a line that looks like this: account requisite pam_time.so to either /etc/pam.d/sudo to enable for only sudo or to ...


6

The simplest way would be to use to use suders.d (via inludedir) for your configuration. You could then have cron jobs that could place the rules for each user in to that directory for the times you desire. The #includedir directive can be used in /etc/sudoers to create a sudo.d directory that you can drop sudoers rules into as part of your rules.. For ...


12

Use su: su - alice sudo vim /etc/hosts From man su: The su command is used to become another user during a login session. Invoked without a username, su defaults to becoming the superuser. The optional argument - may be used to provide an environment similar to what the user would expect had the user logged in directly. For more ...


6

apt-get install sudo -y - Used to install sudo package in Debian based systems and y is used to specify yes during installation. yum install -y sudo - Used to install sudo package in fedora based systems and y is used to specify yes during installation. echo "stack ALL=(ALL_ NOPASSWD: ALL" >> /etc/sudoers - Concatenating the line stack ALL=(ALL_ ...


0

%wheel ALL = (postgres) /usr/bin/psql


1

You mentioned that "sudoers file has commented out # Defaults requiretty". This won't have any effect if your build of sudo has requiretty on by default, which mine does. Use a targeted default spec for the user concerned: Defaults:apache_usr !requiretty


0

This info is for @slm. (See http://unix.stackexchange.com/a/120159/15010 .) Even with this simple case, it asks for the password. $ sudo cat /etc/sudoers tester2 ALL=(ALL) NOPASSWD: /usr/local/bin/backup, /opt/storeBackup/bin/storeBackup.pl tester2@11038-VirtualBox:~$ sudo -l Matching Defaults entries for tester2 on this host: env_reset, ...



Top 50 recent answers are included