tarはsudoでは使用できません

tarはsudoでは使用できません

/usr/local/使用するファイルを抽出しようとしています。

$ sudo tar -xvzf /home/vyom/Downloads/go1.19.4.linux-amd64.tar.gz -C /usr/local/
tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

しかし、私がアクセスできるディレクトリ( - など/home/vyom/abc)を変更すると正常に動作します。

$ tar -xvzf /home/vyom/Downloads/go1.19.4.linux-amd64.tar.gz -C /home/vyom/abc
go/test/typeparam/mdempsky/7.dir/b.go
go/test/typeparam/mdempsky/7.go
go/test/typeparam/mdempsky/8.dir/
go/test/typeparam/mdempsky/8.dir/a.go
go/test/typeparam/mdempsky/8.dir/b.go
go/test/typeparam/mdempsky/8.go
go/test/typeparam/mdempsky/9.go
go/test/typeparam/metrics.go
go/test/typeparam/min.go
....

gzip不足していません。

$ gzip --version
gzip 1.12
Copyright (C) 2018 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Jean-loup Gailly.

編集する:

これについていくつかの情報を得てsecure_path確認しました。

$ echo $PATH
/home/vyom/.sdkman/candidates/groovy/current/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/lib/jvm/java-17-openjdk-17.0.5.0.8-1.fc37.x86_64/bin:/usr/local/go/bin
$ sudo cat /etc/sudoers | grep "secure_path"
Defaults    secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/snapd/snap/bin

安全なパスにはすべてのフォルダが含まれてい*/binますが。-E env "PATH=$PATH"sudo

$ sudo sudo -V | grep "Value to override user's"                                  
Value to override user's $PATH with: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/snapd/snap/bin

関連内容のソースは次のとおりです。/etc/sudoers

Defaults   !visiblepw

Defaults    always_set_home
Defaults    match_group_by_gid

Defaults    always_query_group_plugin

Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
Defaults    env_keep += "MAIL QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

Defaults    secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/snapd/snap/bin

ここに問題がありますか?

関連情報