Must not run with sudo while trying to create a runner using github-actions

Содержание
  1. How to become «root»?
  2. Tests
  3. Care sharing root account!!
  4. First quick way using pstree
  5. With ps only, you could loop over ps ho ppid
  6. Regarding comment about renamed sudo
  7. Because we are speaking about Un*x
  8. Workaround for executing this by using sudo anyway
  9. Conclusion
  10. Regarding logname
  11. About /proc/self/loginuid under Linux
  12. Must run as root, but I am already root
  13. Re: Must run as root, but I am already root
  14. Re: Must run as root, but I am already root
  15. Re: Must run as root, but I am already root
  16. Re: Must run as root, but I am already root
  17. Re: Must run as root, but I am already root
  18. «This script must be run as root»
  19. Re: «This script must be run as root»
  20. Re: «This script must be run as root»
  21. Re: «This script must be run as root»
  22. Re: «This script must be run as root»
  23. Re: «This script must be run as root»
  24. Re: «This script must be run as root»
  25. Re: «This script must be run as root»
  26. Re: «This script must be run as root»
  27. Re: «This script must be run as root»
  28. Must run as root, but I am already root
  29. Must run as root, but I am already root
  30. Re: Must run as root, but I am already root
  31. Re: Must run as root, but I am already root
  32. Re: Must run as root, but I am already root
  33. Re: Must run as root, but I am already root
  34. Re: Must run as root, but I am already root
  35. Re: Must run as root, but I am already root
  36. Re: Must run as root, but I am already root
  37. Re: Must run as root, but I am already root
  38. Re: Must run as root, but I am already root
  39. Re: Must run as root, but I am already root
  40. «This script must be run as root»
  41. «This script must be run as root»
  42. «This script must be run as root»
  43. «This script must be run as root»
  44. «This script must be run as root»
  45. «This script must be run as root»
  46. «This script must be run as root»
  47. «This script must be run as root»
  48. «This script must be run as root»
  49. Comments
  50. oleiolei commented Mar 20, 2018
  51. fortuna commented Mar 20, 2018
  52. Comments
  53. muhdhabeeb commented Oct 22, 2019
  54. willshot commented Oct 23, 2019
  55. jmbluethner commented Oct 31, 2019
  56. DavideRoccia commented Dec 19, 2019
  57. imvrajshah commented Mar 31, 2020
  58. jmbluethner commented Mar 31, 2020 •
  59. Gimhan-minion commented Apr 28, 2020
  60. ramez5566 commented May 20, 2020
  61. ramez5566 commented May 20, 2020
  62. Vi-u777 commented Apr 7, 2021 •
  63. Noorul720 commented May 17, 2021
  64. Footer
  65. Demystifying `root` on macOS, Part 3 — `root` and Scripting
  66. Sudo in Scripts
  67. Running a Process as Another User
  68. Getting the Current User
  69. AppleScript
  70. Beyond the Shell
  71. CentOS 7.7 + BrainyCP + Jail + Bitrix ENV
  72. Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV
  73. Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV
  74. Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV
  75. Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV
  76. Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV
  77. Script needs to be run as root error after already using become, become_user, and become_method
  78. Trending sort
  79. «This script must be run as root»
  80. «This script must be run as root»
  81. «This script must be run as root»
  82. «This script must be run as root»
  83. «This script must be run as root»
  84. «This script must be run as root»
  85. «This script must be run as root»
  86. «This script must be run as root»
  87. «This script must be run as root»
  88. How to stop a script from running if it’s not root (and echo «Not running as root! Exiting
  89. 4 Answers 4
  90. Require script to be run as root (or with sudo)
  91. 7 Answers 7
  92. Cannot run a script as root with systemctl
  93. 1 Answer 1

How to become «root»?

[sudo] password for bytecommander:

Let me give you an example on how/when to use sudo:

  • apt-get is the command-line tool to run software updates and install new packages. This affects the whole system and therefore requires root permissions. Therefore, whenever we need to invoke apt-get, we have to do this with sudo:

    sudo apt-get install vlc
    

How to proceed with graphical applications instead of terminal commands?

gksudo nautilus

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 a simple way to write a script foo.sh, so that the command ./foo.sh outputs 0, and the command sudo ./foo.sh outputs 1?

asked Dec 2, 2010 at 11:30

Malabarba's user avatar

#!/bin/bash
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 
   exit 1
fi

answered Dec 2, 2010 at 11:44

aneeshep's user avatar

14 gold badges64 silver badges77 bronze badges

The only reliable program to check whether the account is logged in as root, or not:

id -u

Tests

rootx
root2

Logged in as root2, gives the next results:

  • whoami: rootx
  • echo $USER: root2 (this returns an empty string if the program was started in an empty environment, e.g. env -i sh -c 'echo $USER')
  • id -u: 0
    As you can see, the other programs failed in this check, only id -u passed.

The updated script would looks like this:

#!/bin/bash
if ! [ $(id -u) = 0 ]; then
   echo "I am not root!"
   exit 1
fi

answered Mar 13, 2011 at 9:19

Lekensteyn's user avatar

65 gold badges311 silver badges401 bronze badges

#!/bin/bash

if [[ $EUID -ne 0 ]]; then
   echo "You must be root to do this." 1>&2
   exit 100
fi
#!/bin/bash

if (( EUID != 0 )); then
   echo "You must be root to do this." 1>&2
   exit 100
fi

Community's user avatar

answered Mar 13, 2011 at 10:26

jfs's user avatar

1 gold badge32 silver badges46 bronze badges

#!/bin/bash

if [ `whoami` != 'root' ]
  then
    echo "You must be root to do this."
    exit
fi

...

if [ $USER != 'root' ]

answered Mar 13, 2011 at 7:38

Nathan Osman's user avatar

Nathan Osman

40 gold badges177 silver badges259 bronze badges

Taking efficiency into consideration, you may test, first, the EUID environment variable and then, if it doesn’t exist, call the standard id command:

if ((${EUID:-0} || "$(id -u)")); then
  echo You are not root.
else
  echo Hello, root.
fi

This way, because of the OR shortcut, you avoid calling a system command, prioritizing the query of an in-memory variable.

function amIRoot() {
  ! ((${EUID:-0} || "$(id -u)"))
}

answered Oct 12, 2016 at 14:14

Luchostein's user avatar

2 silver badges8 bronze badges

#!/bin/bash
[[ $(id -u) != 0 ]] 
echo $?

answered Dec 2, 2010 at 11:40

João Pinto's user avatar

João Pinto

5 gold badges54 silver badges68 bronze badges

#!/bin/bash
if [ "$(id -u)" == "0" ]
then
    echo "I am root."
else
    echo "I am not root."
fi

Teemu Leisti's user avatar

answered Dec 2, 2010 at 11:35

Delan Azabani's user avatar

This snippet would:

  • Check on different sessions
  • suggest to use sudo !!
  • and return an error
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ]
      then
      echo "You must be root to run this script!"
      echo "use 'sudo !!'"
      exit 1
