Sudo can't execute some commands[SOLVED]

Hi Archers,
I am using sudo and disable root account. There is some problems with sudo such as the following commands:
#sudo echo "1234"  >/etc/rc.local
# sudo cd /root
I can't execute these commands with sudo, instead i have to login as root and execute the commands. So the question is how can I solve these problems?
The Second issue is how can I give certain user the commands that they can execute. For example, user A is only allowed to use "ls" commands and not any other commands?
Cheers
Last edited by hungsonbk (2008-11-17 02:02:29)

You can't use those commands because it aren't real commands, it are shell builtins and they are ran by your shell which is ran by your regular user.
sudo echo foo > bar
This runs the "echo" binary as root but the ">" part is handled by the shell, appropriate way to handle this:
echo foo|sudo tee bar
cd wont work neither, if it did you could cd to a directory you don't have permissions to and then you would be in their as regular user, unable to do anything... You should just work from outside /root or use sudo -s.
For the user thing: man sudoers.
Last edited by Ramses de Norre (2008-11-15 16:52:55)

Similar Messages

  • How can I execute a command inside of a VM client from the VM host?

    Hi!
    I'm working on a set of scripts to automate MOC classroom installations using MDT and PowerShell. Sofar I've been able to automate everything except for the Rearm needed within the VM Clients. Is there any command (preferably PowerShell) that I can Launch
    on the VM host with which I can execute a command within the VM Client?
    Regards,
    Gerrit Deike
    If you think your to small to make a differnce, try going to bed with a mosquito in the room...

    If you wanted the pings to run in parallel, you could have this applet configure another applet to do the pinging, then remove it on the last run.  This will require an amount of programmatic logic, though.  If you wanted to keep things a bit simpler, add another applet that runs at 22:00 that configures a watchdog pinging applet, then a third applet that runs at 22:10 that removes the pinging applet.
    When it comes to embedded quotes when you configure your nested pinging applet, you'll need to use $q to stand for the embedded quotes.  You'll also need to configure:
    event manager environment q "

  • After Cisco Device is boot,execute some command on CLI

    Hi
    In other forum, introduced me EEM for my purpose.
    My need is, after cisco is reloaded some command to be executed.
    Is there any sample for this ?
    Thanks in advance

    Hi
    I have added "wait 10" after every command.unfortunately my script is run until before second "wait 10".
    My script :
    event syslog pattern "SYS-5-RESTART"
    action 0 cli command "enable"
    action 1 cli command "conf t"
    action 1.1 cli command "interface range gigabitEthernet 1/0/1-8"
    action 1.2 cli command "shutdown"
    action 1.3 cli command "exit"
    action 1.4 syslog msg "1111"
    action 1.5 wait 10
    action 1.6 syslog msg "2222"
    action 2 cli command "interface gigabitEthernet 1/0/1"
    action 2.1 cli command "no shutdown"
    action 2.2 cli command "exit"
    action 2.3 syslog msg "3333"
    action 2.4 wait 10
    action 3 cli command "interface gigabitEthernet 1/0/2"
    action 3.1 cli command "no shutdown"
    action 3.2 cli command "exit"
    action 3.3 syslog msg "4444"
    action 3.4 wait 10
    action 4 cli command "interface gigabitEthernet 1/0/3"
    action 4.1 cli command "no shutdown"
    action 4.2 cli command "exit"
    action 4.3 syslog msg "5555"
    action 4.4 wait 10
    action 5 cli command "interface gigabitEthernet 1/0/4"
    action 5.1 cli command "no shutdown"
    action 5.2 cli command "exit"
    action 5.3 syslog msg "6666"
    action 5.4 wait 10
    action 6 cli command "interface gigabitEthernet 1/0/5"
    action 6.1 cli command "no shutdown"
    action 6.2 cli command "exit"
    action 6.3 syslog msg "7777"
    action 6.4 wait 10
    action 7 cli command "interface gigabitEthernet 1/0/6"
    action 7.1 cli command "no shutdown"
    action 7.2 cli command "exit"
    action 7.3 syslog msg "8888"
    action 7.4 wait 10
    action 8 cli command "interface gigabitEthernet 1/0/7"
    action 8.1 cli command "no shutdown"
    action 8.2 cli command "exit"
    action 8.3 syslog msg "9999"
    action 8.4 wait 10
    action 9 cli command "interface gigabitEthernet 1/0/8"
    action 9.1 cli command "no shutdown"
    action 9.2 cli command "exit"
    action 9.3 syslog msg "1010"
    action 9.4 wait 10
    action 9.5 cli command "exit"
    I did not find any reason for this.
    Thanks for any help or guidance

  • Can we execute DOS Commands from a Java Application

    I just want to know whether we can execute DOS Commands from a Java Application.
    Thanks.

    hi,
    try this:
    Runtime.getRuntime().exec("cmd /c start abc.bat");
    andi

  • When I open the Adobe Acrobat, Can I execute my command?

    Hi to all, my plug-in execute my command when I clicked my ToolButton, instead I want to execute my command when I'm opening Adobe Acrobat! How to That do?
    Thanks so much.
    P.s.: excuse for my english

    Hi,
    AVAppDidInitialise is a notification so you need to register that you would like you code called when the application sends out that notification.
    Here is a sample
    ACCB1 ASBool ACCB2 PluginInit(void)
    //Register for an event notification
    AVAppRegisterNotification(AVAppDidInitializeNSEL,
    gExtensionID,ASCallbackCreateNotification(AVAppDidInitialize,
    &myNotificationCallback), NULL);
    //Create a user-defined function that is invoked when Adobe Reader or Acrobat
    //has finished initializing
    ACCB1 void ACCB2 myNotificationCallback(void *clientData)
    AVAlertNote("Acrobat has finished initializing");
    HTH
    Malcolm

  • Can't execute windows command in servlet with JDK1.5 and tomcat 5

    Hi all,
    I have a web application which uses a servlet to execute windows commands, such as "mkdir", "mv", and "rmdir". In my servlet, I use java Runtime() class to implement the execution.
    Under jsdk1.4 and tomcat 4, it is fine for the servlet to execute those command. But uncer jdk1.5 and tomcat 5, it gives the following error:
    error to execute a command: java.io.IOException: CreateProcess: mkdir c:\m7q28 error=2
    java.io.IOException: CreateProcess: mkdir c:\m7q28 error=2
    Please help me if you have any idea. Thanks.

    And be sure to read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How can I execute a command every 10 seconds in a specific time-frame

    Hello,
    I would like to create a script which in a specific time-frame collects some outputs and also pings every 10 seconds.
    To collect the outputs every minute from 22:00PM to 22:10PM I have the following:
    event manager applet snmp_output
    event timer cron cron-entry "0-10/1 22 * * *" maxrun 30
    action 010 cli command "enable"
    action 020 cli command "show clock"
    action 030 cli command "terminal exec prompt timestamp"
    action 040 cli command "show snmp stats oid | append bootdisk:show_snmp_stats_oid.txt "
    action 045 wait 5
    action 050 cli command "show snmp pending | append bootdisk:show_snmp_pending.txt "
    action 055 wait 5
    action 060 cli command "show snmp sessions | append bootdisk:show_snmp_sessions.txt "
    acionn 065 wait 5
    action 070 cli command "end"
    To confirm connectivity to the device doing the SNMP polls I would like to execute a ping every 10 seconds in the same timeframe.
    Cron seems only to support minutes. Is it possible to combine a watchdog timer + a cron timer?
    Can this ping function be incorporated in the SNMP output applet or will I have to write a new one?
    Will I need TCL here (I have no experience in TCL)?
    Best regards,
    Tim

    If you wanted the pings to run in parallel, you could have this applet configure another applet to do the pinging, then remove it on the last run.  This will require an amount of programmatic logic, though.  If you wanted to keep things a bit simpler, add another applet that runs at 22:00 that configures a watchdog pinging applet, then a third applet that runs at 22:10 that removes the pinging applet.
    When it comes to embedded quotes when you configure your nested pinging applet, you'll need to use $q to stand for the embedded quotes.  You'll also need to configure:
    event manager environment q "

  • How can I execute a command after kernel-upgrade/mkinitcpio

    Because of the archlinux specific kernelnaming-policy there's a problem when using grub2. The created menu looks nasty because grub-mkconfig can't find the proper kernel-version. (Bugreport: https://bugs.archlinux.org/task/25453)
    Even if this is fixed we need to recreate the grubconfig always when a new kernel-version is installed.
    What I want now is executing grub-mkconfig after each kernel-installation/mkinitcpio, without repackaging the kernel. Is such a hook possible?
    Last edited by fsckd (2012-02-21 17:36:20)

    Rorschach wrote:
    Because of the archlinux specific kernelnaming-policy there's a problem when using grub2. The created menu looks nasty because grub-mkconfig can't find the proper kernel-version. (Bugreport: https://bugs.archlinux.org/task/25453)
    Even if this is fixed we need to recreate the grubconfig always when a new kernel-version is installed.
    What I want now is executing grub-mkconfig after each kernel-installation/mkinitcpio, without repackaging the kernel. Is such a hook possible?
    This is not necessary unless Versioned Kernel Installs are supported by pacman. I have added a new patch to https://www.dropbox.com/sh/jth3mchm3hob … src.tar.gz that solves the issue. No need for pacman or mkinitcpio hooks (for now).

  • How can i execute OS command in ODI?

    hi all,
    i have an exe file
    and
    i want to execute this file in ODI with scheduling?
    how can i do this?
    thanks.
    Eser

    Take a look in the documentation for the ODIOSCommand tool - which you use in a package.

  • Can't execute this command in terminal of Leopard Server

    Hi everyone,
    I just upgraded from Tiger Server to Leopard server, everything going ok so far but only one problem i have with running this command. Here is what i did
    server:~ administrator$su root
    password
    sh-3.2# sh start-cumulus.sh
    sh: - : invalid option
    Usage: sh [GNU long option] [option] ...
    sh [GNU long option] [option] script-file ...
    GNU long options:
    --debug
    --debugger
    --dump-po-strings
    --dump-strings
    --help
    --init-file
    --login
    --noediting
    --noprofile
    --norc
    --posix
    --protected
    --rcfile
    --restricted
    --verbose
    --version
    --wordexp
    Shell options:
    -irsD or -c command or -O shopt_option (invocation only)
    -abefhkmnptuvxBCHP or -o option
    sh-3.2#
    I was able to run 'sh start-cumulus.sh' with tiger is just fine. Any ideas why it doesn't work with Leopard Server? Thanks

    There may be some differences between bash 2.05 and 3.2, but more likely, some whitespace (space, tab, linefeed or carriage return) crept into your command. If not, try:
    sh "start-cumulus.sh"
    or
    sh 'start-cumulus.sh'
    There's also a (pretty fair) chance that that error message isn't from your command, but a line inside the script.
    You could also try running the script in a full bash shell by omitting the sh command.
    Roger

  • How can i execute some code in a jsp page on the same page ? plz read.

    I have made a single JSP Page where in i want to delete users, create users, update table data.
    I have all the UI on the first page. Now i want to write my all JDBC coding on just this single page. I don't want to create 3 separate pages. Can it be done ?

    This is my page !!
    I have 3 separate pages insert.jsp, delete.jsp, update.jsp to implement the jdbc coding. I know that i can get it done by calling a single jsp page using URL rewriting. But i want to code for events on this very page only.
    <%@page language="java"%>
    <%@page import="java.sql.*"%>
    <HTML>
         <BODY>
              <form method=post action="insert.jsp">
                   Username:<input type=text name=username><br>
                   Password:<input type=password name=password><br>
                   <input type=submit>               
              </form>
              <hr>
              <form method=post action="delete.jsp">
                   Username:<input type=text name=username><br>
                   <input type=submit>               
              </form>
              <hr>
              <form method=post action="update.jsp">
                   Username:<input type=text name=username><br>
                   Password:<input type=password name=password><br>
                   <input type=submit>               
              </form>          
         </BODY>
    </HTML>

  • Executing a command in host machine

    Currently i am doing a project in heterogeneous volume manager, where i need to connect to the host machine and execute some commands inside a java program. Can anyone tell me how to do so.. Are there any api?

    Currently i am doing a project in heterogeneous volume manager, where i need to connect to the host machine and execute some commands inside a java program. Can anyone tell me how to do so.. Are there any api?

  • Execute Linux Command via JSP

    How can I execute Linux commands through a JSP page on a Red Hat Linux 6.1 Machine using Tomcat 3.0
    Please Mail your answer
    [email protected]

    Hi Nick,
    Thankx a lot, for suggestion,
    I wanted to make a page which gives me a text box to write a command and below it shows the result of that command,
    Say , I m in directory "/home/dhiraj"
    and I write in command text box : "pwd"
    it should give me the currrent path in result , which I can show in form of HTML as Results ,
    (may be in a String form..)
    same way if I write in command box : "ls -l"
    it should Return me (say a String) the directory listing of the current path in result,
    I have already tried the Runtime & Process class ,
    Runtime rt = Runtime.getRuntime();
    Process p =null;
    p = rt.exec("command here");
    p.waitFor();
    it has following problems:
    1) This way I m not able to get the result ..
    2) I tried to make a zip file via my program it did not threw any exception , but could not execute...
    I was confused is it 'coz of permission ( rights problem) or some programmatical error as the same program runs via a Java Class file ..
    desperately waiting for ur suggestions
    Dhiraj Agrawal
    MCA student and a Trainee in a local Software House
    reply to: [email protected]

  • Getting an Process Execute a command.

    Hi All,
    can I get the process created by the following code
    Process p = Runtime.getRuntime().exec("db2cmd");to execute some commands?
    My problem is I am getting a new window created by executing this line.
    My commands can be executed in the new window that gets created, how can I get a handle of this new window so that I can execute some commands in the new window.
    Any suggestions will be helpful.
    Regards
    Ayusman

    java.lang.ProcessBuilder
    it's in the standard api starting with jdk 1.5
    I don't see how it would help in this case though. Maybe there's something I'm just missing though.
    You might want to consider creating a batch file to run all the various commands you want to do in that window.

  • Execute a command from servlet

    Hello,
    How can I execute this command from a servlet ?
    example: I want execute "java -cp /root/:/root/log/api/:/root/log/apps/ Transmitter" when I lunch servlet1.java
    so which class in JAVA can do this ?
    Thanks ?

    why u want to run another program? Usually you call the methods within the second program.
    Is it possible to invoke another program in the server using a servlet? If so it could even mess up the whole server. I am not sure.

