Могу ли я настроить sudo для вывода запускаемой команды?

заставить пользователя записывать названия треков в файл, по одному на строку.

в вашем скрипте читать заголовки в массив:

mapfile -t titles < track_title_file.txt

Затем обработайте элементы. Например:

for index in "${!titles[@]}"; do
    printf "TITLE%d=%s\n" "$index" "${titles[index]}"
done
1
09.02.2020, 20:55
3 ответа

sudo не предоставляет эту функциональность, вы можете определить функцию:

echo_run(){
    echo "About to run [$@]"
    "$@"
}

# Then you can do : echo_run sudo vim test.sh
-1
28.04.2021, 23:24
sudo -l <somecommand> <someparameters> 

Если команда указана и разрешена политикой безопасности, полный -путь к команде отображается вместе со всеми аргументами командной строки.

Вот отрывок изman sudo

-l, --list  If no command is specified, list the allowed (and forbidden) commands for the invoking user (or the user speci‐
                 fied by the -U option) on the current host.  A longer list format is used if this option is specified multiple
                 times and the security policy supports a verbose output format.

                 If a command is specified and is permitted by the security policy, the fully-qualified path to the command is
                 displayed along with any command line arguments.  If command is specified but not allowed, sudo will exit with
                 a status value of 1.
2
28.04.2021, 23:24

Добавьте `set -x' перед вызовом sudo.

[steve@centos8 ~]$ cat x1
#!/bin/bash
echo foo
set -x
sudo id
set +x
echo bar
[steve@centos8 ~]$./x1
foo
+ sudo id
[sudo] password for steve:
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
+ set +x
bar
[steve@centos8 ~]$
1
28.04.2021, 23:24

Теги

Похожие вопросы