Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
You do not need to find/edit .bashrc in /etc/. There should be a .bashrc file in your home directory. Try to open/edit ~/.bashrc. But before that I should also ask if you are new to Linux. If you are new to Linux, then I can post detailed instructions here. –  Ankit Apr 28 '12 at 15:44
add comment

4 Answers

up vote 28 down vote accepted

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 ...

ls -la ~/ | more

There should be a .bashrc on the first page. If not just create it with

vi ~/.bashrc

and add in the lines you need to add into it.

Permissions of my .bash.rc are

-rw-r--r--  1 discworld discworld  3330 Mar 10 16:03 .bashrc

(chmod 644 .bashrc to make it rw r r)

share|improve this answer
    
That was exactly it -- hidden file, and I didn't think to look beyond the obvious. Thanks -- maybe this will help other shmucks like me as well. :) –  mattshepherd Apr 28 '12 at 15:21
1  
I don't seem to get the sudo... line, isn't this touch ~/.bashrc? –  lgarzo Apr 28 '12 at 15:22
    
@Rinzwind I think that line still has an extra dot in the filename. –  lgarzo Apr 28 '12 at 15:27
    
No, there was no extra dot! I deny there to have been 2 errors in that command! :=D –  Rinzwind Apr 28 '12 at 15:29
    
Sorry, my bad! :P –  lgarzo Apr 28 '12 at 15:31
show 2 more comments

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 ~/.bashrcfrom a terminal (replace nano 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 amke things work i ahvent 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 (bash prompt default to display user@localhost:pwd $) and aliases as well as setting color prompt and maybe PS2 (busy state message)

share|improve this answer
add comment

User specific, hidden by default.

~/.bashrc

If not there simply create one.

System wide:

/etc/bash.bashrc
share|improve this answer
add comment

It is hidden because of the . the filename 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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.