Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [bashrc]

.bashrc is the primary configuration file for the bash shell.

845
votes
11answers
2.0m views

How to correctly add a path to PATH?

I'm wondering where a new path has to be added to the PATH environment variable. I know this can be accomplished by editing .bashrc (for example), but it's not clear how to do this. This way: export ...
65
votes
3answers
50k views

What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc …?

Answers to the questions on SO and askubuntu, along with poking through (and reading headers of) $HOME and /etc/, indicate a number of files that can be used to set environment variables, including: ~...
126
votes
3answers
335k views

What is the purpose of .bashrc and how does it work?

I found the .bashrc file and I want to know the purpose/function of it. Also how and when is it used?
57
votes
3answers
14k views

Why does bashrc check whether the current shell is interactive?

On my Arch install, /etc/bash.bashrc and /etc/skel/.bashrc contain these lines: # If not running interactively, don't do anything [[ $- != *i* ]] && return On Debian, /etc/bash.bashrc has: #...
6
votes
1answer
1k views

Terminal prompt overwrites current line

I have an issue with my terminal prompt line. When the line is too long it wraps on the same line and then Up arrow makes it look even worse. I have already checked Terminal prompt not wrapping ...
39
votes
3answers
45k views

using export in .bashrc

I have noticed in my .bashrc, that some lines have export in front, such as export HISTTIMEFORMAT="%b-%d %H:%M " ... export MYSQL_HISTFILE="/root/.mysql_history" whereas other have not, such as ...
10
votes
2answers
9k views

What is the difference between '.' and 'source' in shells? [duplicate]

Possible Duplicate: running script with “. ” and with “source ” I have used both the dot command '.' and 'source' to reload a given rc file (typically to update my environment variables) but I am ...
79
votes
2answers
50k views

What is the difference between interactive shells, login shells, non-login shell and their use cases? [duplicate]

Possible Duplicate: Difference between Login Shell and Non-Login Shell? I have been looking at /etc/profile. bash.bashrc to see how they are run, and notice that some are executed by non-login ...
37
votes
4answers
21k views

How can I find a rogue alias declaration?

I'm trying to find where a specific alias has been declared. I've searched all the usual places I know to look for aliases: ~/.bashrc ~/.bash_profile /etc/bashrc /etc/profile With no luck. I know ...
24
votes
3answers
27k views

l, ls & la — what are the differences, and are there more of these commands?

So, through typing several commands I've found that there's not only ls, but l and la too. There doesn't appear to be any man entries on Ubuntu 12.14. They all appear to do similar things with minor ...
2
votes
3answers
1k views

What is the difference between ./script and . ./script? [duplicate]

Possible Duplicate: Using ‘.’ to execute files in bash I was trying to figure out how to export my environmental via script instead of changing my .bashrc file. I found this old useful post ...
254
votes
4answers
58k views

What does “rc” in .bashrc stand for?

Is it "resource configuration", by any chance?
30
votes
3answers
6k views

Multicolored Grep

I'm trying to get each grep command to highlight it's results in a different color. I can do it manually with a line like this: ls -l GREP_COLORS='mt=01;32' grep c | GREP_COLORS='mt=01;31' grep o | ...
6
votes
1answer
1k views

Bash scripts ran from from gnome/nautilus don't have environment variables

In my ~/.bashrc and ~/.profile I have some variables set to some filepaths: export MY_VAR1="/path/to/somewhere" In my ~/bin/ (which is added to my PATH) I have a few scripts that rely on those ...
1
vote
3answers
69 views

How to tell what method was used to log in (Password vs. Keyfile) from the bashrc

Is there a way how you can check what auth method the user which just logged in to an account were using? I like to print out a warning after login if someone is using a password instead of a keyfile....
22
votes
2answers
1k views

Any command in my terminal that exits with non-zero code closes my terminal window

At first this was a bit funny, like playing "Bash Roulette" ...but now it's getting old lol Any command in my terminal that exits with non-zero code closes my terminal window I was told that perhaps ...
17
votes
2answers
3k views

.bashrc overwritten but still sourced — how can it be recovered?