Maybe you are looking for

  • How do I move my sons Ipod touch to a new I tunes account?

    Both my sons have a I-Pod touch and they are on my I-tunes account. How do I move my older sons I-Pod to his own I-Tunes account so that when they do face time with their friends it does not show up on both I-Pods.

  • Unable to View the Images in OBIEE Title view

    Hi All, I am trying to add a image in the title view of Answers interface. I placed my image in jpeg format in the following 2 paths. C:\OracleBI\oc4j_bi\j2ee\home\applications\analytics\analytics\res\s_oracle10\images and C:\OracleBI\web\app\res\s_o

  • Some files missing sound some not; all play on another computer

    Both my wife and I have MacBookPros running 10.4.8. I put some video files from a VCD onto both our hard drives. They started out with a .DAT suffix, but I read that they could be manually changed to .MPG format by re-labelling and that they would pl

  • Query regarding Javascript in Visual Web JSF

    Hi, I am learning to use Visual web JSF using IDE Netbeans 6.5. I have a doubt regarding using Javascript in the .jsp file. Whenever I use document.getElementById("component-ID").value, I got an error as "component-ID has no properties". It returns n

  • Javascript escape() function

    Hello everyone, I have a select input in a form, some of the options have strings in which there is a space. like "San Francisco", "Los Angelos". I know javascript escape function can transform those strings to URL string like, "San%20Francisco". But