Linked Questions

0
votes
1answer
4k views

writing a bash script that uses sudo [duplicate]

I am sure that this is a very basic question but I'm afraid that I have been unable to get it to work or understand what is going on. I have a node project that I usually run with sudo npm start ...
-1
votes
2answers
493 views

Suspend SUDO in Bash Script? [duplicate]

I have bash-script that uses sudo commands, but in the middle I need to stop sudo-influence and then later reinstate it. Very simple version using Pseudo code sudo apt-get install -y synaptic sudo ....
1
vote
1answer
593 views

Run sudo commands without running the whole script with sudo (using a desktop launcher) [duplicate]

My script is something like this: #!/bin/bash sudo teamviewer --daemon enable teamviewer sudo teamviewer --daemon disable It works fine on its own, and it requests my password with a terminal window....
0
votes
1answer
942 views

Run script after login as root [duplicate]

I want to run a script as root after a login as a regular user in GDM. Thanks
-1
votes
1answer
807 views

How to achieve sudo privilege in shell script? [duplicate]

how do I can achieve sudo privilege via the shell script without entering the password? Example: [user@user Desktop]$ ./script.sh [user@user Desktop]# which command should I try on the script.sh? ...
2
votes
2answers
379 views

Why does sudo require a password the second time in a bash script every time? [duplicate]

I have a simple very tiny web app, and wanted to make my life a bit easier by having a very simplistic deployment script, that does the following: Pull updates from git Run composer Change owner of ...
0
votes
1answer
571 views

How can I execute a single command as non-root user while the rest of the script runs with root privileges? [duplicate]

I have a script that checks if Java version 8 is installed on my system. If not, the script installs it. Also once it makes sure that correct java version is installed it checks if $JAVA_HOME variable ...
2
votes
2answers
341 views

Prompt sudo password until correct one is given and store it in bash script variable [duplicate]

I'd like to remove the need for the user to type a password multiple times for a bash script that runs sudo commands. How can I loop for password until something like sudo echo returns 0, and then ...
0
votes
3answers
513 views

Executing shell script with sudo [duplicate]

I have a script, which starts the execution of multiple C++-programs. I have to execute those with sudo, as they use some "restricted" linux libs/files(probably not the right nomenclature, but you get ...
0
votes
1answer
432 views

Could not get lock … Resource temporarily unavailable after running sudo apt update (Error 11) [duplicate]

I have a fresh installation of Ubuntu 18.04-x64. In the terminal I enter the command: sudo apt update And I get the following error: E: Could not get lock /var/lib/apt/lists/lock - open (11: ...
0
votes
2answers
136 views

Problem with bash script [duplicate]

I have a little problem with a script of mine. I execute a command in background using sudo and I try to retrieve the PID of the command in a variable. the code is the following: #!/bin/bash sudo ...
1
vote
0answers
160 views

Shell scripts not running on double click [duplicate]

I have created the below script. #!/bin/bash sudo echo "Hi, I'm root" It is inside a file called script.sh I have checked the permission to run as a program inside properties. When I double click, ...
0
votes
0answers
60 views

Sudo - how not to type password in bash script? (apt-get) [duplicate]

I've written update.sh file (bash script): sudo apt-get update sudo apt-get -y dist-upgrade sudo snap refresh read line The localisation of update.sh file is: /home/user/Documents/update.sh Then I'...
106
votes
11answers
103k views

How can a script check if it's being run as root?

I'm writing a simple bash script, but I need it to check whether it's being run as root or not. I know there's probably a very simple way to do that, but I have no idea how. Just to be clear: What's ...
11
votes
5answers
4k views

Is there something similar to echo -n in heredoc (EOF)?

I'm writing on a huge script-factory script generating a lot of maintenance scripts for my servers. Until now I write some lines which need to be written in one line with echo -ne e.g. echo -n "if ((...

15 30 50 per page