From owner-freebsd-questions@FreeBSD.ORG Thu Sep 6 15:31:52 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A103E16A468 for ; Thu, 6 Sep 2007 15:31:52 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 1A47113C465 for ; Thu, 6 Sep 2007 15:31:51 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (vader.bytemobile.ondsl.gr [83.235.244.135]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-8) with ESMTP id l86FVavR021433 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 6 Sep 2007 18:31:44 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.1/8.14.1) with ESMTP id l86FVK9Q002740; Thu, 6 Sep 2007 18:31:35 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.1/8.14.1/Submit) id l86FVKpX002739; Thu, 6 Sep 2007 18:31:20 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 6 Sep 2007 18:31:19 +0300 From: Giorgos Keramidas To: Albert Shih Message-ID: <20070906153119.GB2498@kobe.laptop> References: <20070906150602.GE61602@pcjas.obspm.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20070906150602.GE61602@pcjas.obspm.fr> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.958, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.44, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: bash on login. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2007 15:31:52 -0000 On 2007-09-06 17:06, Albert Shih wrote: > Hi all > I'm using bash for standard shell, what I don't understand is when I'm > connect by ssh on my server the bash don't parse .bashrc file. Because .bashrc is not loaded by login shells. Read the manpage of bash(1) for more details, and make sure you pay A LOT of attention to the ``INVOCATION'' section: 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 commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists. When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc. > But if in the bash session I type «bash» this time the .bashrc is use. Yes. This is no longer a login shell. It's merely an interactive shell, so bash ignores .bash_profile and reads .bashrc instead. > How can I make the .bashrc file is read when I connect by ssh ? My preferred setup uses both files. The .bash_profile file acts solely as a 'delegation script', which loads all my preferences from .bashrc. The full contents of my .bashrcc file are something like this: test -f ~/.bashrc && . ~/.bashrc true All my preferences, options, environment variables, and other bash configuration is stored in ~/.bashrc. This way both login shells and interactive shells use precisely the same environment. - Giorgos