SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-04-12 22:53:54

Graybyrd
Member
Registered: 2012-04-01
Posts: 17

[RESOLVED] How to set a path in CrunchBang Linux?

I apologize if this is an overly-long question, but this is detailed, complex stuff I'm wading in:

This is from Chapter 1 of the GNU/Linux tutorials:

1.5.3. "$PATH" variable

When you type a command into the shell, the shell searches the command in the list of directories contained in the "$PATH" environment variable. The value of the "$PATH" environment variable is also called the shell's search path.

In the default Debian installation, the "$PATH" environment variable of user accounts may not include "/sbin" and "/usr/sbin". For example, the ifconfig command needs to be issued with full path as "/sbin/ifconfig". (Similar ip command is located in "/bin".)

You can change the "$PATH" environment variable of Bash shell by "~/.bash_profile" or "~/.bashrc" files.

There is no ~/.bash_profile file in my CrunchBang. The ~/.bashrc has no explicit path listings; just references that bounce out to other forks.

So ... I got hopelessly adrift without a canoe or a paddle.

My problem: I added the Haskell suite, updated it's "cabal-install" function, then did a cabal compile/install of pandoc. Everything went fine until it came time to run pandoc, which is installed in ~/.cabal/bin. Terminal reports "command not found." So I need to set the path. My books here are useless. First time O'Reilly ever let me down. "Running Linux, 5th Ed." is useless to me for basic things like this. So ...

In my searching through the CrunchBang system, it seems that the "path" listing is reached through a series of programmed alternatives and forks that I cannot follow. I did find these "path" lines from etc/.profile -->

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi

--> inserting a new path in those lines, such as " /usr/.cabal/bin " made no difference at all, even after logout and reboot.

I finally made an alias:

"pandoc" added to ~/.bash_aliases file as pandoc=~/.cabal/bin/pandoc

and that allows me to execute the pandoc command.

The alias works, but I am stumped as to where to find & establish a proper path entry in CrunchBang/Debian linux.

I'm not a programmer; I have very limited experience under the hood with Linux, and I'm finding myself digging around in the internals as superuser with a red banner in Thunar warning that I will destroy the Universe. This gets nerve-wracking! hmm

I'm reminded of what the developer of Mepis Linux posted on one of their forums. IGNORE everything posted on the internet, and in most of the books, concerning Linux. It is obsolete and out of date. I'm tending to agree with that. It sure does get confusing sometimes.

Help?

=GB=

Last edited by Graybyrd (2012-04-13 04:35:04)

Offline

Be excellent to each other!

#2 2012-04-13 03:59:34

jelloir
#! CrunchBanger
From: Outside the garden wall
Registered: 2009-08-21
Posts: 210

Re: [RESOLVED] How to set a path in CrunchBang Linux?

Debian uses ~/.profile by default and that is where you should be adding any PATH options.

Try adding this to your ~/.profile

PATH="${HOME}/.cabal/bin:${PATH}"

Then logout and back in again or you can just source ~/.profile

. ~/.profile

Edit:  Remove the alias you created before doing this...

Last edited by jelloir (2012-04-13 04:03:00)

Offline

#3 2012-04-13 04:34:20

Graybyrd
Member
Registered: 2012-04-01
Posts: 17

Re: [RESOLVED] How to set a path in CrunchBang Linux?

@jelloir --> Thank you.

I disabled the alias entry with #, and added these lines to ~/.profile:

# include .cabal/bin in PATH
PATH="${HOME}/.cabal/bin:${PATH}"

That worked perfectly. What bugs me is that I don't understand the structure of that line, containing ${HOME} and ${PATH) ... and I've not found a text or reference to it yet ... but I'll keep looking until I truly learn what that's all about.

Thanks again. This install is shaping up beautifully.

=GB=

Offline

#4 2012-04-13 06:07:27

jelloir
#! CrunchBanger
From: Outside the garden wall
Registered: 2009-08-21
Posts: 210

Re: [RESOLVED] How to set a path in CrunchBang Linux?

A Couple of links you should read:

http://tldp.org/LDP/abs/html/internalvariables.html
http://www.thegeekstuff.com/2008/10/exe … sh_logout/

Basically in your scenario when you login bash executes /etc/profile, as you discovered it sets a variable PATH with the typical paths a user would like.

Then bash executes ~/.profile (in the absence of ~/.bash_profile) in you home dir.

Before it executes ~/.profile your PATH would be:

PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"

But when bash executes your user ~/.profile more options are appended to the PATH variable (by your PATH variable set in ~/.profile).

$HOME is a bash builtin variable, you can echo it as such from you shell if your curious:

echo $HOME

So what you actually end up with is this variable:

PATH="/home/user/.cabal/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"

You can see all of your environment variables with (rather unsuprisingly):

env

P.S. not sure if you already knew but pandoc is already in the Debian repo's.  I don't use it but was curious when I noticed you compiling things.

apt-cache show pandoc

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo