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 (~/.bashrc
), or in my home directory, or in the main file system directory.
There is no .bashrc
in /etc/
(there is a bash.bashrc
, however).
Do I create a .bashrc
file in my user or home directory? Is there a better, more recent set of instructions for modifying the bash prompt?
Don't forget it is a hidden file inside your home directory (you would not be the first to do a
ls -l
and thinking it is not there).Do a:
There should be a
.bashrc
on the first page. If not just create it with:and add in the lines you need to add into it.
Permissions of my
.bashrc
are:(
chmod 644 .bashrc
to make itrw r r
).User specific, hidden by default.
If not there simply create one.
System wide:
There is a .bashrc in every user's home folder (99.99% of the time) as well as one system-wide (which I don't know the location of in Ubuntu).
The quickest way to access it is
nano ~/.bashrc
from a terminal (replacenano
with whatever you like to use).If this is not present in a user's home folder the system-wide
.bashrc
is used as a fallback as it is loaded before the user's file. You could simply copy and paste it (with root permissions of course), but a.bashrc
is not entirely essential (it may be required to make things work. I haven't found out) at a user level as it mostly overrides the system-wide one with user-specific tweaks. You could write your own though.The main components for that users may tweak are
PS1
(the Bash prompt defaults to displayuser@localhost:pwd $
) and aliases as well as setting a color prompt and maybePS2
(busy state message).Use
gedit ~/.bashrc
, it will allow you to modify~/.bashrc
using gedit.It is hidden because of the '.' it starts with.
list it with
ls -al
or enable "show hidden files" under the view menu in nautilus (Ctrl-H will also do the trick).
You can edit it with your favorite text editor from your home directory e.g.
cd
to go to your home directory then:
emacs .bashrc
If
.bashrc
is not in your home folder, even after you list the hidden files, you can copy it from:Use
nano ~/.bashrc
to open and edit the .bashrc file. (This will create the file if it does not yet exist)if not in home directory, you can just copy from
/etc/bash.bashrc
, and make it source for your terminal, by typing in your terminalsource .bashrc
from your home directory after copying.If you use encryption and work from the command line you might not see it as one need to mount the real home-dir first (in contrast to in the graphical UI where this is done automaticallu) by the command:
(I had the same question and stumbled upon this question; but found my answer in the readme instead)
Bashrc file is a hidden file inside the home directory. It is actually, give the path directions.
And those are wanted to edit
.bashrc
file, try this commandgedit ~/.bashrc
instead of this~/.bashrc
.This command
gedit ~/.bashrc
directly take you to the text editor, where you can edit it easily, as you know.