Kali Linuxインストールでは環境パス変数を設定できません。

Kali Linuxインストールでは環境パス変数を設定できません。

私のLinuxコンピュータにFlutterとAndroid Studioをダウンロードしました。カリLinuxのインストールです。 Android studioとflutterの環境パス変数を永久に追加して、シェルの起動時に毎回追加する必要がないようにしたいと思います。すべてのユーザーに追加したいと思います。検索を試してみると、/etc/profileすべてのユーザーに対してこれを行うにはパスを追加する必要があることがわかりました。しかし、何も動作しないようです。

ファイルの元の内容

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
    PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

if [ "${PS1-}" ]; then
    if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
        # The file bash.bashrc already sets the default PS1.
        # PS1='\h:\w\$ '
        if [ -f /etc/bash.bashrc ]; then
            . /etc/bash.bashrc
        fi
    else
        if [ "`id -u`" -eq 0 ]; then
            PS1='# '
        else
            PS1='$ '
        fi
    fi
fi

if [ -d /etc/profile.d ]; then
    for i in /etc/profile.d/*.sh; do
        if [ -r $i ]; then
            . $i
        fi
    done
    unset i
fi

:以下のように4行にelseで区切られたパスを追加しました。

PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/user1/Flutter/flutter/bin:/home/user1/android-studio/bin"

ファイルを保存し、コンピュータを再起動して実行します。

echo $PATH

シェルにありますが、出力は次のようになります。

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

その後、以前の変更を削除して追加するさまざまな方法を試しました。

PATH=$PATH:/home/user1/Flutter/flutter/bin:/home/user1/android-studio/bin

パスをエクスポートし、マシンを保存して再起動する直前でも動作しませんでした。このecho $PATHコマンドは上記と同じパスを出力します。

私が達成したいことをどのように達成しますか?私はこのサイトでいくつかの同様の質問を見て、ほとんどが上記でやったことを提案しました。私は何が間違っていましたか?

編集する.profileこれが私のユーザーディレクトリにあります。私のユーザーは一人だけです。

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

ベストアンサー1

私も最近この問題に直面しました。 Kali Linuxのデフォルトシェルは今すぐzsh変更する必要があります。

export PATH="$PATH:/path/to/"

変える.zshrc。その後、変更を実装した後

source ~/.zshrc

PATHを見ると、echo $PATH更新されたPATHを見ることができます。シェルを再起動して確認します。

おすすめ記事