ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am trying to edit .bash_profile and .bashrc files. I dont know how to do this.
I tried vi .bash_profile and all I get is just few lines printed as below:
I am unable to add/delete anything here.
Could anyone please tell me how to edit this file.
Do I need to have superuser priveliges?
If yes, then what is an alternative?
Can I create this file in my own local (default 'cd ~' directory)?
I actually tired creating this file in my local directory but it seems like it is not working.
I am trying to add
alias dir="ls -a"
codes in the above files.
Please help me with this.
Also , the line of tilda's means you are now in the vi editor and the tilda's represent lines on the screen that do not exist in your file. To get into insert mode type 'i', then you should be able to type what you want. When you are finished hit the escape key and type :wq and hit enter. This will exit and save changes.
Try nano .bash_profile. Nano is an easy to use editor and is included with most Linux distributions. If you are stuck with vi,then here is the basics.
Vi has 2 modes, command and append. when you start vi, it is in command mode. The ~~~ are blank spaces. You can move the cursor around, but not type. Press the "a" for append to add text. When you are finished editing, press the "esc" key to go back to command mode.
Summary of commands:
a Edit Mode
esc Command Mode
You must be in command mode for these to work:
:w + enter Save file
:x + enter Save and exit
:q + enter exit
:q! + enter exit without saving
Different distributions use different names for the bash startup file. It could be .bash_profile, .bashrc, or .profile.
There is one of these default files for each user including root. Each user can edit his own startup file without needed root privileges. So look in /home/username and see what filename your distribution uses for a bash startup file and edit that.
Each distribution also has a universal default bash default file somewhere in /etc. In Debian it is called /etc/profile. Other distributions may give it a different name. You need to be root to edit this file. If you specify a default in both /etc/profile and your user bash startup file then the user file takes precedence.
Here is an explanation about how bash startup files work in Linux From Scratch:
The post from jailbait was very helpful. I am using a debian-etch distro which is very reliable. But for the mewbie it is very complicated especially the location of the startup files. I was able to find both .bashrc and .bash_profile under /home/username as was suggested but you have to enable system and hidden files in the view part of the directory menu for /home/username. A little gotcha. Thanks for the help.
Anyway, you have to learn to use at least one text-editor if you want to use your system effectively. There are many possibilities both in GUI and terminal.
(I prefer mcedit -- very easy to use for people who knew Norton Commander.)