I downloaded flutter and Android studio on my linux machine. It is a kali linux installation. I want to add environment path variable for both android studio and flutter permanently so, who when I start a shell, I don't have to add them every time. I want to add to all users. I did some searching and found that you have to add the path in /etc/profile if you want to do for all users. But nothing seems to be working.

The original content of the file

# /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
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
        if [ "`id -u`" -eq 0 ]; then
            PS1='# '
            PS1='$ '

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

I added my paths using a : to separate just after else in line 4 like this


saved the file and restarted machine, and did

echo $PATH

in the shell but the output was just this:


Then I tried different method removed previous changes and added


just before export path, saved restarted the machine and it didn't work either. The echo $PATH command prints the same above paths.

How do I accomplish what I am trying to accomplish. I have looked at several similar questions on this site and most suggest what I have done above. Am I doing anything wrong?

EDIT This the contents of .profile in my user directory. I have only one user.

# ~/.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"

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

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
  • 1
    Does your user account's shell startup files reset the PATH variable? What shell are you using? – Kusalananda Apr 27 '20 at 12:49
  • @Kusalananda Hi, I did echo $0 and it said bash so I am using Bourne Again Shell. bash – OpampInverting Apr 27 '20 at 12:57
  • @Kusalananda I have added the contents of .profile from my user directory. – OpampInverting Apr 27 '20 at 13:06

Add the following line to your /etc/environment


Explained on debian wiki:

Put all global environment variables, i.e. ones affecting all users, into /etc/environment

Remember, this file is read by PAM, not by a shell. You cannot use shell expansions here. E.g. MAIL=$HOME/Maildir/ will not work!

There is no shell-agnostic and login-independent solution to the problem of how to configure the environment for all users, beyond the trivial cases that PAM can handle.

You can logout then login or source /etc/environment.

  • 1
    It worked. Thanks. I had read about etc/environment on other answers but when didn't find the environment file in etc but found profile I thought I will have to edit profile. Also most answers had mentioned profile. I am curious. Why didn't editing the profile work? I also tried added the path in .profile but it still didn't work. – OpampInverting Apr 27 '20 at 13:25
  • @OpampInverting Welcome, explained here :Using graphical display manager – GAD3R Apr 27 '20 at 13:33
  • I'm having the same issue, and trying to update the PATH in my ~/.profile has no effect. I also have no .bash_login or .bash_profile files. This really seems like a bug in Kali. – Sean Aitken Oct 1 '20 at 5:33

Recent Kali distribution 2021.1 works with updating $PATH variable in ~/.profile.

Just add PATH=$PATH:"/replace/with/your/path" to ~/.profile

Logout and login or type source ./profile in your home directory.

Check your environment with the env command.

You should see something like below

  • Recent Kali Linux releases uses zsh as the default login shell. The zsh shell does not read ~/.profile. – Kusalananda May 21 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.