LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-12-2006, 01:09 PM   #1
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Rep: Reputation: 0
About adding PATH directories and maping in vim


I have 2 small problems, i have the sw11.0.
The 1st one, i want that my root directory be in the PATH, i add it, but i cant execute my C executable files directly.
I added the following directories into the PATH, /~, /root. It is wrong?

The 2nd is a vim remaping problem, i want to remap the f1 key to work like esc, i cant do it,i can remap esc to work calling help, but my f1 key dont work like esc. (i have the esc key a little far away and it force my hand to move out of the writing keys).

THANKs.
 
Old 12-12-2006, 01:38 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
well your root directory should *NOT* be in your path. it's a really bad idea. if you wish to run your own compiled software, then you should put it in somewhere like /usr/local/bin/, or just run it with a relative or absolute path. now if you deicide to go against stnadard conventions then "/~" doesn't really make sense, it's invalid, but /root should be fine, so you've presumably got a syntax problem in the way you are defining it, or you are applying incorrectly somehow.
 
Old 12-12-2006, 03:16 PM   #3
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Original Poster
Rep: Reputation: 0
I put in the cmdln
export PATH=$PATH:root/java
it work. But i want it to be executed in the boot.
I put the same line in etc/rc.d/rc.local
and it isnt working, what must put instead?

acid_kewpie, a folder into the root directory is also unrecomended?
why i mustnt put the root directory into the path?

THANKS
 
Old 12-12-2006, 03:20 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
/root is where the system administrator puts all sorts of little bits of information and such, it's just not an organizd place to pur exectuables in the long term.

but if you must, edit your own personal /root/.bashrc file and add it there, e.g. "export PATH=$PATH:/root"
 
Old 12-12-2006, 08:07 PM   #5
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Original Poster
Rep: Reputation: 0
I do it, but it dosnt work. The .bashrc file was empty, and i dont know if it already exist before i open it with: vim .bashrc
I put the ls command, and i cant see the file. Why i cant see it?, it is ocult?.
 
Old 12-13-2006, 03:07 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
a file that starts with a . is hidden. add the -a flag in ls and you'll see them. your bashrc really will always exist, unless you don't use bash or have a distro i've never seen before. you can also try ~/.profile too, which is largely shell agnostic.
 
Old 12-13-2006, 06:59 AM   #7
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
.bashrc is not executed on login shells.
And bash_profile is not executed if bash is called by #!/bin/sh.

So the best, IMO, would be to put this at end of /etc/profile:

Code:
if [ "`id -u`" -eq 0 ]; then
  PATH=$PATH:/root/java
fi
export PATH
 
Old 12-13-2006, 07:50 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
It is common to have a ~/bin/ personal bin directory to execute your own scripts and personal program files. Commands you install from a tarball probably should be installed in /usr/bin/ or /usr/local/bin/.
You can add the line "export PATH=$PATH:$HOME/bin" to your ~/.profile file. The .profile is run when you login, so you will need to run it manually "./.profile" if you haven't logged out. Also, the ~/.bashrc file is run every time a new subshell is run, so if you used ~/.bashrc instead, your added paths will be added twice.
 
Old 12-13-2006, 09:34 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Quote:
Originally Posted by nx5000
.bashrc is not executed on login shells.
And bash_profile is not executed if bash is called by #!/bin/sh.

So the best, IMO, would be to put this at end of /etc/profile:

Code:
if [ "`id -u`" -eq 0 ]; then
  PATH=$PATH:/root/java
fi
export PATH
what do you mean not exectued on login shells? of course it is... and why would you want a single uid specific test to be run on a system wide script? can't see the logic there at all
 
Old 12-13-2006, 09:52 AM   #10
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
Sorry, its not, see bash manual page:
http://www.die.net/doc/linux/man/man...tml#invocation
I will add that if /etc/profile is executed then ~/.profile is not executed.

This is what comes when you install debian, it looks very similar:

Code:
root@debian# more /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="/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/
usr/bin/X11"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

export PATH

umask 077
So the logic seems to be the same..
 
Old 12-13-2006, 10:26 AM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
yes, it calls ~/.bash_profile which as a standard for years and years has sourced ~/.bashrc if it's found. not sure why it really goes round the houses like that, but it's the way i've always known it.
 
Old 12-13-2006, 12:51 PM   #12
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 23, 24, RHL 5.2
Posts: 560

Rep: Reputation: 56
Not that I would recommend this, but to map your F1 key in vi to be Esc you'll need to edit a file called .exrc in your home directory. Once in there enter the following.
Code:
:map! #1 ^[
Note: the ^[ is made using the keys Cntl+V Esc. To be more clear you hold down the control key and V at the same time, let go, then hit the Esc key. Using the map with ! means it will work while in insert mode, #1 is F1, and ^[ is how it interprets the escape key.

You may still encounter a problem if you are using a terminal window in Gnome(I don't have KDE, so don't know). The Gnome terminal will capture your F1 and bring up help before it gets to vi. This can be overridden. On the Terminal screen menu go to Edit, then Keyboard Shortcuts. At the bottom of the list you'll see F1 listed as the shortcut key for help.

Now, having said all that, it is not a good practice to use F1. F1 has been the standard help key on applications since function keys were first invented.

For the $PATH question I would not put an entry in /etc/profile since that is system wide. It would be better to put it in /root/.bash_profile. That is always executed during login and typically where your environment is set. Also since SW-ANIKY is talking C executables and not java, /root/bin would be a more appropriate directory. A few people have said something similar to this already, but here is the entry I would use.
Code:
export PATH=$PATH:$HOME/bin
-or-
PATH=$PATH:$HOME/bin
export PATH
While most distributions include 'if' logic to execute .bashrc in their .bash_profile, it is possible that is missing in SW-ANIKY's .bash_profile and that is why it's not working. A more probable explanation is that he did not logout and log back in or execute the .bashrc using the command source ~/.bashrc.

Some may disagree with me, but it is common practice to use .bashrc more for entering aliases and functions. I would put anything to do with the environment in .bash_profile.

Bill
 
Old 12-13-2006, 12:59 PM   #13
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
Well disagree or not, don't care.
There is a manual page, people have to read it. You are right for alias and stuff: there shouldn't be any export command in bashrc files

This is the most common error found in Linux, bashrc, profile and such things. Amazing.

I agree with putting it in .bash_profile but it will only work if bash is invoked as bash, not as /bin/sh. Okay I'm fussy
Edit : won't work with dash,csh,.. for example

Last edited by nx5000; 12-13-2006 at 01:01 PM.
 
Old 12-13-2006, 02:40 PM   #14
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks a lot, to all. Problem solved.

Last edited by SW-ANIKY; 12-13-2006 at 02:42 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding vim to current install. DotHQ Red Hat 5 05-11-2006 10:08 AM
Can't compile in directories not in PATH tutwabee Linux - Software 5 09-27-2004 10:37 PM
Adding directories to the PATH statement kaplan71 Slackware 2 09-02-2004 04:57 PM
Adding Syntax Highlighting to VIM TastyWheat Linux - Software 2 02-27-2004 04:37 AM
RedHat 9.0 and $PATH - where are the directories? -G- Linux - General 6 11-18-2003 07:02 PM


All times are GMT -5. The time now is 06:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration