28
votes
Accepted
How can I restore /etc/profile?
There should be a copy of the default profile in /usr/share/base-files
- 2,901
28
votes
Accepted
What goes in ~/.profile and ~/.bashrc?
It helps to understand which files get sourced when and why.
.profile is sourced by a login shell on startup. Typically, the only login shell you start is the one started when you log in, but you can ...
- 556
27
votes
Why isn't .profile sourced when opening a terminal?
I found I had to edit the Default profile. In the terminal, click Preferences > Profiles > Edit > Command > Run command as login shell
Afterwards new terminals would source .profile script.
- 371
16
votes
Configure gnome-terminal to start bash as a login shell, doesn't read .bashrc
This is neither a bad design decision, nor a bug, nor an expected behavior of shells and terminals
It is merely an unfortunate default value of a per-profile configuration option in Gnome Terminal, ...
- 161
15
votes
I cannot find .bash_profile in ubuntu
When invoking a login shell bash will looks for its config files in this order:
[0] ~/.bash_profile
[1] ~/.bash_login
[2] ~/.profile
After finding the first one, it stops looking for the others so ...
- 53.3k
15
votes
Why do I have to `source .profile` in every terminal I open?
The reason for this is that ~/.profile is only sourced by login shells. When you open a new terminal window, the shell that starts is a non-login shell by default. If you log out, and log back in, the ...
- 68.6k
14
votes
Permanent PATH variable
To permanently change PATH you need to make changes to /etc/environment file. Make a backup before editing:
sudo cp /etc/environment /etc/environment.bak
sudo nano /etc/environment
sample output:
...
- 1,242
13
votes
What goes in ~/.profile and ~/.bashrc?
~/.profile is only called when you first log into your account. Any changes you make after that it would be wise to log out and back in so settings take effect. ~/.bashrc is called every time you ...
- 38.7k
12
votes
Why ~/.bash_profile is not getting sourced when opening a terminal?
TL;DR
In classical recommended ubuntu setup, ~/.bash_profile gets evaluated only in specific occasions. And it makes sense.
Put your stuff in ~/.bashrc, it'll get evaluated everytime.
Ok, I want to ...
- 1,064
12
votes
Why are scripts in /etc/profile.d/ being ignored (system-wide bash aliases)?
in Debian for Terminal session I solved this problem for all user so:
added to
sudo nano /etc/bash.bashrc
block
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ];...
12
votes
Why is setting alias in .profile not working?
There are two related reasons why aliases don't always work when put in the .profile file. The first is that the .profile (or .bash_profile) file is only run for a login shell. If you are starting ...
- 131
11
votes
What are login and non-login shells?
I do not think that correct answer can be given without “technical jargon”. Since this question is the first one popping up in Google for the query “what is a login shell” I am providing a more ...
- 211
9
votes
Where is my PATH variable being set?
The PATH could be set in any of the various files bash reads when it starts. To find them all, run this:
grep --color -H 'PATH=' ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
...
- 96.8k
9
votes
Accepted
"qmake" is not recognized
The solution lies in using update-alternatives(8). For more information on the reasoning behind it, refer to What exactly does `update-alternatives` do?
sudo update-alternatives --install /usr/bin/...
- 726
9
votes
Accepted
Ubuntu Desktop: Why the .profile script is executed in an interactive non-login shell?
Scripts that are executed for a login shell (systemwide /etc/profile, any script in /etc/profile.d, your local ~/.profile and the other files you list) define the environment of your current user - ...
- 78.1k
8
votes
Accepted
Is .profile read upon GUI login
Quoted from https://help.ubuntu.com/community/EnvironmentVariables#A.2BAH4-.2F.profile
~/.profile
In this file you can also place environment variable assignments,
since it gets executed ...
- 81.8k
8
votes
Accepted
How do I get Ubuntu to use Anaconda's python instead of the standard /usr/lib/python...?
The tilde (~) character is not expanded when enclosed in quotes (even double quotes, which allow most other filename expansions). You should replace ~ by $HOME in the PATH export:
export PATH="/usr/...
- 129k
8
votes
Accepted
`alias` command in `.profile` not recognized until `source .profile` is called
TL;DR: As Gunnar Hjalmarsson says, put aliases in ~/.bash_aliases.
The commands in ~/.profile are run by login shells. That file is a good place to do things that should be done once at the beginning ...
- 115k
8
votes
What goes in ~/.profile and ~/.bashrc?
chepner's answer covers the overall principles. There are a few other subtleties that you want to take note of.
First, login shells do not source .bashrc even if they are interactive. Thus, you ...
- 285
7
votes
How to fix ~/.profile and ~/.bashrc syntax errors
This can happen if your files have a non-printing byte sequence at the start - for example a byte order mark - perhaps as a result of having edited them in a word processor program or Windows text ...
- 129k
6
votes
Permanent PATH variable
Type the following in a terminal window
export PATH=/media/De\ Soft/mongodb/bin:$PATH
Close the terminal and restart the computer. The path should include /media/De\ Soft/mongodb/bin when you type ...
6
votes
Accepted
Help me understand .profile, .bashrc, etc
To put it (very) simple: ~/.profile is sourced when you log in, while ~/.bashrc is sourced when you open a terminal window.
6
votes
Accepted
Shell prompt customization and cmd behavior
You must make sure the non-printing characters in the prompt are in escaped square brackets, otherwise bash cannot calculate the size of the prompt correctly. I think I have fixed it for you:
PS1='\[\...
- 68.6k
6
votes
How to set default umask in Ubuntu 17.04?
To set permissions for all directories and files that are created day-forward by any user:
sudo nano /etc/pam.d/common-session
Find the line with "session optional pam_umask.so"
Change this to "...
- 584
5
votes
Accepted
Add executable to Path
Try this
export PATH="$PATH:/opt/activator-dist-1.3.5"
Open a terminal and type source .profile
Then type activator
- 3,098
5
votes
Accepted
repair ~./profile file
You can first try to just copy the default .profile from the original copy found in /etc/skel/:
First, it is recommended to make a backup of your profile first just in case (Thank you wjandrea):
/...
- 38.7k
5
votes
Messed with my /etc/profile and now an error pops up every time I log in
The part here:
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
fi
has to look like this:
if [ -d /etc/profile.d ]; then
for i in /etc/...
- 32.7k
5
votes
Accepted
Launch words to my ".profile" not executing
Points:
By doing sudo vi ~/.profile, you have opened and edited your .profile i.e. "$HOME"/.profile as root, this is because shell does tilde (~) expansion first, so sudo vi gets the full path to the ...
- 89.3k
5
votes
Accepted
How do I explain the contents of the profile file
The below answer is based on .bash_profile vs. .bashrc by Josh Staiger. For more details please review the content of that page.
According to the bash man page, .bash_profile is executed for login
...
- 12.6k
5
votes
How to set default umask in Ubuntu 17.04?
tl; dr: Replace UMASK 022 by e.g. UMASK 027 in file /etc/login.defs but doesn't work 100%.
Documentation
See the man pages (20.04) for info on this. There are several places where it can be set: I ...
- 3,781
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
.profile × 198bash × 77
bashrc × 44
command-line × 38
environment-variables × 34
login × 28
scripts × 12
paths × 10
14.04 × 8
18.04 × 6
permissions × 6
sudo × 6
startup × 6
20.04 × 5
gnome-terminal × 5
alias × 5
user-profile × 5
16.04 × 4
kubuntu × 4
firefox × 4
users × 4
boot × 3
12.04 × 3
xubuntu × 3
java × 3