fi

answered Oct 16, 2014 at 9:17

rubo77's user avatar

49 gold badges158 silver badges277 bronze badges

This answer is just to save an idea with may be helpful for some of you.
If you need script which is run from desktop GUI and requires root privileges try this way:

#!/bin/bash
if ! [ $(id -u) = 0 ]; then
   gksudo -w $0 $@
   exit
fi

#here go superuser commands, e.g. (switch intel cpu into powersave mode):
echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
cpupower frequency-set -g powersave

The gksudo may not be available in your system then install it with sudo apt-get install gksu.

answered Oct 17, 2015 at 22:00

gertas's user avatar

3 bronze badges

One simple way to make the script only runnable by root is to start the script with the line:
#!/bin/su root

answered Aug 13, 2016 at 21:07

alexandre1985's user avatar

This code works under both Bash and stock Bourne sh (tested under FreeBSD) that does not define EUID. If EUID exists its value is returned, else the ‘id’ command is run. It is a tad shorter than the «or» example above, as it uses a shell built-in «:-«.

Root in sh:

# echo $EUID

# euid=${EUID:-`id -u`}
# echo $euid
0

In bash:
[chaapala@tenfwd2 ese]$ euid=${EUID:-`id -u`}
[chaapala@tenfwd2 ese]$ echo $euid
10260

answered May 22, 2019 at 18:37

Clayton Haapala's user avatar

Care sharing root account!!

Once you give root access to someone, they could do anything, including editing your script!!

First quick way using pstree

So simplier way to search for sudo presence in whole current tree, seem to use pstree:

