No bashrc file in my home directory
Here is what I noted down from my lecture:
- Find file
.bashrcin your home directory - do
vi .bashrc - When you put an application folder somewhere, make sure that its address is in the path variable.
The problem is that I do not have a .bashrc file in my home directory. There is only a .bash_history file in my home.
If i go to the root, there is a etc/bash.bashrc file there but what i think is that it will make changes for all users and not just for me. I want to add this path just for myself. It shouldn't effect others. Also there is no $PATH variable in that bashrc file so I am even more confused.
6 Answers
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 following ...
ls -la ~/ | moreThere should be a .bashrc on the first page. If not just create it with
vi ~/.bashrcAnd simply write following line into it.
PATH=$PATH:~/binORMost of the distributions keep a standard .bashrc file in /etc/skel/ You can copy it to home directory.
$cp /etc/skel/.bashrc ~ 4 Most distributions keep a standard .bashrc file in /etc/skel/ you can just copy to your home dir. Otherwise you could just make a new empty .bashrc file in your home dir.
Create Your Own Startup File for Interactive Shells
About Bash Startup Files
From the INVOCATION section of man 1 bash says:
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.
Note that these startup files are optional; Bash doesn't require them. Bash also differentiates between login shells and interactive shells. An interactive shell is defined thus:
An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option.
Many distributions source one type of startup file from the other, but some don't, so this issue can be difficult to address canonically. You need to examine all your startup files to see how and when your ~/.bashrc will be invoked on your system.
Creating Your Per-User Interactive Shell Startup File
If you're simply missing a user-specific ~/.bashrc file, just create one. This will be invoked by Bash for non-login shells (e.g. shells started without the --login flag), or whenever you force the shell to be interactive by invoking it with the -i flag.
If you don't have a .bashrc, you can simply create one and add the lines you wish to it, such as:
PATH=$PATH:~/binto add your user bin directory to the end of the path.
But you should be careful if there are other startup files. The rules as to what files get used are rather complex, but they're detailed in the bash man page. Enter man bash on a command line and look for INVOCATION.
Short answers:
find ~ -maxdepth 1 -name '.bashrc'vi ~/.bashrcecho $PATH | grep ~/MyNewCoolProgramFolder
Detailed one:
I take a more close literal interpretation.
"Find file .bashrc in your home directory"
Since it exists the commandfind, maybe the treacherous editor would suggest you to use it:find ~ -maxdepth 1 -name '.bashrc'Search in the home directory
~, descend only of one level (no subdir-maxdepth 1). For all the options writeman find.
The line below the will do the minimal jobls ~/.bashrcNote: In case
~/.bashrcdoesn't exist you can create it with a simpleecho >> ~/.bashrc.The
>>will create the file if doesn't exists. If the~/.bashrcinstead exists it will append only the harmless output of emptyecho, avoiding an unintentional deletion a such critical file, that is incidentally difficult to restore without a backup.(The following is because seldom I have to honour the meaning of my nickname, do not execute if you are in doubt).
if [ ! -f ~/.bashrc ] ; then cp -i /etc/skel/.bashrc ~/.bashrc ; else ls -la ~/.bashrc; fi || echo " # Auto Generated " >> ~/.bashrc"Do
vi .bashrc"
Now you can dovi ~/.bashrc, the trap here is that you need to press : and q to exit !Application folder and
$PATH
When you create an application folder, e.g.~/MyNewCoolProgramFolder, the below line will only check if it is in the$PATH:echo $PATH | grep ~/MyNewCoolProgramFolderYou do not need to add if is already there. If needed you can add to the
$PATHwithPATH=$PATH:~/MyNewCoolProgramFolderand to add that line to
~/.bashrcif you want to make it permanent."4?!? How 4 if there were only 3 points?"- Workarounds.
There are some workarounds for the latter; let's suppose an executable file namedCoolDetravellerexists only in your new application folder:(a) You can try to execute it. Simply it will not start if it is not in the
$PATH.CoolDetraveller: command not found
(b) You can try its auto completion. Start to write
CoolDetravelleand press Tab. If it is in the$PATHit will be auto completed (always if auto completion is enabled).(c) You can ask to the bash shell
whichcommand will be used if you write the commandCoolDetraveller.which CoolDetravellerNote: If in your application path there is one or more spaces,
whichcould be unable to findCoolDetraveller, although (here I honour my nickname again) the auto completion ofCoolDetravelleras a valid parameter of thewhichcommand will work!Ad nauseam: You cannot ask
whereis CoolDetravellerbecausewhereishas a hard-coded path, so may not always find what you're looking for
you can open your hidden files from home byCTRL + h
then if you don't find .bashrc there then open terminal and just run following commond
/bin/cp etc/skel/.bashrc ~/and your problem is solved any you may find bashrc file in your hiden files......
More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"