Usually when I find a command I want to alias, I echo it to my .bashrc like so: [up button pressed to last command, then line edited so that it reads] $echo "command-i-just-did" >> ~/.bashrc ...
11
votes
4answers
29k views

how to execute a bash script without typing ./ [duplicate]

It has been bugging me for a very long time and I'm really sick of it. For example there's a script called testscript that compares two directories. In class the prof can just type testscript dir1 ...
10
votes
1answer
2k views

Is there a Bash file that will be always sourced in interactive mode no matter if it is login or non-login?

As far as I know, the interactive shells may be login or not login, and the start up files for them are different. If interactive + login shell → /etc/profile then the first readable of ~/....
15
votes
3answers
2k views

How to call a “sub” .inputrc? (Like in .bashrc, where you can “source sub_script.sh”)

My ~/.bashrc contains exactly one line: source my_config/my_actual_bashrc.sh Is there an equivalent with .inputrc, so my customizations can be in a separate location, and "called" by ~/.inputrc?
8
votes
1answer
2k views

Change the location of .bashrc

Is it possible to change the location of .bashrc from /home/orhanc/.bashrc to some other directory?
3
votes
3answers
6k views

How to fix corrupted bash-completion in command substitution? [duplicate]

it seems my bash-completion got corrupted. Every time I try to use command substitution, for example when I type ls $(ls Deskto<Tab> ..result is.. ls $(ls Desktobash unexpected eof while ...
3
votes
2answers
128 views

Handling duplicate programs names bash

I'm wondering if $PATH cascades entries. You'll all need to take a leap of faith with me here, but here it goes. Let's say we have a Java executable at /usr/bin/java but this version is very old and ...
7
votes
1answer
497 views

bashrc lazy substitution

How does one get ~/.bashrc aliases to evaluate $() substitutions at run time, instead of at the time that ~/.bashrc is executed (when opening a terminal)? I run this command often enough that I would ...
5
votes
2answers
3k views

How to get the arrow style bash prompt after installing powerline?

I have installed powerline. But my prompt looks like so instead of arrow shaped: In vim, it looks ok: I have seen the issue here: https://github.com/powerline/powerline/issues/1697. But the solution ...
2
votes
1answer
1k views

How to change the color scheme of the prompt based on user?

My current prompt is colorized and edited as so - #!/bin/bash # GIT Prompt help if tput setaf 1 &> /dev/null; then tput sgr0; # reset colors bold=$(tput bold); reset=$(tput sgr0); ...
1
vote
1answer
288 views

How to correctly deal with locally built binaries?

I tend to build binaries from sources. My usual setup is the following $HOME/build -> this gets the sources $HOME/programs -> this is where the build happen, so where the binaries are Once ...
0
votes
2answers
3k views

How to get the ~/.bashrc to work in the native terminal application in Centos? [closed]

The problem I had was to get the .bashrc and .bash_profile and/or .profile scripts to execute by default when using the native Gnome terminal application. I found a number of references which told me ...
0
votes
1answer
1k views

Where to put the escape characters? [duplicate]

I've tried to change my prompt by editing .bashrc: export PS1="\e[0;32m[\u@\h \W]\$ \e[m" This seems to work, but ctrl-r to access reverse history ends up with my typing not appearing in the same ...
70
votes
13answers
70k views

How can I set my default shell to start up tmux

I would like my default bash shell to go straight into tmux instead of my always having to type tmux every time.
17
votes
4answers
37k views

Completely restart Bash

Is there a way to completely restart Bash and reload .bashrc and .profile and the like? I'd like to make sure my changes worked out properly after editing these files.
35
votes
4answers
12k views

How can I create a local function in my bashrc?

My .bashrc had some code that was repetitive so I used a function to simplify it do_stuff() { local version=$1 export FOO_${version}_X="17" export FOO_${version}_Y="42" } do_stuff '5.1' ...
6
votes
3answers
7k views

When is /etc/bash.bashrc invoked?

What is this file anyway? Documentation makes no mention of it. And it's not supposed to be run automatically (version 4.3, 2 February 2014): Invoked as an interactive login shell, or with --login ...
15
votes
7answers
4k views

Is it possible to check where an alias was defined?

An alias, such as ll is defined with the alias command. I can check the command with things like type ll which prints ll is aliased to `ls -l --color=auto' or command -v ll which prints alias ll='...
9
votes
1answer
4k views

Where do /root/.bashrc and /root/.profile come from on a Debian system?

Normally when you add a user on a Debian system, the contents of /etc/skel/ are copied into the new user's home directory. But /root/.bashrc does not match /etc/skel/.bashrc and /root/.profile does ...
7
votes
1answer
9k views

.bashrc doesn't get executed

I have a user (non-root) which has a ~/.bashrc file with some aliases in it. But it doesn't look like the file is executed at log in time. If I do source ~/.bashrc then it does what it's supposed to. ...
11
votes
2answers
2k views

Is it OK to use “.” to run files instead of source - in .bashrc in Ubuntu and OS X?

OK, so source runs the script in the current shell and . separately, as detailed in running script with ". " and with "source " for example, but, specifically, in my .bashrc file, ...
9
votes
4answers
8k views

Non-interactive shell expand alias

I'm having trouble getting aliases to expand on my hosting account when I run a command like: ssh user@server "bash -c \"alias\"" My .bashrc file is: echo .bashrc # .bashrc shopt -s expand_aliases ...
5
votes
1answer
37k views

When I run “sudo su” I get --bash: command not found for everything

I'm not good with command lines or servers. But I needed to configure for work a AMI of EC2 AWS with LINUX So I've installed a lot of stuff, moved a lot of stuff around and then I realized that sudo ...
5
votes
2answers
1k views

Can 'ssh <host> <command>' be configured to always load server-side startup files?

I would like run remote ssh commands and have them always load server-side startup files by default. I am looking for a solution that does not require: configuration by root adding extra boiler plate ...
5
votes
3answers
2k views

Run ssh login command without modifying remote .bashrc

We have a bunch of servers set up with set -o vi in their ~/.bashrc. It would be nice to be able to ssh into these boxes and automagically run set -o emacs as a timesave. I've seen a solution ...
3
votes
3answers
1k views

Trying to understand .bashrc, env, and export

Disclaimer: Using bash. I just need some confirmation / correction on my understanding of these things: env is basically displaying the current environmental variables that are accessible to my ...
6
votes
2answers
19k views

How to execute source command from sh file

I have file called install.sh and within this file I write something to $HOME/.bashrc file and after that I must call source command. In terminal I can type source $HOME/.bashrc but I can't do this in ...
3
votes
1answer
847 views

Populate PS1 asynchronously

I have a few git svn related functions that see if I have to pull/push from/to the repository. My problem is that the functions I've written to gather this information are too slow. I'd like to make ...
3
votes
1answer
263 views

Issues with scp if I use bashrc to open fish if present

Situation: Need to login to multiple remote servers with some of them having fish shell Requirement: Default shell is bash. If I login to a server and fish is present, switch to fish shell, otherwise ...
3
votes
1answer
841 views

Invoke subshell command with loaded rcfile

I have some Python code that does: (this is a simplified version) shell = os.environ['SHELL'] os.environ['PATH'] = ... # some new PATH value if call(shell, '-c', '...
2
votes
1answer
2k views

What does . ~/.bashrc command do? [duplicate]

I was viewing my .bash_profile file, and I saw this written inside a block of if statement: if [ -f ~/.bashrc ]; then . ~/.bashrc Can someone explain what the second line is actually doing?
0
votes
1answer
150 views

Is there a way to bind a key to a control-sequence in bash?

In my .bashrc file I'm trying to bind a custom escape-sequence key to a control-sequence. What I have is: bind -x '"\eJD0C": "^C"' And it does not execute the shell control-sequence ^C which ...
9
votes
4answers
8k views

disabling job control in bash (CTRL-Z)

It happens to me sometimes, that I press CTRL+Z by accident and my application disappears into background. I know, I can bring it back with fg, so it's not such a big deal. But I am wondering about ...
5
votes
1answer
664 views

Load aliases from .bashrc file while using sudo

I have set aliases for a few programs in the .bashrc file, and they work fine without sudo and they don't with sudo. Is there a way to get those aliases work with sudo? For example: nano text.txt #...