Questions tagged [.profile]

A user-specific (not systemwide) configuration script executed when starting login shells.

.profile is a file in each user's home directory (for example /home/octavia/.profile) that is run for login shells only. This means it will definitely be read by bash when the user logs in on a TTY (virtual terminal), but will not usually be read by bash when opening a terminal emulator inside a graphical shell. However, since the file is usually read by the graphical shell when the user logs in, variables set there may be inherited by other shells. It is therefore one place that may be used to set or modify some user-specific environment variables.

The file .profile is normally read in Ubuntu because we do not typically have a file ~/.bash_login, which would be read in preference to ~/.profile if it existed, or a file ~/.bash_profile which would be read in preference to either of those files.

Here is an example of a .profile in Ubuntu

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

As shown, ~/.profile can be used to set a for the user, overriding the one set systemwide by /etc/profile.

The code then checks to see whether the shell being run is a bash shell, and if it is, reads the user's ~/.bashrc. This means that any customisations (such as PS1 definition, aliases and functions) made in ~/.bashrc will be available in shells that read ~/.profile but not ~/.bashrc directly, unless they are overidden by commands later in the file.

Finally, the code checks to see whether the user has a directory ~/bin and if it does exist, it is added to their PATH variable. This means that users can place applications in this directory, and call them without the full path.

Additional customisations can be added to the end of the file.

Some popular questions:

What are login and non-login shells?

Why does Ubuntu's default ~/.profile source ~/.bashrc?

205 questions
20
votes
2 answers

how to reset ~/.profile to default

I have been playing around with the ~/.profile file trying to add something permanently to my $PATH variable and it seems i have done some damage. I can't log into ubuntu now. When I enter my password the screen goes black for 1 second and then it…
Adrian Buzea
  • 323
  • 1
  • 3
  • 6
5
votes
0 answers

Error found when loading /home/[myusername]/.profile

I get this error each time after logging on: Error found when loading /home/[myusername]/.profile: stty: standard input: Inappropriate ioctl for device As a result the session will not be configured correctly. You should fix the problem as soon as…
Blue
  • 51
2
votes
1 answer

Explaining the contents of the ~/.profile file

# ~/.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…
Jansen Roy
  • 49
  • 1
  • 1
  • 3
2
votes
2 answers

.xprofile broken in Ubuntu 18.04

Today I upgraded to latest Ubuntu 18.04 from 17.10, but computer says ~/.xprofile has syntax error, and could not use desktop. Only a movable mouse icon on a violet color blank screen. When I checked the .xprofile in home directory, it only…
1
vote
1 answer

~/.profile error upon Startup

I'm getting this message upon startup, just after I login as a user. I recently installed nodejs, realized I should have researched it more and installed it LOCALLY, and subsequently went through file system and deleted everything node and npm. I've…
gson78
  • 11
0
votes
2 answers

Need help with error found in home/superuser/.profile line 23

During start up, just after I log into my account, I get an error message that says: Error found when loading /home/superuser/.profile: /home/superuser/.profile line 23: export: '=': not a valid identifier As a result the session will not be…
0
votes
2 answers

error when loading .profile

This is my bashrc # LD_LIBRARY_PATH OTCL_LIB=/home/shabeer/ns-allinone-2.35/otcl-1.14 NS2_LIB=/home/shabeer/ns-allinone-2.35/lib X11_LIB=/usr/X11R6/lib USR_LOCAL_LIB=/usr/local/lib export…
0
votes
2 answers

Trying to get /etc/profile working

I have Ubuntu on Linode VPS. I intstalled latest Golang as instructed on this page (http://golang.org/doc/install) - steps taken are wget http://go.googlecode.com/files/go1.2.linux-amd64.tar.gz tar -C /usr/local -xzf go1.2.linux-amd64.tar.gz Added…
ericbae
  • 139
  • 1
  • 2
  • 4
0
votes
1 answer

How do I run a command with uxterm after running ~/.bashrc lines in Ubuntu 18.04?

My ~/.profile file has the following code source ~/.bashrc When I run the following command, uxterm firefox I do not see any log of the lines of the file ~/.bashrc on the corresponding uxterm window that gets open. I therefore understand the lines…