Hot answers tagged


~/.bash_profile is only sourced by bash when started in interactive login mode. That is typically only when you login at the console (Ctrl+Alt+F1..F6), or connecting via ssh. When you log in graphically, ~/.profile will be specifically sourced by the script that launches gnome-session (or whichever desktop environment you're using). So ~/.bash_profile is ...


To understand what's going on here, you need to understand a little background information about how shells (bash in this case) are run. When you open a terminal emulator (gnome-terminal for example), you are executing what is known as an interactive, non-login shell. When you log into your machine from the command line, via ssh, or run a command such as ...


Simply put: If you open a shell or terminal (or switch to one), and it asks you to log in (Username? Password?) before it gives you a prompt, it's a login shell. If it doesn't (like gnome-terminal), and lets you use it straight away, it's a non-login shell. If you are a normal user of Ubuntu Desktop, the only login shell is...your desktop (you type a ...


You can check if your Bash shell is started as a login-shell by running: shopt login_shell If the reply is off you are not running a login shell. Read the Bash manual's invocation section on how Bash reads (or does not read) different configuration files. Excerpt from man bash: When bash is invoked as an interactive login shell, or as a ...


Yes, that is the expected behaviour. The behaviour, in short, is as follows: bash started as an interactive login shell: reads ~/.profile bash started as an interactive non-login shell: reads ~/.bashrc Read the bash manual about startup files for more details. Personally, I think that this behaviour is strange and I have not yet found a rationalization ...


Ubuntu uses ~/.profile . you can create your .bash_profile in Ubuntu but then .profile will not be read. If we read .profile content : cat ~/.profile output # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. So use ~/.profile instead of ~/.bash_profile


This is kind of complex. First of all, the details depend on what kind of shell you are running. To plagiarize myself: When you open a terminal emulator (gnome-terminal for example), you are executing what is known as an interactive, non-login shell. When you log into your machine from the command line, or run a command such as su username, you are ...


I think it is worth mentioning that you can change the default of gnome-terminal to use a login shell (ie. bash -l) by editing the profile preferences. go to Edit -> Profile Preferences -> Title and Command tab check the "Run command as a login shell" option


~/.bashrc and /etc/bash.bashrc are run every time an interactive bash shell is started. In contrast, ~/.profile and /etc/profile are run every time any login shell is started. So it does not have to be a bash shell, but it does have to be a login shell (and many bash shell instances are not login shells). A bash shell is a shell where the shell program ...


They are configuration files. One way: Open a terminal window using Ctrl+Alt+T Run the command gedit ~/.profile Add the line export PATH=$PATH:/media/De\ Soft/mongodb/bin to the bottom and save Log out and log in again


You can run the followin command: ssh -t user@host bash --noprofile where -t option to ssh is to force tty allocation.


This is an upstream decision coming from Debian. The rationale for it is explained in this very nice wiki post, of which the following is an excerpt. The executive summary is "to ensure that GUI and non GUI logins work in the same way": Let's take xdm as an example. pierre comes back from vacation one day and discovers that his system administrator has ...


Because terminals don't usually run login shells by default. They also usually have options to run login shells, which do source .profile. To control the behaviour of login shells. Depends on the shell. For bash, see the set of startup files. Not in some sense (updating login records, for example). If you have a folder called bin in $HOME, the default ...


Do you have a .bash_profile or .bash_login in your home directory. There are these comments in the .profile file: # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists.


In the default setup on Ubuntu 12.04, the .profile file is loaded by /usr/sbin/lightdm-session. This is shell script, executed by /bin/sh. On Ubuntu, /bin/sh is dash. You've used features of bash that dash doesn't support. Dash and Bash both have the same core features, but dash sticks to these core features in order to be fast and small whereas bash adds a ...


You can edit the file using nano ~/.profile To get the default ~/.profile back use cp /etc/skel/.profile ~/.profile As this will overwrite your modified version you may want to save your version first: cp ~/.profile ~/.profile.invalid


If you open a terminal or run su the shell is not executed as a login shell but as a normal interactive shell. So it reads ~/.bashrc but not ~/.bash_profile. You can run su with the -l option to make it run your shell as a login shell. When you are working with a GUI the shell is usually never run as a login shell so it's usually fine to put all yout stuff ...


I think if you add a $HOME/bin directory it should be added to the path automatically, looking in my .profile would indicate this Yes just checked and by creating a $HOME/bin directory the next time you log in its automatically added to the path. Hope that helps


Looks like this was answered before. You have to be aware of the loading priorities of the files. [EDIT] You Have two options: (Not Recommended) Get your terminal to start as a login shell: open a terminal Go to Edit -> Profile Preferences -> Title and Command activate the "Run Command as a login shell" checkbox This way your .profile is read. But it ...


It all depends on with which user you're trying to log in. The global /etc/profile file is loaded for every user, while the ~/.profile is only loaded for the user. ~ points to the current user's home directory. So, if you would put it in /home/user-a/.profile and login as user-a, both global and its user-specific file are loaded (in that order), whereas if ...


Yes, and it is one of the feature of Linux: you can get to a console by pressing ControlAltF1 Use cd to go to the directory where you edited the file and restore the backup profile you created before you editted it ( ;) ) or just edit the file if you did not make a backup. nano .profile When you're done, ControlX to save and exit and then just run sudo ...


Just wrap it in another bash script. Your file names will be different, but I have: test(.profile) #!/bin/bash function printDate() { date } wrap(a new script you can put wherever, just change the url) #!/bin/bash cd ~/ source ./test printDate > ./date.log when run from a /bin/sh $ ls test wrap $ ./wrap $ cat date.log Wed Apr 11 11:49:39 EDT ...


If you are trying to get a script to run on login, just add it to your startup programs (system>preferences>startup applications). Anything you add to this will be read by all 3 of the D.E. For example you could write a script in /home/username/bin, and add this to your start up programs.


Quoted from ~/.profile In this file you can also place environment variable assignments, since it gets executed automatically by the DisplayManager during the start-up process desktop session as well as by the login shell when one logs in from the textual console. This ...


You can first try to just copy the default .profile from the original copy found in /etc/skel/: /bin/cp /etc/skel/.profile /home/<username>/ If for some reason that does not work, you can follow the next part to replace your .profile from its original contents: Boot your system to Recovery Mode first so that you have root capabilities to your ...


Add every subdirectory to $PATH as well. But that means editing ~/.profile everytime I move, download or git-clone new directories. No need to edit every time, try something like this: if [ -f ~/bin ]; then for i in $( find ~/bin -type d ); do PATH=$PATH:$i done fi


To permanently avoid trouble, in my .bashrc on the target system, I have: if [ -z "$SSH_CLIENT" ] ; then ... fi surrounding ssh-incompatible stuff. SSH_CLIENT is defined for shells invoked via ssh, and not for other shells. ssh user@somewhere "env >env.ssh" walk over so somewhere, login as user, and: env >env.local diff env.local env.ssh


That script itself must be sourced for it to make changes to the current shell. If you run the script, a new instance of bash is started to interpret the commands in the script. This new instance cannot alter its parent, thus any aliases that are set in the script, dies with the script.


Make sure you have logged back in (the changes happen only when you start a new shell). Additionally, try using .bash_profile instead of .profile. To test without logging back in, you can source the file directly by typing: . ~/.profile

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