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

Questions tagged [bashrc]

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

847
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 ...
254
votes
4answers
58k views

What does “rc” in .bashrc stand for?

Is it "resource configuration", by any chance?
128
votes
3answers
337k 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?
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 ...
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.
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: ~...
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: #...
45
votes
3answers
57k views

Refresh aliases and functions after defining new aliases and functions?

When I define a new alias in .bash_aliases file or a new function in .bashrc file, is there some refresh command to be able immediately use the new aliases or functions without closing the terminal (...
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 ...
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 ...
36
votes
3answers
26k views

How do I get rid of Cygwin's /cygdrive prefix in all paths?

I'm switching to Cygwin from the bash shell that ships with Git for Windows, and encountering a strange problem. Someone thought it would be a good idea to add /cygdrive/ to all paths, while I think ...
35
votes
4answers
13k 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' ...
32
votes
8answers
67k views

Doing simple math on the command line using bash functions: $1 divided by $2 (using bc perhaps)

Sometimes I need to divide one number by another. It would be great if I could just define a bash function for this. So far, I am forced to use expressions like echo 'scale=25;65320/670' | bc but it ...
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 | ...
25
votes
6answers
42k views

sftp gives an error: “Received message too long” and what is the reason?

I was able to do sftp yesterday to a RHEL 5.4 box (RedHat) and today I can't. The message is "Received message too long 778199411", and after some investigation, it was due to my RHEL box's .bashrc ...
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 ...
23
votes
3answers
25k views

sudo command doesn't source /root/.bashrc

I have added a custom path to PATH variable in my /root/.bashrc file When i do sudo su; echo $PATH, it shows the entry, '/path/to/custom/bins'. But i do sudo sh -c 'echo $PATH', it shows, /usr/...
22
votes
2answers
20k views

Bash doesn't read .bashrc unless manually started

bash won't source .bashrc from an interactive terminal unless I manually run bash from a terminal: $ bash or manually source it: $ source ./.bashrc or running: $ st -e bash Here's some useful ...
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 ...
21
votes
4answers
5k views

Why no shebang in .bashrc/.bash_profile?

Simple inquiry: I have just realized that I have never seen a shebang on top of a .bashrc script, which leads me to think the system uses the default shell to source it upon login (${SHELL}). I am ...
19
votes
2answers
53k views

Global bash_profile

I realize there are /etc/profile and /etc/bashrc files for setting global environment variables and maybe I'm just misunderstanding their purposes, but... Is there a global bash_profile file? I'm ...
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.
17
votes
2answers
935 views

How to retrieve lost aliases?

I made an echo command to my .bash_aliases file and erased all of my aliases, except the test alias. However, I still have a session open that has the aliases loaded (into the tcl?). Can I retrieve ...
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 ...
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?
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='...
13
votes
4answers
2k views

How can I source the bashrc file every time I 'clear'

This might be a bad idea. The more I think about it the more I come to the realization that I probably shouldn't do it... but I've been trying and failing so I REALLY want to know how to do it, even ...
13
votes
4answers
6k views

why deleting bash history is not enough?

I used to think deleting my bash history was enough to clear my bash history, but yesterday my cat was messing around the right side of my keyboard and when I got back into my computer I saw something ...
12
votes
5answers
2k views

How to test for possible conflicts while using alias in bashrc?

Is there a simple way to list all the command conflicts that have occurred in the system due to the bashrc update involving alias commands? For example, someone writes alias ls=/path/to/user-...
11
votes
1answer
2k views

I have multiple copies of .bash_profile, which one is actually being used? (if any)

I think at some point I messed up my .bash_profile and I have multiple now. I am trying to customize my shell but I am not sure which .bash_profile to use, if any. I thought .bashrc file was more ...
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, ...
11
votes
4answers
120k views

Where is .bashrc file found in Linux?

I am not finding my .bash_login and .bash_profile root@linux:~# locate .bash* /etc/bash.bashrc /etc/skel/.bashrc /etc/skel/.bashrc.original /home/noroot/.bashrc /home/noroot/.bashrc.original /root/....
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
4answers
2k views

Purpose of [ -n “$PS1” ] in bashrc

What purpose does the [ -n "$PS1" ] in [ -n "$PS1" ] && source ~/.bash_profile; serve? This line is included in a .bashrc of a dotfiles repo.
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 ...
10
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 ...
10
votes
1answer
3k views

View shell function's current definition

So I am editing bashrc constantly, and I have a terminal open with a working function definition, although bashrc has been updated with a wrong function definition. (Because the definition do not ...
10
votes
1answer
2k views

What's the difference between .bashrc and .inputrc

I am new to the unix system, and find it interesting to create customized functions and configurations in the setting files like .bashrc and .inputrc. However, I don't understand the differences ...
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 ~/....
9
votes
3answers
13k views

Why root does not source .bash_profile?

Every time I try to login as root using su (not su -), it doesn't source .bash_profile in user1's home directory. Basically, my /var/root directory doesn't have .bash_profile, so I put a copy of ....
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 ...
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 ...
9
votes
3answers
523 views

In shell config scripts, how can I account for differences between coreutils on BSD compared to GNU?

Up until this month, my shell configs have been pretty simple (just a .bashrc or .bash_profile with some aliases mainly), but I have been refactoring it so I can get different behavior depending on ...
9
votes
1answer
771 views

.inputrc vs .bashrc settings

I've noticed few settings in .bashrc and .inputrc files look the same or are similar, such as: shopt -s nocaseglob vs set completion-ignore-case export HISTSIZE vs set history-size export ...
9
votes
1answer
2k views

How to detect when a shell is owned by a remote SSH session?

My question is similar to this one, but I'm looking for something slightly different. I have a notebook PC that I use to access Linux machines on a network in two different scenarios: I have a direct,...
9
votes
4answers
1k views

Is it possible for there to be a login shell that's not interactive?

In interpreting this flowchart I found that in man bash: When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes ...
9
votes
1answer
15k views

Jenkins does not use system's locales

I got a interesting behavior in Jenkins. Jenkins' shell does not use my systems locales. Jenkins runs as user jenkins on my system. Logged in as jenkins via SSH: locale displayed: LANG=en_US.UTF-...
9
votes
2answers
15k views

HISTTIMEFORMAT modification. In /etc/bash.rc or /etc/profile? [duplicate]

I'd like to add the date/time to the output of the history command in CentOS/RHEL 6. I would like this to apply to all users on the machine by default. This itself is easy. It seems to just be a case ...
8
votes
3answers
17k views

SSH parameter to ignore .bashrc script

I have a server which when it starts, a line in .bashrc executes the following command /bin/watch ~/checker.bash which as expected watches that command upon server start. I also have a client which ...
8
votes
2answers
34k views

Where is the system profile that gets sourced at login on CentOS 5.8?

In CentOS release 5.8 (Final), where is the bash system profile? Is it /etc/profile ? I've added the following to source my ~/.bashrc file but haven't had any luck as it fails. I know it fails ...