Bash - скрипт проверки root: различия между версиями

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2023
Перейти к:навигация, поиск
(Новая страница: «=== Bash - скрипт проверки root === # Am I root? if [ "x$(id -u)" != 'x0' ]; then echo 'Error: this script can only be executed by root' ex...»)
 
Строка 1: Строка 1:
 
=== Bash - скрипт проверки root ===
 
=== Bash - скрипт проверки root ===
  
# Am I root?
+
 
if [ "x$(id -u)" != 'x0' ]; then
+
# Am I root?
 +
if [ "x$(id -u)" != 'x0' ]; then
 
     echo 'Error: this script can only be executed by root'
 
     echo 'Error: this script can only be executed by root'
 
     exit 1
 
     exit 1

Версия 11:11, 23 мая 2022

Bash - скрипт проверки root

# Am I root?
if [ "x$(id -u)" != 'x0' ]; then
   echo 'Error: this script can only be executed by root'
   exit 1

fi

exit 1 - завершение с ошибкой