die() { echo >&2 ${0##*/} Error: "$@"; exit 1;}
pstree -s $$ | grep -q '\bsudo\b' && die "Can't be run under sudo"

With ps only, you could loop over ps ho ppid

die() { echo >&2 ${0##*/} Error: "$@"; exit 1;}
pid=$$
while read pid name foo < <(ps ho ppid,cmd $pid) && ((pid>1));do
    [ "$name" = "sudo" ] && die "Can't be run under sudo"
done

Regarding comment about renamed sudo

If sudo command is renamed or copied, then instead of looking for command name, look for UID in whole parent tree. So script is same than previous, but searching for UID >= 1000 in parent tree:

die() { echo >&2 ${0##*/} Error: "$@"; exit 1;}
pid=$$
while read pid uid < <(ps ho ppid,uid $pid) && ((pid>1));do
    ((uid>999)) && die "Can't be run under sudo"
done

Because we are speaking about Un*x

To be correct, avoid using fixed statical datas, use of UID_MIN from /etc/login.defs:

die() { echo >&2 ${0##*/} Error: "$@"; exit 1;}
while read fld val;do
    case $fld in UID_MIN ) UIDMIN=$val ;break ;; esac
done </etc/login.defs
((UIDMIN)) || die Getting UID_MIN.
pid=$$
while read pid uid < <(ps ho ppid,uid $pid) && ((pid>1));do
    (( uid >= UIDMIN )) && die "Can't be run under sudo"
done

Workaround for executing this by using sudo anyway

But all this is someting fragile:

$ sudo su -
# screen -D -R  # apt install screen if not installed
$ sudo screen -x

Now, you’ll be logged in a root login session. No trace of any sudo.

# ps $PPID
 PID TTY      STAT   TIME COMMAND
 26367 ?        Ss     0:00 SCREEN -D -R
# ps ho ppid $PPID
 1
# set | grep SUDO
                                         # <-- nothing here!

Conclusion

As chepner rightly commented: sudo is drawn to give specifics access to specifics tools:

Nothing about sudo requires it to give you root access; that’s just the default behavior everyone is familiar with. sudo can be configured to allow you to do only very specific things, including not gain root access at all – chepner

Care to configure them correctly, before using fragile workaround!

apropos sudo

And read carefully

man sudo.conf
man sudoers

Regarding logname

Have a look at correct Stéphane Chazelas’s answer! This could be the best answer for a homework!!

Дополнительно:  Сильно нагревается ноутбук: 10 простых советов

About /proc/self/loginuid under Linux

Please read interesting laolux’s answer about this!

die() { echo >&2 ${0##*/} Error: "$@"; exit 1;}
read lUid </proc/self/loginuid || die "Can't access procfile"
((lUid)) && die "You must be logged as root."

( This syntax avoid forks! )

  • script could be copied and edited
  • depending on config/kernel, this kernel entry could be spoofed
  • Sudoer could create cron entry for initiating special screen session as root. (cron and screen are not the only way for doing things like this! Just the first coming to my mind. )

I have a script that I need to run at startup. I have it in init.d. I need to execute one of the commands within the script with root permissions. How do I go about doing this?

 /path/to/atria_start stop  # stop CC
 /path/to/start_lmgrd start # start license manager (flexlm)
 /path/to/atria_start start # restart CC

These don’t happend. I have them in a simple script «cc_startup.sh» in /etc/init.d

asked Jan 27, 2016 at 19:47

basil's user avatar

1 silver badge4 bronze badges

S##Name -> ../init.d/scripthere.sh wherein ## is equivalent to when you want it to run at start up. Do you want it coming up before ssh? After apache? Before your database? etc etc. Knowing that will tell you which numbers to put in.

To achieve this you’ll want to run ln -s ../init.d/scripthere.sh S##name from the proper rc directory.

answered Jan 27, 2016 at 22:41

SpaceLourde's user avatar

answered Jan 28, 2016 at 15:37

SkyLeach's user avatar

echo $MY_SUDO_PASSWORD | sudo -S <command>

This will run under sudo without prompting for password, if $MY_SUDO_PASSWORD matches your sudo password of course.

answered Jan 28, 2016 at 16:30

ErectCrested's user avatar

I’m trying to write a bash script (in Ubuntu) that will backup a directory using tar.

How can I do a check in the script so that it can only be run as root (or with sudo)?

I know there has to be an easy solution, I just haven’t been able to find it by googling.

asked Jul 8, 2009 at 17:30

Cory Plastek's user avatar

To pull the effective uid use this command:

id -u

If the result is ‘0’ then the script is either running as root, or using sudo. You can run the check by doing something like:

if [[ $(/usr/bin/id -u) -ne 0 ]]; then
    echo "Not running as root"
    exit
fi

answered Jul 8, 2009 at 17:36

Scott Pack's user avatar

Scott Pack

10 gold badges53 silver badges83 bronze badges

I assume you know that by changing the ownership to root

chown root:root file

and setting the permissions to 700

chmod 700 file

you will accomplish the same thing — without the suggestion to run as sudo.

But I will post this answer for completeness.

answered Jul 8, 2009 at 17:43

Brent 's user avatar

19 gold badges70 silver badges102 bronze badges

The bash variable $EUID shows the effective UID the script is running at, if you want to make sure the script runs as root, check wether $EUID contains the value 0 or not:

if [[ $EUID -ne 0 ]]; then
    echo "$0 is not running as root. Try using sudo."
    exit 2
fi

This is better than the solution with /usr/bin/id (for bash scripts!) because it doesn’t require an external command.

answered Mar 24, 2015 at 13:56

neuhaus's user avatar

2 silver badges6 bronze badges

You can use whoami command as well.

if [ ! "`whoami`" = "root" ]
then
    echo "\nPlease run script as root."
    exit 1
fi

answered Jul 22, 2009 at 9:12

Kiril's user avatar

1 gold badge2 silver badges7 bronze badges

answered Jul 8, 2009 at 18:02

theotherreceive's user avatar

1 gold badge31 silver badges44 bronze badges

One simple way to make the script only runnable by root is to start the script with the line:
#!/bin/su root

answered Aug 13, 2016 at 20:55

alexandre1985's user avatar

1 gold badge2 silver badges9 bronze badges

answered May 15, 2017 at 18:12

Lynnux's user avatar

Hi I am new in github actions and I am trying to create a CICD pipline using Github action. I am using a digital ocean droplet UBUNTU 20.04 as my server and I am trying to create a runner as said in ->settings->actions

I got this:
Must not run with sudo

asked Feb 7, 2021 at 9:04

Riwaj Chalise's user avatar

The env variable to use is RUNNER_ALLOW_RUNASROOT="1"
You can :

  • Export it before running config.sh using export RUNNER_ALLOW_RUNASROOT="1"
  • Start config.sh like this : RUNNER_ALLOW_RUNASROOT="1" ./config.sh --url...
user_id=`id -u`
if [ $user_id -eq 0 -a -z "$RUNNER_ALLOW_RUNASROOT" ]; then
    echo "Must not run with sudo"
    exit 1
fi

So in our case we could do RUNNER_ALLOW_RUNASROOT="0" or even RUNNER_ALLOW_RUNASROOT="cool" and it would work but RUNNER_ALLOW_RUNASROOT="" would not work.

answered Feb 7, 2021 at 19:50

Paul's user avatar

1 silver badge6 bronze badges

bertenvdb

Posts: 6
Joined: 2015-01-21 15:25
Location: Belgium

Must run as root, but I am already root


by bertenvdb » 2015-01-21 16:29

I’m trying to install OpenNMS. I need to execute:

Code: Select all

sudo $OPENNMS_HOME/bin/install -dis

But wether I do the above using sudo or logged as root, I get:

Code: Select all

Error: you must run this script as root, not 'UID=0(root'

Code: Select all

# User privilege specification
root      ALL=(ALL:ALL) ALL
berten    ALL=(ALL:ALL) ALL

uname -a: Linux kira 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1 x86_64 GNU/Linux



bertenvdb

Posts: 6
Joined: 2015-01-21 15:25
Location: Belgium

Re: Must run as root, but I am already root


by bertenvdb » 2015-01-21 17:09

Code: Select all

berten@kira:/usr/share/opennms$ sudo $OPENNMS_HOME/bin/install -dis
Error: you must run this script as root, not 'UID=0(root'
berten@kira:/usr/share/opennms$ su root
Wachtwoord: 
root@kira:/usr/share/opennms# $OPENNMS_HOME/bin/install -dis
Error: you must run this script as root, not 'UID=0(root'





schnuller

Posts: 386
Joined: 2014-11-25 05:05

Re: Must run as root, but I am already root


by schnuller » 2015-01-21 21:35


bertenvdb

Posts: 6
Joined: 2015-01-21 15:25
Location: Belgium

Re: Must run as root, but I am already root


by bertenvdb » 2015-01-22 01:25

schnuller wrote:
Perhaps try su —

I tried this, but no dice.

roseway wrote:Have you tried examining the script? Search for the error message and see what triggers it. It’s probably just a bug in the script, and you could edit it to bypass the root check.

Will post a topic on OpenNMS as soon as I wake up in the morning.

Thanks for the support ! :wink:

For reference or curious people:

Code: Select all

#!/bin/sh -

OPENNMS_HOME="/usr/share/opennms"
OPENNMS_BINDIR="/usr/share/opennms/bin"

RUNAS="root"

ULIMIT=`which ulimit 2>/dev/null`
if [ -n $ULIMIT ]; then
        for SIZE in 1024 2048 4096 8192 unlimited; do
                ulimit -n "$SIZE" >/dev/null 2>&1
                if [ $? -gt 0 ]; then
                        break
                fi
        done
fi

myuser="`id | sed -e 's/uid=[0-9][0-9]*(//' -e 's/).*//'`"
#if [ x"$myuser" = x"$RUNAS" ]; then
#       true # all is well
#else
#       echo "Error: you must run this script as $RUNAS, not '$myuser'" >&2
#       exit 4 # According to LSB: 4 - user had insufficient privileges
#fi

if [ -f "$OPENNMS_HOME/etc/opennms.conf" ]; then
        . "$OPENNMS_HOME/etc/opennms.conf"
fi

exec "$OPENNMS_BINDIR"/runjava -r -- \
        $ADDITIONAL_MANAGER_OPTIONS \
        -Dopennms.home="$OPENNMS_HOME" \
        -Dlog4j.configurationFile="$OPENNMS_HOME"/etc/log4j2-tools.xml \
        -cp "$OPENNMS_HOME/lib/opennms_bootstrap.jar" \
        org.opennms.bootstrap.InstallerBootstrap \
        "$@"

fsmithred

Posts: 1873
Joined: 2008-01-02 14:52

Re: Must run as root, but I am already root


by fsmithred » 2015-01-22 13:23

That’s weird. It looks like it should work. It does work on command line, and it does work if I put just that test in a script by itself. Is there something odd about the output of the id command? You could add

FWIW, here’s another way to do the same test:

Code: Select all

# Check that user is root.
[[ $(id -u) -eq 0 ]] || { echo -e "\n\t You need to be root!\n" ; exit 1 ; }

impensj

Posts: 1
Joined: 2016-07-05 16:58

Re: Must run as root, but I am already root


by impensj » 2016-07-05 17:24

The script expects the `id` command to return a line containing uid= but gets a line containing UID= instead.


  1. June 15th, 2012

    «This script must be run as root»

    Hello.

    I am trying to install a program, but when I enter «./install» in the terminal, I get the message:

    «This script must be run as root»

    How can I run it as root, and what does that mean ?

  2. diesch's Avatar

    June 15th, 2012

    Re: «This script must be run as root»

    Use
    root is the privileged adiminstrator’s account in Linux. It’s usually needed for example to install software outside your home folder.

    Be careful what you do and run as root. Only run programs and scripts from trustworthy sources that way as the can harm your system.

  3. June 15th, 2012

    Re: «This script must be run as root»

    Thank you.

    I used the «sudo ./install» command and it asked me for my password, which I entered. Then I got the message «command not found», though I navigated exactly to the directory where it is inside.

    I am trying to install Avira Antivir Personal for Linux, if that helps. I unzipped the gz package to the /tmp folder in the main drive, where Linux is installed. I renamed it to «antivir» since the original name was long and complicated.

    Yet I cannot get it to install.

  4. June 15th, 2012

    Re: «This script must be run as root»

    Do I have to enter «sudo ./install» exactly or something like «sudo cd /tmp/antivir/install» ?

  5. June 15th, 2012

    Re: «This script must be run as root»

    I quote from the Terminal with translations in bold, since it is the German version:

    So first it asks me for permission, and when I enter «sudo» before the «./install» it suddenly does not find the command anymore ?!

    But when I open the folder with the file manager, the install command/file is clearly there !

  6. June 15th, 2012

    Re: «This script must be run as root»

    Could it be that the program, though written for Linux, is not compatible with Ubuntu ?

    Last edited by Ali_Barba; June 15th, 2012 at .

  7. June 15th, 2012

    Re: «This script must be run as root»

    Maybe somebody could download the program, too, and see whether it works ? The source is definitely trustworthy, one of the major antivirus companies. But maybe they made some mistake while writing the installer and it is corrupted ?

  8. lisati's Avatar

    June 15th, 2012

    Re: «This script must be run as root»

    Have a look here: https://help.ubuntu.com/community/RootSudo

    Please post back if you have any further questions or comments.

  9. June 15th, 2012

    Re: «This script must be run as root»

    Quote Originally Posted by lisati
    View Post

    Yeah, I got the sudo thing now, but it still will not install.

    See the quote from the Terminal above.

  10. June 16th, 2012

    Re: «This script must be run as root»

    Could you show the output of an ‘ls’ in the install directory?

Must run as root, but I am already root

Must run as root, but I am already root

#1 Post by bertenvdb » 2015-01-21 16:29

I’m trying to install OpenNMS. I need to execute:

uname -a: Linux kira 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1 x86_64 GNU/Linux

Re: Must run as root, but I am already root

#2 Post by aicardi » 2015-01-21 17:03

Re: Must run as root, but I am already root

#3 Post by bertenvdb » 2015-01-21 17:09

Re: Must run as root, but I am already root

#4 Post by aicardi » 2015-01-21 17:33

Re: Must run as root, but I am already root

#5 Post by bertenvdb » 2015-01-21 17:48

I wonder what you searched for, I guess you found this on the OpenNMS mailinglist. I have been searching for 2 hours and didn’t come accross that yet.

Re: Must run as root, but I am already root

#6 Post by roseway » 2015-01-21 18:44

Re: Must run as root, but I am already root

#7 Post by dilberts_left_nut » 2015-01-21 18:50

Re: Must run as root, but I am already root

#8 Post by schnuller » 2015-01-21 21:35

Perhaps try
su —
too. Which usually should be done, i was told, but as i get away without doing it .

Re: Must run as root, but I am already root

#9 Post by bertenvdb » 2015-01-22 01:25

Will post a topic on OpenNMS as soon as I wake up in the morning.

Thanks for the support !

For reference or curious people:

Re: Must run as root, but I am already root

#10 Post by fsmithred » 2015-01-22 13:23

FWIW, here’s another way to do the same test:

Re: Must run as root, but I am already root

#11 Post by impensj » 2016-07-05 17:24

The script expects the `id` command to return a line containing uid= but gets a line containing UID= instead.

«This script must be run as root»

Thread Tools
Display

«This script must be run as root»

I am trying to install a program, but when I enter «./install» in the terminal, I get the message:

«This script must be run as root»

How can I run it as root, and what does that mean ?

«This script must be run as root»

root is the privileged adiminstrator’s account in Linux. It’s usually needed for example to install software outside your home folder.

Be careful what you do and run as root. Only run programs and scripts from trustworthy sources that way as the can harm your system.

«This script must be run as root»

I used the «sudo ./install» command and it asked me for my password, which I entered. Then I got the message «command not found», though I navigated exactly to the directory where it is inside.

I am trying to install Avira Antivir Personal for Linux, if that helps. I unzipped the gz package to the /tmp folder in the main drive, where Linux is installed. I renamed it to «antivir» since the original name was long and complicated.

Yet I cannot get it to install.

«This script must be run as root»

Do I have to enter «sudo ./install» exactly or something like «sudo cd /tmp/antivir/install» ?

«This script must be run as root»

I quote from the Terminal with translations in bold, since it is the German version:

So first it asks me for permission, and when I enter «sudo» before the «./install» it suddenly does not find the command anymore ?!

But when I open the folder with the file manager, the install command/file is clearly there !

«This script must be run as root»

Could it be that the program, though written for Linux, is not compatible with Ubuntu ?

Last edited by Ali_Barba; June 15th, 2012 at 11:38 PM .

«This script must be run as root»

Maybe somebody could download the program, too, and see whether it works ? The source is definitely trustworthy, one of the major antivirus companies. But maybe they made some mistake while writing the installer and it is corrupted ?

«This script must be run as root»

Please post back if you have any further questions or comments.

Comments

oleiolei commented Mar 20, 2018

First, before you have the script running, it’s necessary to install a software called docker on Amazon EC2 Ubuntu system, where docker is not pre-installed.
Second, it doesn’t work. After running the script, the server doesn’t show any api. It stopped at «starting Watchtower. OK», which is obviously not OK.

The text was updated successfully, but these errors were encountered:

fortuna commented Mar 20, 2018

Thanks for the feedback, and sorry for your trouble.

When you run docker ps , does it show a shadowbox container? That’s the core of the service.

You can get the JSON needed to set up the Server Manager with

If you’d like to try again, the server installation on EC2 was tested using the image ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20180126 — ami-66506c1c (from Community AMIs)

What we did to get it working was:

Under «Configure Security Group», added a «Custom TCP Rule» and a «Custom UDP Rule». Set the Port Range for both to 1024-65535 , and Source to 0.0.0.0/0

  1. SSH in as user «unbuntu»
  2. curl -sS https://get.docker.com/ | sh
  3. sudo usermod -aG docker $USER

Because «ufw status» requires «sudo», we accidentally think that ufw is enabled when it is not by default

Could you try that and let us know if it still doesn’t work?

Comments

muhdhabeeb commented Oct 22, 2019

The text was updated successfully, but these errors were encountered:

willshot commented Oct 23, 2019

type apt-get install fcrackzip and install it

jmbluethner commented Oct 31, 2019

what a question . xD

DavideRoccia commented Dec 19, 2019

Type: sudo apt-get install fcrackzip

type apt-get install fcrackzip and install it

imvrajshah commented Mar 31, 2020

Hey i have tried using the sudo command

can u please help me resolve this issue

jmbluethner commented Mar 31, 2020 •

Maybe your repositories are a bit outdated.

Gimhan-minion commented Apr 28, 2020

If you are using ubuntu terminal on windows, Try using

ramez5566 commented May 20, 2020

i need help for the fcrackzip install

ramez5566 commented May 20, 2020

did you solve it out
.

Vi-u777 commented Apr 7, 2021 •

what Should i do

Noorul720 commented May 17, 2021

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Demystifying `root` on macOS, Part 3 — `root` and Scripting

sudo is very useful when working interactively in the shell. However, when you are scripting workflows then you don’t want to encounter the interactive prompt for authentication.

Sudo in Scripts

You will write scripts that require root privileges to perform their tasks. Many novice scripters will simply add the sudo command to their scripts. For example:

When you invoke this script from the command line, it will actually work as expected, since the first sudo will prompt the password and the second sudo will use the cached credentials.

In many cases where the script already has root privileges, it will work also, because sudo when run as root will not prompt for authorization again.

In most contexts, the scripts should already be running with root privileges so sudo in the script is not necessary.

You should not use sudo in your management scripts. When commands inside a script require root privileges, you should invoke the entire script with sudo :

Running a Process as Another User

Update: 2020-08-25 macOS has changed and I had a few things to add. Rather than keep modifying this post, I decided to make a new post with some updated code.

Getting the Current User

The ‘official’ method is to use the SystemConfiguration framework, and from a script this is easiest with scutil :

You can use this code snippet as a template:

AppleScript

Will run like this:

Beyond the Shell

These tasks are not controlled by sudo but by a separate mechanism. The data for that mechanism is stored in the authorization database, which we will cover in the next post.

Здесь VPS на BrainyCP за 2$ в месяц, а здесь 50GB шаред-хостинг на BrainyCP за 1.9$ в месяц

MQLab

Сообщения: 1
Зарегистрирован: Ср апр 22, 2020 10:09 am

CentOS 7.7 + BrainyCP + Jail + Bitrix ENV

Проконсультируйте пожалуйста как развернуть Bitrix ENV окружение в Jail управляемый BranyCP.

Установил Centos 7.7 минимум, установил BrainyCP. в Jail прописал следующие строки

Создал хост-аккаунт, создал группу хост-аккаунта, в настройках группы включил доступ root

при запуске скрипта установки Bitrix ENV выскакивает строка в терминале

This script needs to be run as root to avoid errors.

Добавил созданный хост-аккаунт в группу root, таже ситуация.

Подскажите как в Jail развернуть Bitrix ENV



Аватара пользователя

creogen

Сообщения: 34
Зарегистрирован: Вт янв 12, 2021 11:52 pm
Откуда: Украина

Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV


Вт янв 19, 2021 7:59 am

Изображение


confignsk

Сообщения: 14
Зарегистрирован: Пн дек 21, 2020 1:38 am

Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV


Вт мар 30, 2021 8:08 am

А еще вечно после их обнов потерянные вечера. У Camouf есть видео, как настроить данную панель под битру. Этого для начала хватит. Потом под 1с интеграцию допилишь со временем сам и будет счатье. Главное подумать надо над тем какой конектор выбрать, fastcgi или phpmod, есть нюансы еще не познанные с http авторизацей при обмене с 1с.


GHBB

Сообщения: 11
Зарегистрирован: Ср фев 26, 2020 12:45 pm

Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV


Вс апр 04, 2021 9:45 pm


iLuckyGUY

Сообщения: 2
Зарегистрирован: Пн апр 20, 2020 12:39 am

Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV


Вс июн 27, 2021 7:33 am

«Просто мнение» от подробной инструкции обычно отличается квалификацией и опытом!
Вы конечно можете поднять сайт на Bitrix на любом похожем стеке и панели (или без панели вообще), НО, как написано в инструкциях официального окружения (Bitrix ENV) работа (имеется ввиду корректная) всех модулей в этом случае не гарантируется.

Например при работе CRM под BrainyCP отклеивается push сервер, и не «приклеивается» потом самостоятельно, а композитная технология работает примерно никак без оф.окружения. А нужен ли вам глючный полуБитрикс решать вам самим, только не надо потом строить выводы на основании таких «научных изысканий». Делается всё ИЛИ по инструкции ИЛИ без гарантий. Если разработчик продукта даёт для него ЦЕЛОЕ web окружение своё, то это не просто так.

Те кто это писал совсем не глупые люди, то что в Bitrix официальном отстаёт всё примерно на 5 лет соглашусь. Очень долгое тестирование и ввод в эксплуатацию например модулей которые к моменту ввода уже частично утратили свою актуальность и устарели, как например с обновлением PHP (на момент записи по дефолту доступна версия 7.3, а чтобы 7.4 поставить надо beta версии подключать в окружении) это в то время когда имеет смысл переписывать под 8 версию уже всё. То же самое с поддержкой самой платформы (йа про ось). Официальная поддержка CentOS 7 прекратится скоро, а в ответах на форуме Bitrix по поводу CentOS 8 — «размытие»

Но так у них было всегда и со всем, за то работало без глюков.

BrainyCP — как инструмент отличная панель, но для корректной работы таких «девайсов» как Bitrix нужна или инструкция от разработчиков (как настроить чтобы работало как в Bitrix Env) или юзать официальное окружение для сайтов на Битрикс и их CRM


iLuckyGUY

Сообщения: 2
Зарегистрирован: Пн апр 20, 2020 12:39 am

Re: CentOS 7.7 + BrainyCP + Jail + Bitrix ENV


Вс июн 27, 2021 7:42 am

MQLab писал(а):

Ср апр 22, 2020 10:44 am

Всем привет.

Проконсультируйте пожалуйста как развернуть Bitrix ENV окружение в Jail управляемый BranyCP.

Установил Centos 7.7 минимум, установил BrainyCP. в Jail прописал следующие строки

Создал хост-аккаунт, создал группу хост-аккаунта, в настройках группы включил доступ root

при запуске скрипта установки Bitrix ENV выскакивает строка в терминале

This script needs to be run as root to avoid errors.

Добавил созданный хост-аккаунт в группу root, таже ситуация.

Подскажите как в Jail развернуть Bitrix ENV

поверх установленной панель BrainyCP?? никак!
ставится ИЛИ одно ИЛИ другое.
Если у Вас сайты на Bitrix все работают то на голую ось ставьте скриптом Bitrix ENV если Вы хотите использовать BrainyCP для управления сервером и сайтами, то под тот сайт который на Bitrix индивидуальные настройки связки веб-сервера просто сделайте


Script needs to be run as root error after already using become, become_user, and become_method

Writing a task to run an install script and normally it would have to be run with : sudo ./install.sh

My task looks like:

The error I am getting is:

Would appreciate any insight!

Switch to Trending sort

Alternatively, you may consider a reversed scenario when the installation starts as root, and does sudo to jenkins when required.

«This script must be run as root»

Thread Tools
Display

«This script must be run as root»

I am trying to install a program, but when I enter «./install» in the terminal, I get the message:

«This script must be run as root»

How can I run it as root, and what does that mean ?

«This script must be run as root»

root is the privileged adiminstrator’s account in Linux. It’s usually needed for example to install software outside your home folder.

Be careful what you do and run as root. Only run programs and scripts from trustworthy sources that way as the can harm your system.

«This script must be run as root»

I used the «sudo ./install» command and it asked me for my password, which I entered. Then I got the message «command not found», though I navigated exactly to the directory where it is inside.

I am trying to install Avira Antivir Personal for Linux, if that helps. I unzipped the gz package to the /tmp folder in the main drive, where Linux is installed. I renamed it to «antivir» since the original name was long and complicated.

Yet I cannot get it to install.

«This script must be run as root»

Do I have to enter «sudo ./install» exactly or something like «sudo cd /tmp/antivir/install» ?

«This script must be run as root»

I quote from the Terminal with translations in bold, since it is the German version:

So first it asks me for permission, and when I enter «sudo» before the «./install» it suddenly does not find the command anymore ?!

But when I open the folder with the file manager, the install command/file is clearly there !

«This script must be run as root»

Could it be that the program, though written for Linux, is not compatible with Ubuntu ?

Last edited by Ali_Barba; June 15th, 2012 at 11:38 PM .

«This script must be run as root»

Maybe somebody could download the program, too, and see whether it works ? The source is definitely trustworthy, one of the major antivirus companies. But maybe they made some mistake while writing the installer and it is corrupted ?

«This script must be run as root»

Please post back if you have any further questions or comments.

How to stop a script from running if it’s not root (and echo «Not running as root! Exiting

Here’s my source:

If run with elevated privileges, it just runs as normal. Any ideas? Thanks!

4 Answers 4

zsh and bash make that available in the $EUID variable, so you can do:

With any POSIX-like shells, you can use the id standard command:

Require script to be run as root (or with sudo)

I’m trying to write a bash script (in Ubuntu) that will backup a directory using tar.

How can I do a check in the script so that it can only be run as root (or with sudo)?

I know there has to be an easy solution, I just haven’t been able to find it by googling.

7 Answers 7

To pull the effective uid use this command:

If the result is ‘0’ then the script is either running as root, or using sudo. You can run the check by doing something like:

I assume you know that by changing the ownership to root

chown root:root file

and setting the permissions to 700

you will accomplish the same thing — without the suggestion to run as sudo.

But I will post this answer for completeness.

The bash variable $EUID shows the effective UID the script is running at, if you want to make sure the script runs as root, check wether $EUID contains the value 0 or not:

This is better than the solution with /usr/bin/id (for bash scripts!) because it doesn’t require an external command.

Cannot run a script as root with systemctl

I need to apply a patch ram to a chip for Bluetooth on startup of a Debian linux. This patch uses /dev/mem to reset the GPIO. This updated init script for bluetooth is included in /etc/init.d/bluetooth .

My bluetooth.service is

However, when I reboot, I get an error saying `Unable to open /dev/mem: Operation not permitted»

I understand that /dev/mem is only accessible to root, but aren’t I running my init script as root?

1 Answer 1

just login as root and re-run the script

Running the script when system startup

Create a script called bluetooth.service in /etc/init.d/ directory(login as root) vi /etc/init.d/bluetooth.service

Setup executable permission on script: chmod +x /etc/init.d/bluetooth.service

Make sure this script get executed every time Debian Linux system boot up/comes up:

update-rc.d bluetooth.service defaults 100

Where, bluetooth.service: is Your startup script name defaults : The argument ‘defaults’ refers to the default runlevels, which are 2 through 5. 100 : Number 100 means script will get executed before any script containing number 101. Just run the command

This command will soft linked to /etc/init.d with numbers.

Оцените статью
Master Hi-technology
Добавить комментарий