The No such file or directory warning is correct?

Hi,
When I learn shell script, I want to add my own PATH variable to system previous variables. I find that my linux has the below PATH variables (in the end of this message). It shows ‘No such file or directory’ although I verify that all the directories exist. Some directories are empty indeed. This will result that warning?

I want to make the present PATH variables correct before I add mine. Thanks


bash: /usr/lib/mpi/gcc/openmpi/bin:/home/jeff/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/jvm/jre/bin: No such file or directory

To add your own path to you as a single user, you can add this to the file ~/.bashrc:

To edit this file in KDE do a menu Run Command (or just press Alt-F2):

kwrite ~/.bashrc

Then add a line like the following with your new path command where /folder/mypath is changed to the path you want to add:

PATH=/folder/mypath:$PATH

Then save the file, log out and back in to see your path added for you.

Thank You,

vi + .bashrc and add

 export PATH=$PATH:/path/to/new/directory

Save and Exit .bashrc
type

source ~/.bashrc

then

echo $PATH

You can short-term test it by just typing

export PATH=$PATH:/path/to/new/directory

in a terminal window, then the binary should run if done correctly.
Once that’s verified, then add it to .bashrc for permanence.

Thanks Habitual for the catch on needing to use the export command:

export PATH=$PATH:/path/to/new/directory

Thank You,

As PATH is allready exported to the environment, there is not need to export it again (and again) when the value is changed. It does no harm of course, but it is one of those urban legends spread through the Linux world without increasing the real knowledge about what export is and does.

And to the OP. Your “last line” is a bit strange. When you want to post any computer output, please copy/paste that text please between CODE tags (Posting in Code Tags - A Guide) and please as complete as possible, thus we all can see what commands you used and what the results were. E.g., I would show the PATH variable as it was at a certain moment in this way:

henk@boven:~> export $PATH
bash: export: '/home/henk/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/home/henk/.local/bin': is geen geldige naam
henk@boven:~>

To my surprise, I have the same silly argument there!!!
This must be due to a bug somewhere in my .profile or* .bashrc*. I am going to investigate!

Oh, oh, oh! I am realy silly. :shame: :shame: :shame:
I should have published:

henk@boven:~> echo $PATH
/home/henk/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/home/henk/.local/bin
henk@boven:~>

Now everybody can see how important it is not only to show what the system says, but also what one asked the system!

After I have shown how stupid I can be, maybe @freerjw you can tell us how you got that error message.

On 05/13/2011 02:36 AM, freerjw wrote:

>I find that my linux has the below PATH variables
> (in the end of this message). It shows ‘No such file or directory’
> although I verify that all the directories exist. Some directories are
> empty indeed. This will result that warning?
>
> bash:
> /usr/lib/mpi/gcc/openmpi/bin:/home/jeff/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/jvm/jre/bin:
> No such file or directory

remove the final : (behind bin) and that “No such file or directory”
should go away…i think with that bin: it is now looking for a file
or directory named " " (space) or "
" (end of line)


dd CAVEAT: http://is.gd/bpoMD
[NNTP via openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10]
Dual booting with Sluggish Loser7 on Acer Aspire One D255

I think you missed something DD. We are still waiting for he OP to explain how he got that line with the error (it is not a warning imho).

You assume that he displays the contents of his environment variable PATH. But as he does not show how he got that line, I doubt that this is his PATH at all.

As you can see in my two posts, I am able to generate a line same as his by giving a command that DOES NOT display the PATH (in this case* export $PATH*, but I guess there are more possibilities). When I do* echo $PATH* the PATH is displayed and does not contain an error message.

That is the reason why I allways encourage to post not only the generated output of a command, but also the command itself. To avoid people assuming that the correct command was given where it was not.

On 05/16/2011 07:36 PM, hcvv wrote:
>
> I think you missed something DD. We are still waiting for he OP to
> explain how he got that line with the error (it is not a warning imho).

you are, as usual correct…

and the short answer to the OP is (i guess):

if you use the correct way to see your path, the “No such file…” error
may go away…

try this (the correct) way to see your path: echo $PATH


dd CAVEAT: http://is.gd/bpoMD
[NNTP via openSUSE 11.4 [2.6.37.6-0.5] + KDE 4.6.0 + Thunderbird 3.1.10]
Dual booting with Sluggish Loser7 on Acer Aspire One D255

Because the OP never bothered to post here again after he started this thread four days ago, I guess we can stop our efforts to try to help him >:(

Your efforts were not in vain; the answers you guys provided are still helping problem-debugging Google searchers (such as myself) years down the road. :slight_smile:

~/.profile

is the right place to add the PATH for a single user and for global/system_wide you can put it in

/etc/profile.local

and as what Henk said it is not needed to use export. By the way the .local does not exist by default and needs to be created.