Rc.local, run command as regular user?

I want to run a command at startup that can't safely be run as root (and I don't want it to be anyway).  The only way I know of to execute a command at startup is rc.local, but that will run the command as root.  I know sudo can be used to run commands as other users.  If I use sudo to change what user the startup command is running as, will that be safe?  In other words, will that effectively make it as if it was being run by a regular user instead of root?  Or is there a better way of doing this?  Thanks.

You can also put it in your .bashrc, so it will be executed every time you log in. For example, I have it set to mount my external disc if it's plugged but not mounted:
if [[ -r /dev/disk/by-label/disco-externo && `mount | grep disco-externo | wc -l` -eq 0 ]]
then
sudo mount /dev/disk/by-label/disco-externo /mnt/disco-externo
fi
If you put the sudo away you can start any command as a regular user under certain circumstances.

Similar Messages

  • SSIS package issues when running as a regular user

    Hello
    I have one package which is getting data from MSSQL server and putting it to the excel (2007 format).
    When started as an administrator from Visual studio, IS, command line or SQL Agent job it works just fine.
    But when using regular user (SSIS proxy in SQL Agent job) it does not return any errors, but result Excel file is just empty. It puts only firs row with headers into it.
    Only difference I've found when executing as admin and regular user is a warning in package execution detailed log:
    OnWarning,SERVERNAME,USERNAME,PACKAGE_NAME,{GUID},{GUID},2014.03.21 15:23:22,2014.03.21 15:23:22,-2147183868,0x,Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available.  To resolve,
    run this package as an administrator, or on the system's console.
    If I add user to local administrators group it runs just fine.
    Trying to search the web I've found that most causes of thet could be UAC enabled on the server. But it is not enabled.
    SQLserver - Microsoft SQL Server 2012 - 11.0.2383.0 (X64)
    Windows Server 2008 R2
    Thanks in advance,
    Olegas

    It could be also an issue with the access to the %temp% directory.
    But I suggest again, you do not rely on turning the logging on that is built into DTEXEC, you need to provide this package right now with thorough logging to find the root cause of the issue. E.g. no access to a shared drive may an issue, too.
    Arthur My Blog

  • Howto run umtsmon as regular user

    Hi,
    I've got myself a UMTS USB modem and I've a  problem running umtsmon from the AUR as regular user. In particular it's telling me that it can't find a device (even though it's 100% there). I think I am missing something simple here, maybe a group thing but I couldn't figure out what. I've made the user a member of the network group already (but I think that's only for the pppd part). Running it as root or via sudo works without problems.
    Thanks in advance
    Last edited by chimeric (2008-11-06 09:14:25)

    You can also put it in your .bashrc, so it will be executed every time you log in. For example, I have it set to mount my external disc if it's plugged but not mounted:
    if [[ -r /dev/disk/by-label/disco-externo && `mount | grep disco-externo | wc -l` -eq 0 ]]
    then
    sudo mount /dev/disk/by-label/disco-externo /mnt/disco-externo
    fi
    If you put the sudo away you can start any command as a regular user under certain circumstances.

  • 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?

    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)

  • SunStudio Newbie: Installed OK (as root), but cannot run as regular user

    All,
    Just installed SS12.1 with patches successfully on a box with root. Can execute various
    progs (CC, make, etc) as root OK. However when running as a regular user I get permission denied errorsor command not found errors. The path is set correctly (/usr/bin is part of the path).
    What am I missing here - must be something simple, I'm sure...
    Cheers,
    Bonny

    Igor,
    Thanks for the reply, I've managed to sort it earlier - it turned out the directory it was installed into did not allow regular user/world execute access - only root's.
    I've used the package installer btw, if it makes it useful for other people stumbling on this.
    Cheers,
    Bonny
    Edited by: bonnster on Nov 30, 2009 10:52 PM

  • [solved] hook to run commands when user logs in? (before bash profile)

    Is there any way to run commands when a user logs in but before the bash profile is sourced?
    For example, I have a user account with a home directory on /tmp. When the user logs in, the home directory might not exist so there will be no .bash_profile to source. I want to run a script to create the directory if necessary and copy some files into it. How can that be done?
    I thought of putting something in /etc/profile or /etc/profile.d/, but I would like to run something before the user's shell and environment become active.
    I can use /etc/rc.local to do what I want, but I would prefer a hook to ensure that everything is set right when the user logs in.
    Any ideas?
    *edit*
    Solution
    In my case, I found that I could write my own shell script and set it as a login shell. In the script, I can configure everything I need before launching the interactive shell, then clean up anything after it exits.
    Last edited by Xyne (2011-12-10 19:34:07)

    Thanks, dammannj. PAM could probably do what I need but I think I have found a simpler solution (see original post).

  • Can ACS run commands at logon for specific users?

    I have a scenario where I'd like a command run at the time a user logs into the device. Can ACS do this on behalf of the user during the logon process?

    Sure. Bigip LTM, once authenticated, drops users into what is called a TMSH shell. This breaks rancid since rancid expects to be in a bash shell.
    You can access bash from TMSH via a command(run util bash). I'd like ACS to pass this command and run it the moment the rancid user logs in. That way subsoquent commands from rancid will work since he will at that point be at a bash prompt.
    Basically a logon script that runs commands for the user at the time the user logs in.

  • Adobe Premiere CC 2014 CRASHES WHEN RUN AS A REGULAR DOMAIN USER

    When I run the software as domain admin or local admin or any other user that has administrator priviledges on the domain the software starts just fine.
    Faulting application name: Adobe Premiere Pro.exe, version: 8.2.0.65, time stamp: 0x5486db4a
    Faulting module name: dvaui.dll, version: 8.2.0.65, time stamp: 0x5486b61b
    Exception code: 0xc0000005
    Fault offset: 0x00000000001871a8
    Faulting process id: 0x1d2c
    Faulting application start time: 0x01d04aecacb7353d
    Faulting application path: C:\Program Files\Adobe\Adobe Premiere Pro CC 2014\Adobe Premiere Pro.exe
    Faulting module path: C:\Program Files\Adobe\Adobe Premiere Pro CC 2014\dvaui.dll
    Report Id: f1f36e19-b6df-11e4-a820-005056c00008
    when i run as a regular domain user this is what happens.

    I'm not clear why you couldn't run it in Administrator mode ... right-click the program icon, Properties -> Compatibility, near the bottom, run in administrator mode ...
    Neil

  • How to make netcfg2 run with regular user permissions

    when i want to run netcfg2 to connect to my wireless i always have to be superuser then run netfg2.  is there anyway to let the regular user run netcfg2?

    sudo is your friend. You can also set it to only work with certain commands. Instead of having
    USER_NAME   ALL=(ALL) ALL
    You can have
    USER_NAME   ALL=/usr/bin/netcfg2./usr/bin/netcfg-menu,[any other commands you want to add]

  • TS-Run Command Line-run as different user

    HI
    I needed to deploy one program which do not like SYSTEM account (do not installs). So I created TaskSequence with
    Run Command line and specified domain user which will be running this command.
    Is my domain users password safe or it will be provided in clear text in my network? Because this user must be Admin on local computer.

    Just to reinforce, the tasks use standard, core Windows APIs to impersonate the account and execute the command -- these APIs never send anything in clear text and if they did, then Windows has much bigger issues. It would actually take
    a huge amount of effort to not securely perform this operation.
    Jason | http://blog.configmgrftw.com

  • How to run the the impersonation permission grant command for multiple users

    I have run below command earlier to grant the impersonation for a user called user1
    get-mailbox -identity user1 | add-adpermission -user domainname\service application user -ExtendedRights ms-Exch-EPI-May-Impersonate
    Now I want to run this command for multiple users like user2, user3, user 4 together. How should I run the command.
    This is for Exchange Server 2007 SP2
    Abhijeet M. Mohite

    Hi Abhijeet
    get-mailbox -identity user1 | add-adpermission -user domainname\service application user -ExtendedRights ms-Exch-EPI-May-Impersonate
    I am little bit confused with this command so can you please help me what to right inplace of User1 and domainname\service application user
    Example: I wanted to give Impersonate rights to
    [email protected] then can you please complete command for me.      Thanks in advance.
    Warm Regards, Pramod Kumar Singh Manager-IT

  • What file/registry permissions are required to run MultiSim 7 as a regular user?

    I want to be able to run MultiSim 7 as a regular user (since our students obviously do not have administrative permissions/rights).
    I can't quite figure out what file and registry permissions are required to be able to do this (despite using Filemon and Regmon).

    Hi,
    If you are refering to the "failed to update registry" warning message, do this:
    1.  Click Start-->Run
    2.  Type "regedt32"
    3.  Locate HKEY_Classes_Root/Multisim.Document
    4.  On the menu, select Security-->Permission (win 2000), For  XP select Edit-->Permission
    5.  Give full control for everyone
    6.  Repeat step 3-->5 for:
    HKEY_Classes_Root/CLSID/{2D964073-9BC9-11D1-840B-006008AC6551}
    Regards,
    Tien Pham
    EWB Support
    Tien P.
    National Instruments

  • Can't run command because user is in read-only mode.

    Hi
    I try to execute any sql statment i am getting this error.
    Can't run command because user is in read-only mode.

    user493528 wrote:
    I am having the same issue with Benthic when I do the With clause.
    I understand this is not related to Oracle but did anyone had issue related to this. I am getting the same error. Is it related to ODBC driver of how Benthic use to connect etc.,? I do not know.
    Thanks
    Gopihttp://www.benthicsoftware.com/support.html

  • Setting user permissions when running commands

    Here's a doosey,
    Looking to implement a system which will run "commands" being recieved from the network from a bunch of different users. I want the users to have different permissions depending on their username. I'm thinking the backing store as being an LDAP database. (easy update over the network, no using the policy editor, etc).
    Anyone got any advice, experience, existing products which do this? I"m looking at java.security.Profile and java.security.AccessController, java.security.ProtectionDomain and rolling my eyes. Kinda difficult.
    Am I barking up the wrong/right tree?
    Any ideas?
    Many thanks
    Keith

    I think I understand what you're saying, however i'm using the LDAP database to store the user's permissions (exactly like a policy file). So I"m not using LDAP to handle the authentication, just the data.
    It's the process of what you call "assigning the secuirty level" that I wanted to do...
    I think I've found what I'm looking for - JAAS. First I implent a java.security.Policy (in particular the getPermissions(ProtectionDomain domain) method). Then create my own java.security.Principal (containing the username) and associate that with a java.security.auth.Subject then use the Subject.doAs method.
    IN the command code then I do a AccessController.checkPermission(Permission ) method which will throw an exception if the permission is not found.
    I think this is it anyway.

  • How to run commands upon system boot as user?

    How can I as a user run commands upon system boot? In Vixie's cron, one can use the @reboot syntax in a crontab, and the job is ran every time the cron daemon starts. Arch however, uses Dillon's cron which seems not support this feature.

    bwalk wrote:Hmm, does not work, because root owns init, so everything requires root. stb's version is valid, the -s parameter drops privileges to <USER>, spawns a shell and executes <COMMAND>. So, no security problem whatsoever.
    So there is nothing like @reboot in vixiecron?

Maybe you are looking for