Tag Info

Hot answers tagged

38

The file $HOME/.profile is used by a number of shells, including bash, sh, dash, and possibly others. From the bash man page: When bash is invoked as an interactive login shell, ... 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 ...


35

When you log in, the file ~/.profile is read by the login shell (ksh for you). You can instruct that login shell to replace itself by bash. You should take some precautions: Only replace the login shell if it's interactive. This is important: otherwise, logging in in graphic mode may not work (this is system-dependent: some but not all systems read ...


28

~/.profile is the right place for environment variable definitions and for non-graphical programs that you want to run when you log in (e.g. ssh-agent, screen -m). It is executed by your login shell if that is a Bourne-style shell (sh, ksh, bash). Zsh runs ~/.zprofile instead, and Csh and tcsh run ~/.login. If you log in under an X display manager (xdm, ...


26

The organization of configuration files is much less uniform than your questions seem to imply. There is no "class", there is no "hierarchy", and there is no global "configuration czar" nor committee that decrees a common syntax or other nice clean generalizations like the ones you are seeking. There is only a multitude of separate applications like R, ...


17

Why are these files not a part of /etc/profile if they are also critical to Bash startup ? If you mean, "Why are they not just combined into one giant script?", the answer is: Because that would be a maintenance nightmare for the people who are responsible for the scripts. Because having the scripts loaded as independent modules makes the whole ...


15

The text displayed before the login prompt is stored in /etc/issue (there's a related file, /etc/motd, that's displayed after the user logs in, before their shell is started). It's just a normal text file, but it accepts a bunch of escape sequences: \b -- Baudrate of the current line. \d -- Current date. \s -- System name, the name of the operating system. ...


14

The .profile was the original profile configuration for the Bourne shell (a.k.a., sh). bash, being a Bourne compatible shell will read and use it. The .bash_profile on the other hand is only read by bash. It is intended for commands that are incompatible with the standard Bourne shell.


12

That line in your .profile should be one of export PATH="$PATH:$HOME/Unix/homebrew/bin" PATH="$PATH:$HOME/Unix/homebrew/bin" PATH=$PATH:$HOME/Unix/homebrew/bin PATH=$PATH:~/Unix/homebrew/bin The ~ character is only expanded to your home directory when it's the first character of a word and it's unquoted. In what you wrote, the ~ is between double quotes ...


12

The file ~/.bash_profile is read by bash when it is a login shell. That's what you get when you log in in text mode. When you log in under X, the startup scripts are executed by /bin/sh. On Ubuntu and Mint, /bin/sh is dash, not bash. Dash and bash both have the same core features, but dash sticks to these core features in order to be fast and small whereas ...


11

This is slightly kludgey, but you can cause bash to be the shell you're using upon login by creating a .profile file in your home directory, containing SHELL=`type -P bash` exec bash -l This will cause the ksh session to be replaced with a bash session. You won't have to type exit (or ^D) twice, as you would if you manually started a new bash session ...


11

Create .bash_profile in your home directory and add these lines: export SHELL=/bin/zsh exec /bin/zsh -l Update: .profile may work as a general solution when default shell is not bash. I'm not sure if .profile may be called by Zsh as well that it could go redundant but we can do it safely with a simple check: export SHELL=/bin/zsh [ -z "$ZSH_VERSION" ] ...


9

You are mostly wrong to think that .bash_profile should be sourced when X starts. .bash_profile is the startup configuration script of bash. There exists no standard mandating X to source .bash_profile. What you are thinking of is rather .profile. Originally it was the startup configuration file of sh. Today many distributions have their desktop environment ...


9

.bashrc and .bash_profile are NOT scripts. They're configuration file which get sourced every time bash is executed in one of 2 ways: interactive login The INVOCATION section of the bash man page is what's relevent. A login shell is one whose first character of argument zero is a -, or one started with the --login option. An interactive shell ...


8

There is no such thing like a environment config file for different shells, because its even shell specific how they are defined. In csh you use setenv in bash you use export to define them. Anyway you could write your own config file and include it with source in the dotfiles of your shells.


8

I personally use the following bash function to do this: so() { local tmpdir="$(mktemp -d)" local tmprc="$(mktemp)" cat > "$tmprc" << EOF PS1='\\$ ' cd "$tmpdir" EOF env - HOME="$HOME" TERM="$TERM" bash --rcfile "$tmprc" rm -rf "$tmpdir" "$tmprc" } Here is what it does, in order: Create a temporary directory (to use as our ...


8

.bashrc scripts are only run by bash itself. They're not free-standing, and they're not intended to be executed by the system. (In fact, they're generally not marked executable, and, as you say, they don't have a shebang line.) Such scripts are intended to be sourced, since they generally do things like change environment variables ($PATH, for example), ...


8

But shouldn't it have been sourced during the graphical login? There's a minor debate about that on which some graphical logins take an unusual stance... I add $HOME/bin to $PATH from ~/.profile. However, it seems it is not sourced during login. I use a login manager - lxdm I think Correct. Most DM's do read ~/.profile when you log in. However, ...


7

It seems worth noting that the command you mention in your question ssh name@host echo $PATH will pretty much never be useful. The variable substitution for $PATH is done by your local shell, and passed to ssh which executes echo on the remote system to print the contents of the path variable, as it expanded on your local system. Here is an example of ...


7

In the post installation script of package base-files (i.e. /var/lib/dpkg/info/base-files.postinst) it is copied from /usr/share/base-files/profile.


7

Those files are specific to an application, but are sourced at shell startup, not when the application starts. A configuration directory is used here for the same reason that it is found in many other places. This allows an application or software package to modify configurations. This wouldn't be possible without a split configuration, as multiple packages ...


6

It's not called bash_profile, but the standard place for global bash configuration is /etc/bash.bashrc. It's usual to call this from /etc/profile if the shell is bash. For example, in my /etc/profile I have: if [ "$PS1" ]; then if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then # The file bash.bashrc already sets the default PS1. # PS1=’0 ...


6

Generic Colouriser Generic Colouriser could be used for this application. It has the capability to identify via regular expressions bits of text, and then assign a color to any that match. # this is probably a pathname regexp=/[\w/\.]+ colour=green count=more This will match /usr/bin, /usr/local/bin/, /etc/init.d/syslogd and similar strings and paint it ...


6

The .profile dates back to the original Bourne shell known as sh. Since the GNU shell bash is (depending on its options) a superset of the Bourne shell, both shells can use the same startup file. That is, provided that only sh commands are put in .profile For example, alias is a valid built-in command of bash but unknown to sh. Therefore, if you had only a ...


6

If you're using bash, you may have better luck declaring it as: function grom() { … } (Note: function will not work in strict POSIX shells like dash!) @aug suggested (via edits to this answer) that this is due to a conflicting alias (or, less plausibly, a builtin that somehow got defined). The reserved word function either alters the loading order to ...


5

Your .profile should be loaded when you log in, not in each terminal. Its purpose is to define environment variables and other settings for the whole session (including your window manager and any program you start from it such as Emacs). It's normal that ~/.profile isn't read when you start a terminal: it's rare to need to define environment variables then. ...


5

The file /etc/issue and /etc/issue.net are the files displayed by the login program. You can put special expansion characters in it, as noted on the other answer. But you may also want to try the linux_logo program. It can generate really nice ASCII art issue files for you.


5

There is no common file, but you can make every shell read from a common file. bash reads from .bash_profile or .bashrc zsh reads from .zprofile and .zshrc ksh reads from .profile or $ENV So here's what I do: ~/.env # Put environment variables here, e.g. PATH=$PATH:$HOME/bin ~/.shrc test -f "$HOME/.env" && . "$HOME/.env" # Put interactive ...


5

Yes, but it's the worst thing you can do. There are different users with different permissions in your OS. And that is on purpose. Giving root permissions to your user permanently will compromise the security of the system. (Remember Windows 9x and all the viruses ?) Executing a command with sudo wont need any of your customization stuff I guess, unless you ...


5

If you want it to be global, modify /etc/profile or add a script to /etc/profile.d If you want it to be user-specific, modify /home/$USER/.profile


5

You might want to have a look at toilet. The following has been incorporated in the banner of one of the servers at my lab: You can install it on Debian based systems with sudo apt-get install toilet TOIlet prints text using large characters made of smaller characters. It is similar in many ways to FIGlet with additional features such as ...



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