Skip to main content
41 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 ...
chepner's user avatar
  • 686
31 votes
Accepted

How can I restore /etc/profile?

There is a copy of the system default profile in /usr/share/base-files
stumblebee's user avatar
  • 3,710
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.
Billious's user avatar
  • 371
18 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 ...
Terrance's user avatar
  • 42.1k
16 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 ...
Ravexina's user avatar
  • 55.9k
15 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: ...
Xaqron's user avatar
  • 1,272
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 ...
Zanna's user avatar
  • 70.8k
14 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 ...
vaab's user avatar
  • 1,094
13 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 ...
Tony McGregor's user avatar
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 ];...
Nikolay Baranenko's user avatar
12 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 ...
cjs's user avatar
  • 324
10 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/...
ben-Nabiy Derush's user avatar
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 - ...
vanadium's user avatar
  • 89.8k
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 ...
Eliah Kagan's user avatar
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 ...
steeldriver's user avatar
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 ...
Nivedita Velagaleti's user avatar
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='\[\...
Zanna's user avatar
  • 70.8k
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 "...
TooManyPets's user avatar
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 ...
heemayl's user avatar
  • 92.2k
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 ...
Yaron's user avatar
  • 13.2k
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/...
Videonauth's user avatar
  • 33.5k
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): /...
Terrance's user avatar
  • 42.1k
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 ...
Daniel's user avatar
  • 4,030
5 votes

What are the dangers of sourcing ~/.profile from ~/.bashrc?

Without knowing your .bashrc and your .profile, we can't say. For example, the default .profile on Ubuntu sources .bashrc. Now if you source .profile from .bashrc, you get an infinite loop: $ bash ...
muru's user avatar
  • 200k
5 votes
Accepted

How do I avoid having to manually source ~/.profile or ~/.bashrc to get "LD_LIBRARY_PATH" to work?

Those library paths probably should go in a configuration file under /etc/ld.so.conf.d/ ... So create a file e.g. mylibs.conf under that directory and add those paths one path per line (no colons, no ...
Raffa's user avatar
  • 32.9k
4 votes

Where is my PATH variable being set?

To find all places where $PATH environment variable is changed use this: sudo grep -rnw --exclude-dir={boot,dev,lib,media,mnt,proc,root,run,sys,/tmp,tmpfs,var} '/' -e "PATH=" This will search all ...
WinEunuuchs2Unix's user avatar
4 votes
Accepted

Why does my xprop- command fail on login, if I run it from ~/.profile?

The issue As I already mentioned in comments, the issue is timing. (commands to-) Configuring desktops is typically something that will break if the desktop isn't ready for it, and your command simply ...
Jacob Vlijm's user avatar
  • 84.2k
4 votes
Accepted

How can I configure the steps of font size changes in the terminal?

The script below will set the font size, of all profiles at once, in steps of 0.5. You will have to see if this is sufficient for you; the terminal does not react on all steps. In my case, there was ...
Jacob Vlijm's user avatar
  • 84.2k
4 votes
Accepted

Messed with my /etc/profile and now an error pops up every time I log in

The for conditional construct ends in done, which is missing in your case. Check the ^^^^ mark below: if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . ...
heemayl's user avatar
  • 92.2k
4 votes

Why is setting alias in .profile not working?

The right way to do this in Ubuntu is to add your alias to ~/.bash_aliases. Create the file if it doesn't exist. This file (if present) is called from the default ~/.bashrc, and the alias will be ...
Emilio's user avatar
  • 321

Only top scored, non community-wiki answers of a minimum length are eligible