Tag Info

Hot answers tagged

30

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


30

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


21

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


17

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


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


10

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


10

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


9

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.


9

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


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.


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.


6

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


6

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


6

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


6

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


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

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

Simply source it: . ~/.profile Or do a login with su -l <user>, this doesn't require a logout.


5

If you just want to launch a program at startup, a login script is the wrong place to do it. Instead, write a systemd unit file (since Arch seems to use systemd). Create /etc/systemd/system/scanner.service (or whatever.service) : [Unit] Description=(description of your program) [Service] ExecStart=/usr/bin/mono /path/to/scannerSoftware.exe 127.0.0.1 ...


5

When I type set | wc the result is 9571 bytes long! Assuming you got that number correct, it is in fact quite small, probably because you are using QNX. On a normal desktop system, it is much larger. Here's what I get on fedora 20: > set | wc --bytes 133195 133 kB. I did not count the entries as many of them are sourced functions (git seems to ...


5

Normally you can use chsh as a non-root user. But it's occasionally disabled, usually in sites that use some form of networked user database like NIS and LDAP. There might be a ypchsh (NIS) or chsh.ldap (LDAP) instead. If you can't use chsh or its variants at your site, then arrange for your login shell to exec your favorite shell, and set the SHELL ...


4

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


4

~/.profile is only executed by login shells. The program that calls the shell decides whether the shell will be a login shell (by putting a - as the first character of the zeroth argument on the shell invocation). It is typically not executed when you log in to execute a specific command. OpenSSH in particular invokes a login shell only if you don't specify ...


4

This is generally considered a very dangerous idea because it introduces the possibility that you will be tricked into executing something thinking it is something else. Say for example that somebody puts an executable named "cd" in /tmp. Being able to run things in the current folder without specifying an explicit path might mean you inadvertently run that ...


4

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


4

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


4

Updated answer based on some researching Remove duplicated welcome messages Since you login with ssh, the first welcome message should be coming from /etc/issue.net. To remove the message, just remove the contents of that file. To remove the second welcome message, remove the contents of /etc/motd. Colorize the line about mail To colorize that line, ...


4

As a general rule, strange errors like that are due to a file being called from one of the various initialization files your shell reads. Which one will depend on the shell you are using and how you are launching it. Here's a nifty function that will look through all possible bash init files and grep them for whatever you are looking for. Add these lines ...



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