Correcting path setting in ~/.profile file

by Smile   Last Updated December 07, 2017 10:02 AM

There is a line in ~/.profile which is

PATH="$HOME/bin:$HOME/.local/bin:$PATH"i

I'm not sure about the last i.

  • Should I remove it??
  • Isn't it a syntax error??


Answers 3


The extra i at the end of the line is typo, should be removed

Yaron
Yaron
December 07, 2017 09:28 AM

Yes it is a syntax error, the actual .profile should look like this unless you changed things around:

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

So to add as you asked in your comment simply place this at the end of your profile file:

# Manual addition for swift development snapshot
export PATH="$PATH:/home/jeremy/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-06-29-a-ubuntu16.04/usr/bin"

If you ever mess up your profile completely, there is a copy where you can get a new one from in /etc/skel/.

Videonauth
Videonauth
December 07, 2017 09:29 AM

No it's not a syntax error, it's just a letter which is appended after the expansion of $PATH, because the shell removes quotes...

$ PATH="$HOME/bin:$HOME/.local/bin:$PATH"i
$ echo $PATH
/home/zanna/bin:/home/zanna/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bini

So, as well as prepending local directories, it has effectively removed the existing /snap/bin from my PATH, and added the non-existent /snap/bini.

You can remove the i to repair your PATH.

If you did not make this change to your .profile yourself, you may want to restore the default file by running

mv ~/.profile{,.old}
cp /etc/skel/.profile ~/.profile

This renames the old .profile .profile.old (you could also delete the file if you wanted to) and replaces it with the default version for your system from /etc/skel.

Zanna
Zanna
December 07, 2017 09:39 AM

Related Questions




Can't get $(date +%F) set as environment variable

Updated June 03, 2015 00:00 AM