Tag Info

Hot answers tagged

61

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


29

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 ...


17

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 ...


17

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 ...


15

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, or run a command such as su ...


7

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 ...


6

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


6

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 ...


6

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


5

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.


5

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.


5

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 ...


4

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


4

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 ...


4

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 ...


4

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


4

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


4

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 ...


3

Here is the story: ~/.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. (source) solution: export the variables defined in .profile.         export ...


3

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.


3

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 ...


3

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


3

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 ...


3

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


3

Changing the profile with PATH=xxx;export PATH will not prevent you from loggin in, at least not from the console. Switch to the text console with: CTL-ALT-F1, login, edit the file with your prefered text editor.


3

This may not be the answer you're looking for, but I would say no. There are other folders like 'bin', 'usr', 'etc', etc. that have most likely been modified since your installation. So, unless you just installed and haven't downloaded any apps or modified anything, simply deleting the 'home' folder would not turn it into a clean slate.


3

From the Bash manual: When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes ...


3

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


2

It's because traditionally environment variables go only in /etc/profile or .profile. The bashrc file is for things like aliases, prompt settings, shell options and so forth (i.e. things that relate directly to the shell).



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