I've created a file containing these two lines of code:  #!/bin/sh  sudo sh -c "sync; echo 3 &gt; /proc/sys/vm/drop_caches"   I have ticked (from 'properties') the appropriate box to run the file as a program. Clicking it, I am asked to either run it or run in terminal. The second option works as intended, with the terminal asking for my password then running the command.  Is there a way to run the program directly? Currently it doesn't work (presumably because it cannot run the sudo command without password)
87180
Currently, for all my commands that require root access, I have to type them out on a command line.  I would like for the GUI to prompt me to key in my password, when sudo is required, instead of having to type out the commands from command line.  Is there any way to enable this? Previously one version of Ubuntu desktop had this feature out of the box.  This version of Ubuntu (that I am now running) I upgraded from a server installation.  I will add, my user account is already added to sudo group. Thus I can run commands such as sudo gedit or sudo apt-get but I'm not able to install software in the Ubuntu Software Center.
9812
How should I run another program from within my C program? I need to be able to write data into STDIN of the launched program (and maybe read from it's STDOUT)  I am not sure if this is a standard C function. I need the solution that should work under Linux.
121067
I have a script which can run as sudo script.sh or pkexec script.sh  It would be much nicer from the user point of view if the script asked for the password from the user when just running it by name script.sh.   How can I "embed" request to pkexec or sudo to run the whole script with root privilege?  Note that running everything with sudo sh -c might not be the best solution as I have functions in the script.
85711
When we want to run a programs as root we use sudo, gksu, gksudo and etc. Now my question is how do we can run a Terminal as the root user in Terminal?  I tried with using gksudo terminal and gksu terminal but nothing happens. and by running sudo terminal I get error sudo: terminal: command not found.
777
This seems to be a chicken-egg problem. The most common task using sudo is installing and removing software.  sudo apt-get purge &lt;appname&gt;   But sudo itself can be removed.  sudo apt-get purge sudo # Do not run this command on production computers!   This is where the fun comes  ubuntu@ubuntu:~$ sudo bash: /usr/bin/sudo: No such file or directory   Although it's obvious that no person in his right mind will purge sudo (other than me), someone can be fooled to run this command (not directly, in its hex mode, or whatever it's called) or a person could SSH in disguised as tech guru and do the mess.  So is there a way of reinstalling sudo?
78799
I find that if I execute something using sudo that then if I execute something else soon after also using sudo, that it does not prompt me for my password, and although this can be inconvenient in some situations, it is a security risk in others, and a hassle to keep on coming back and executing the command to make it prompt your for the password on the next go. So I was wondering if and how I could get it to prompt me every time, or for it to at least only remember my password for a very short amount of time?
45209
I have recently joined Ubuntu version 16.04. When i open the terminal it displays this message "To run a command as administrator(user "root"), use sudo command ". Please help me with this problem asap.  It happened to me (@waltinator), too. I did CtrlAltt to open a teminal, and is my wont, did 3 CtrlShiftt to open additional teminal screens. The additional screens got the message:  To run a command as administrator (user "root"), use "sudo &lt;command&gt;". See "man sudo_root" for details.   before my .bashrc finished.    I can't find anywhere in my .bashrc or its included files where I attempt to sudo anything (sounds like a Bad Idea) during my login process. I do set up aliases that sudo when evaluated, but not when defining the alias:  $ egrep 'sudo |su ' .bashrc .bash_aliases /etc/profile.d/color_ls.sh etc/bash_path_funcs/*  .bashrc:# makes "sudo" easier: sudo less $LESS files .bash_aliases:alias bigopenfiles="sudo lsof / | awk '{if(\$7 &gt; 1048576) print \$7/1048576 \"MB\" \" \" \$9 }' | sort -n -u"  .bash_aliases:alias deletedfiles="sudo lsof / | egrep 'PID|\(deleted\)'" .bash_aliases:alias bigopenfiles="sudo lsof / | awk '{if(\$7 &gt; 1048576) print \$7/1048576 \"MB\" \" \" \$9 }' | sort -n -u"  .bash_aliases:alias deletedfiles="sudo lsof / | egrep 'PID|\(deleted\)'" .bash_aliases:alias aptfixkey="sudo gpg --keyserver keyserver.ubuntu.com --recv-keys " .bash_aliases:alias susp="sudo -v &amp;&amp; sleep 20 &amp;&amp; echo 'Zzzzzzzzzzzzzzzzzzzzz' &amp;&amp; date &amp;&amp; sudo pm-suspend &amp;&amp; date &amp;&amp; echo 'Awake'" .bash_aliases:alias update='wupdatestatus=99;while [[ $wupdatestatus -ne 0 ]] ; do sudo apt-get update; wupdatestatus=$?;echo "status=$wupdatestatus";if [[ $wupdatestatus -ne 0 ]] ; then date; sleep 300; fi; done' .bash_aliases:alias upgrade='wupgradestatus=99;while [[ $wupgradestatus -ne 0 ]] ; do sudo apt-get upgrade; wupgradestatus=$?;echo "status=$wupgradestatus"; if [[ $wupgradestatus -ne 0 ]] ; then date; sleep 300; fi; done' .bash_aliases:alias upgradedl='wupgradestatus=99;while [[ $wupgradestatus -ne 0 ]] ; do sudo apt-get --download-only upgrade; wupgradestatus=$?;echo "status=$wupgradestatus"; if [[ $wupgradestatus -ne 0 ]] ; then date; sleep 300; fi; done' .bash_aliases:alias dist-upgrade='wupgradestatus=99;while [[ $wupgradestatus -ne 0 ]] ; do sudo apt-get dist-upgrade; wupgradestatus=$?;echo "status=$wupgradestatus"; if [[ $wupgradestatus -ne 0 ]] ; then date; sleep 300; fi; done' .bash_aliases:alias wup='wifi;sudo rmmod rt2800usb;sudo modprobe rt2800usb;nmcli con up id Nick;wifi;ping3 slashdot.org' .bash_aliases:    sudo tail -n 50 $( ls -rt1 /var/log |sed -e 's%^%/var/log/%'| tail -n 6 ) grep: /etc/profile.d/color_ls.sh: No such file or directory   None of the logs help:  $ sudo grep -l sudo /var/log/* /var/log/*/* 2&gt;/dev/null     shows nothing interesting.  How do I track down who/what is trying to sudo when I login?
20404
At the risk of posting a duplicate question: How can I run a local script (as the current user) when I log out? I read (and tried) among others:   (Marton's version), which did perfectly nothing, used on a simple script creating a file, absolute paths to the script (being executable) and the file. , which must be outdated; it made me remove the file from command line to be able to use my system again. I also looked into , without succes.  I believe I must be doing something wrong here, but cannot find out what is my blind spot. Context Looking for an elegant solution (workaround) to , presumably the result of a bug, I made a script that, depending on the argument, either takes a snapshot of the current desktop icon arrangement, or arranges the icons, according to the last snapshot. The script works fine, but is really no candidate to run as a background script. The script therefore should run on logout to get the arrangement, obviously run by the current user.
53235
I would like to know what is the difference between    su - sudo bash sudo sh   I cannot login as root while doing su - because I do not have the root password - I mean I have my user password with which I can sudo "command"  but this password does not work for su - I can log in as root with sudo bash with my user password and I can login while doing sudo sh but then I get a command prompt in this form #
10006
I have a shell script. I want to configure my script to run automatically during startup. I know how to do this from GUI. But I wanted to do this from terminal. How can I do this?  On a primary research I found that the file needs to be moved to /etc/int.d/ directory. But this operation needs sudo permission. I wanted to do this without super user permissions.   I also found that there are files under ~/.config/autostart/ which are having some settings regarding the startup applications. But I don't know how to edit them to achieve this.   Can someone tell me the exact procedure to achieve this?
113657
For running direct commands, there are two ways.   Either run in Terminal Or run from the "Run Command" dialogue (screen shown below) obtained from Alt+F2     Then, Is there any difference between them? (working same &amp; shell) or redirects to same?
56449
$ source /etc/environment   $ sudo source /etc/environment  [sudo] password for t:  sudo: source: command not found   It seems that a different shell than bash is run to execute source /etc/environment and that shell doesn't have source as builtin.   But my and the root's default shells are both bash.  $ echo $SHELL /bin/bash   If sudo indeeds uses a different shell, why is it? I saw , but don't understand in my case.
72278
How do I execute a program X times in the terminal?  I read that I have to do a bin/bash txt, but I don't know how to execute this X times.
48235
I am writing a script (actually a combination of scripts and makefile) that installs external dependencies: some apt-get commands, some git cloning, building, installing, adding users to groups, ...  Some of the operations in these scripts require superuser permissions, some don't.   Until now I have run the entire make process with sudo, but it has some drawbacks:   git repos I clone get root as owner, which means I can't modify them afterwards without sudo or chown the scripts that add users to groups don't know which user to add since whoami returns root   What is the best way of running as superuser only the commands that require it? Ideally the process would still require me to enter my sudo password, but only once at the very beginning of the install process. It would then forget it at the very end, but keep it all the time until then (it can take several hours).  The solutions I have found online include:   sudo -v at the begninning of the script, but if I understand correctly this times out. My script could be running for a couple of hours running the script with sudo, but the commands that do not need superuser with sudo -u $(logname) &lt;command&gt;. This is what I do now, but it feels like it should be the other way around.   Ideally, I would like my script to:   ask for superuser credentials run normal commands as the logged in user run sudo commands with the credentials entered at step 1 sudo -k to close the superuser session
6219
I'd like to run a .sh file using bash on logout and shutdown of Ubuntu. I have searched up and down the web and have found only fixes for KDE and GNOME. The script is simple, I just need to know if I can add the line of code to the "logoff/shutdown" file or if I need to reference it in another script.
8916
I'd like to know if there is a way to run  program/shell script without typing full path:  /opt/idea/bin/idea.sh
69323
I have the following commands that I want to have them all in one shell file:  su – s3 lizinfo.sh –b   when the first linex executes, it prompts and the command prompt become like as below:   -bash-3.1$ (here I cant type second command &gt;&gt; lizinfo.sh –b)   I want to have my shell file run all of these command at once. But when I run my shell file it only runs the first line and for does not run the second line, and waits until I enter it manually.  Would you help me please ?