Questions tagged [bashrc]
.bashrc is the Bash shell configuration file for a user's terminal login session.
785
questions
251
votes
7
answers
439k
views
Why ~/.bash_profile is not getting sourced when opening a terminal?
Problem
I have an Ubuntu 11.04 Virtual Machine and I wanted to set up my Java development environment. I did as follows
sudo apt-get install openjdk-6-jdk
Added the following entries to ~/....
250
votes
7
answers
438k
views
Why does "(base)" appear in front of my terminal prompt?
I'm wondering why I have (base) on the left of my terminal prompt.
If I run source ~/.profile in the terminal, it disappears.
If I close that terminal and reopen a new terminal, (base) is there ...
237
votes
6
answers
275k
views
How can I shorten my command line (bash) prompt?
Currently it is:
michael@Castle2012-Ubuntu-laptop01:~/Dropnot/webs/rails_v3/linker/spec/controllers$
Outside of renaming my machine and directory structure...
How could I make it be something more ...
230
votes
7
answers
153k
views
Bash history search, partial + up-arrow
I have searched, but not found anything on this. I am looking for a functionality in bash, using a terminal.
Way back when, I had a user on a debian system, and a friend set me up with a convenient ...
181
votes
7
answers
261k
views
.bashrc not executed when opening new terminal
The code in .bashrc does not execute when I open a new terminal window in Ubuntu 12.04.
I noticed this when creating a .bash_aliases file. The aliases did not show up when I opened a new terminal. ...
176
votes
11
answers
1.6m
views
Where is .bashrc?
I feel stupid asking, but I can't seem to find the answer to this anywhere. I'm trying to follow these instructions to edit my bash prompt, but there is no .bashrc in either my user directory (~/....
151
votes
4
answers
54k
views
What does "${debian_chroot:+($debian_chroot)}" do in my terminal prompt?
In my terminal prompt definition in my .bashrc file, among other things, I have this snippet of code:
${debian_chroot:+($debian_chroot)}
What does this do, and do I need it?
140
votes
5
answers
210k
views
Changing colors for user, host, directory information in terminal command prompt
Is it possible to change the colors in the command prompt for the user@computer, as well as the the current directory and command parts of the prompt display?
I've already seen something like this ...
127
votes
5
answers
303k
views
How do I get a colored bash?
How can I get the bash to look colored like this?
113
votes
4
answers
289k
views
How do I restore .bashrc to its default? [duplicate]
I've been trying to install Android developer tools on Eclipse, and I followed the information in this video.
Like the video said, I added the following two lines of code to the .bashrc file:
export ...
84
votes
6
answers
140k
views
Cannot successfully source .bashrc from a shell script
Normally we can source ~/.bashrc file using this command
source ~/.bashrc
but if I write this in a shell script and execute it, nothing happens. Why?
Is there any way to do this?
My script:
#!/bin/...
81
votes
4
answers
260k
views
Permanent PATH variable
How will I make this /media/De Soft/mongodb/bin PATH variable permanent?
Everyone is saying "export PATH=$PATH:media/De\ Soft/mongodb/bin to your ~/.profile, or .bashrc, or .zshenv depending on your ...
79
votes
2
answers
81k
views
Why isn't .profile sourced when opening a terminal?
Just installed Ubuntu 14.04.1 LTS.
According to .profile,
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash, if ~/.bash_profile or ~/.bash_login ...
73
votes
4
answers
128k
views
How can I preset aliases for all users?
I have Ubuntu 14.04.2. I want to make it so all users automatically have a specific set of aliases. I have my aliases set in my personal .bashrc, but I don't want to have to manually copy them into ...
70
votes
1
answer
108k
views
Why is /etc/profile not invoked for non-login shells?
Login and non-login shell defined as:
su - $USER # will give you a login shell
bash # will give you a non-login shell
/etc/profile is not invoked for non-login shells, such as when you start konsole ...
63
votes
3
answers
156k
views
Add environment variable to .bashrc through script
I need to add the following lines to the end of .bashrc file in Ubuntu. How can I add these lines automatically using a script. If I run the script, then it automatically inserts the lines at the end ...
62
votes
3
answers
119k
views
How to save terminal history manually?
It's my understanding that the history file is updated when the terminal exits. But sometimes my computer crashes out, and the terminal doesn't exit cleanly, and then I lose those commands from my ...
55
votes
3
answers
54k
views
Sequence of scripts sourced upon login
I would like to concentrate all my login config in my ~/.bash_profile. There was a ~/.bashrc there by default but I replaced it with a ~/.bash_profile.
However, when I log in, something before my ~/....
51
votes
8
answers
119k
views
How to add an alias to a command in terminal?
By typing a manually specified command in terminal I want to execute some other command.
How could add an alias to a command? Can i do that with the help of the terminal or should I edit some kind of ...
48
votes
3
answers
23k
views
Write function in one line into ~/.bashrc
Why when I try to write a function just in one line into .bashrc file,
list(){ ls -a }
I get error?
bash: /home/username/.bashrc: line num: syntax error: unexpected end of file
but when I write it ...
45
votes
5
answers
54k
views
difference between bash.bashrc and /etc/environment file
Till date I used to set my environment variables in the bash.bashrc file. Recently I was told to use the /etc/environment file. Well, both work fine.
So, what is the difference between them?
I ...
44
votes
5
answers
68k
views
How to restore .bashrc file?
The terminal shows this when it opens:
bash: /home/atlas/.bashrc: line 73: syntax error near unexpected token `['
bash: /home/atlas/.bashrc: line 73: `if [ -x /usr/bin/dircolors ] ; then '
I've ...
42
votes
5
answers
95k
views
Specify JDK for tomcat7
I have installed tomcat7 (using apt-get install) and whenever I want to start tomcat7 it says :
* no JDK found - please set JAVA_HOME
I have set JAVA_HOME in my bash.bashrc and also in ~/.bashrc and ...
39
votes
5
answers
97k
views
How can I change the default python on my Ubuntu 20.04 to Python3.8?
I would like to set python 3.8 as default on my PC
Thinkpad X230
Ubuntu 20.04
I tried setting an alias
gt@gt-ThinkPad-X230:~$ alias python='usr/bin/python3.8'
Q: Does this alter a .bashrc file? If ...
39
votes
3
answers
20k
views
What goes in ~/.profile and ~/.bashrc?
I'm having trouble wrapping my head around what belongs in ~/.profile and what belongs in ~/.bashrc.
From what I've read, it seems to me that ~/.profile should be used for environment variables and ~/....
36
votes
9
answers
289k
views
How do I activate a conda environment in my .bashrc?
I use Conda for package management in Python. I have a basic environment which I use almost all of the time, and I want it to be loaded by default when I open a terminal. How do I set up my .bashrc to ...
35
votes
7
answers
63k
views
Copy current terminal prompt to clipboard
Is there a way to copy the currently written content of the bash prompt? Say I wrote:
ping www.google.com
so that the lines in terminal looks like:
petr@sova:~$ ping www.google.com
and didn't hit ...
33
votes
2
answers
14k
views
Why does Ubuntu's default ~/.profile source ~/.bashrc?
These are the contents of the stock ~/.profile that came with my 13.10 (commented lines removed):
if [ -n "$BASH_VERSION" ]; then
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
...
32
votes
4
answers
91k
views
Add a binary to my path
I have an executable. I want to execute the executable in terminal with name only like other commands.
I can put my executable in /usr/local/bin or I could add its PATH to ~/.bashrc. Both will work.
...
29
votes
4
answers
51k
views
Configure gnome-terminal to start bash as a login shell, doesn't read .bashrc
I'm trying to integrate RVM with gnome-terminal.
Per default, gnome-terminal does not start bash as a login shell. I enabled run command as a login shell as suggested in this answer about the same ...
29
votes
1
answer
97k
views
What is a .bashrc file and what does it do?
I can't seem to find any clear information on what the .bashrc file is and what it does exactly.
Thanks for all the help so far. It seems that this script does everything from coloring, completion, ...
27
votes
2
answers
8k
views
Why is my function not re-evaluated in PS1?
I'm trying to have a part of my prompt set dynamically by a function, so in my .bashrc I have:
asdf ()
{
echo -n $(pwd)
}
PS1="\u@\h:\w $(asdf)\$ "
Opening a shell gives me what I expect at ...
26
votes
12
answers
37k
views
How to check which terminal emulator is being currently used?
I have gnome-terminal and Guake installed. I want to give different startup messages to be displayed on these terminal emulators as they start. What code should I write in .bashrc so that this is ...
25
votes
2
answers
31k
views
What's the difference between .bashrc and /etc/bash.bashrc?
What's the difference between /etc/bash.bashrc and ~/.bashrc?
24
votes
10
answers
16k
views
Accidentally modified .bashrc and now I cant login despite entering password correctly
I messed up bigtime with the bashrc file. I was installing Gurobi and I had to set path variables in the bashrc file. So, I replaced all the text in bashrc with the path variables and saved the bashrc ...
24
votes
3
answers
8k
views
What does "[[ $- != *i* ]] && return" mean?
I have this line in my .bashrc and I would like to know what exactly this means
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
22
votes
1
answer
8k
views
At what point is the ~/.bashrc file created?
For instance, if I were to run the command adduser test, is the .bashrc created automatically upon creation of the home directory for the user test? If it's not created upon user creation, under what ...
21
votes
4
answers
3k
views
How do I teach bash in Ubuntu some curse words?
When bash encounters an unknown command(word?) it does this :
The program 'hello' can be found in the following packages:
* hello
* hello-debhelper
Try: sudo apt-get install <selected package&...
20
votes
5
answers
13k
views
How (and where) can one change 'user@host $:' pattern in gnome-terminal?
When I start terminal in Ubuntu, I see:
ilya@HOST:~$
I need to add a timestamp to this, something like:
2011-10-09T09:32:00 ilya@HOST:~$
How can I configure this?
20
votes
2
answers
8k
views
Can I create a separate bash history file for each terminal profile?
I use a bash script to start gnome-terminal with multiple tabs, each tab using a different profile, working directory, and in some cases executing a command within the tab.
In this situation, I'd ...
20
votes
5
answers
45k
views
Changing behavior of bash prompt when functioning as root
Before you click away, this isn't the typical "how do I make my bash prompt have color" question. I've already customized my bash prompt to look like this:
[user @ host]----[$(pwd)]
$
where ...
20
votes
4
answers
6k
views
How to get shared Bash history among different tabs
I used the answer in https://unix.stackexchange.com/a/1292/41729 to enable real-time shared history among separate Bash terminals.
As explained in the answer above, this is achieved by adding the ...
18
votes
2
answers
49k
views
How to make python shebang use python3?
I have a third party script that uses the shebang #!/usr/bin/env python.
According to the python documentation, this is the correct form for scripts that are suitable for both Python v2 and Python v3 ...
18
votes
2
answers
10k
views
How can I use the arrow sign in my bash prompt?
How can I use these red and green arrow signs in the bash prompt?
update 1
This is my .bashrc file
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\...
18
votes
1
answer
29k
views
Where is bashrc profile for root?
I believe the question says it all.
Also if it doesn't exist where do I create it.
Ubuntu 10.04
18
votes
1
answer
31k
views
What can cause my .profile file to not be loaded when a new terminal shell is initialized?
There are no errors in xsession and I don't have a .bash_login or .bash_profile file, so I'm 100% certain neither of those is loaded and thus cancels .profile loading.
When I rename the .profile to ....
16
votes
1
answer
7k
views
How to display random jokes from www.icndb.com in your terminal?
I already know that you can get some nice quotes/jokes using the fortune program.
But I've found in this urwird script a new source of fun that I'd like to have when I open a new terminal.
This time ...
15
votes
2
answers
3k
views
How do I pipe each command given to the shell?
I'd like to edit my .bashrc so that every command executed on the shell is piped to something, for example:
$ sudo apt update
_________________
< sudo apt update >
-----------------
\ ...
15
votes
2
answers
32k
views
I think I accidently deleted the PATH variable
Whatever I try to run, I get the error:
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
I had some modification in my .bashrc file but then ...
15
votes
2
answers
4k
views
Is there a way I can open the Windows 10 Ubuntu bash without running the ~/.bashrc script?
I was editing the bashrc script in my Windows 10 Ubuntu Bash and I made a mistake while editing the script. Now bash exits immediately upon opening it. Is there a way for me to open Bash without ...