Here is what I noted down from my lecture:

  • Find file .bashrc in 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 6


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 ~/ | more

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

vi ~/.bashrc

And simply write following line into it.


OR Most of the distributions keep a standard .bashrc file in /etc/skel/ You can copy it to home directory.

$cp /etc/skel/.bashrc ~
  • OK I get that now. On other computers, I can type lego and the software starts. On my system, the lego folder is in my ~/data/user1/bin folder. I have added this path to .bashrc file. Now what do I have to do so that when i type lego, it should start the software? Do i have to set up an alias? If yes, how? alias lego='<What do i put here???>'
    – detraveller
    Apr 18, 2013 at 13:47
  • @detraveller Have you added ~/data/user1/bin to your PATH environment variable in the .bashrc file? (add this line: export PATH=$PATH:~/data/user1/bin) - if so, you should be able to just type lego in the terminal, and the program should start.
    – AcId
    Apr 18, 2013 at 14:40
  • I added only PATH=$PATH:~/data/user1/bin. You didn't mention export so I didn't put it there. I will try again tomorrow when I go to Uni. Apr 18, 2013 at 18:12
  • But i was wondering how do i tell bash that lego is the word that starts the software? Apr 18, 2013 at 18:25

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:


to 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:

  1. find ~ -maxdepth 1 -name '.bashrc'
  2. vi ~/.bashrc
  3. echo $PATH | grep ~/MyNewCoolProgramFolder

Detailed one:
I take a more close literal interpretation.

  1. "Find file .bashrc in your home directory"
    Since it exists the command find, 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 write man find.
    The line below the will do the minimal job

    ls ~/.bashrc   

    Note: In case ~/.bashrc doesn't exist you can create it with a simple echo >> ~/.bashrc.

    The >> will create the file if doesn't exists. If the ~/.bashrc instead exists it will append only the harmless output of empty echo, 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 ] ; 
         cp -i /etc/skel/.bashrc ~/.bashrc ;
      else ls -la ~/.bashrc; 
    fi || echo " # Auto Generated " >> ~/.bashrc
  2. "Do vi .bashrc"
    Now you can do vi ~/.bashrc, the trap here is that you need to press : and q to exit !

  3. 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 ~/MyNewCoolProgramFolder

    You do not need to add if is already there. If needed you can add to the $PATH with


    and to add that line to ~/.bashrc if you want to make it permanent.

  4. "4?!? How 4 if there were only 3 points?"- Workarounds.
    There are some workarounds for the latter; let's suppose an executable file named CoolDetraveller exists 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 CoolDetravelle and press Tab. If it is in the $PATH it will be auto completed (always if auto completion is enabled).

    (c) You can ask to the bash shell which command will be used if you write the command CoolDetraveller.

        which CoolDetraveller

    Note: If in your application path there is one or more spaces, which could be unable to find CoolDetraveller, although (here I honour my nickname again) the auto completion of CoolDetraveller as a valid parameter of the which command will work!

    Ad nauseam: You cannot ask whereis CoolDetraveller because whereis

    has a hard-coded path, so may not always find what you're looking for


you can open your hidden files from home by CTRL + 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......

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .