Modifying PATH (LINUX, Ubuntu) | Unix Linux Forums | Ubuntu

  Go Back    


Ubuntu Ubuntu is a complete desktop Linux operating system, freely available with both community and professional support.

Modifying PATH (LINUX, Ubuntu)

Ubuntu


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-30-2011
Tolmac Tolmac is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 1 September 2011, 6:53 PM EDT
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Modifying PATH (LINUX, Ubuntu)

Hello,

I'm a newbi to Unix and the last few weeks I have been trying to learn Unix through a book called Unix in 24 hours. I have tried advanced shell programming (that's what the chapter is called) today and what the excersise was all about was to create mylocate - a version of locate that is a shell script. The first step was to write a script that would build a database of every file and directory that is accessible to my login. Once that script was done and changed to executeable I tried it out as he (the author) had suggested and I got outputs similar to the ones in his book. So that step worked. Next was to create a script that used grep to allow easy file searching. (I try to understand as much as I can but not everything is always explained, so I'm still stumbling around in the dark quite a bit...). The second script was called mylocate. Once that was executable I again did some testruns he suggested and they worked (e.g. ./mylocate "\.c$" | wc -l ).

The problem started once I did the next step - to make it part of my overall environment...
So like he suggested, I went back to $HOME with cd (my $HOME is /home/ubuntu), created a new bin (mkdir bin) and moved both scripts I had written somewhere else (in my file that is in home/ubuntu/data/user) into the new bin (with mv). When I move to bin and check with ls, both scripts are there (mkmylocatedb and mylocate). Both are still executable. Next step would be to modify PATH so that at the end I only need to type in command names from my new bin (he wanted to link it to .profile). He said to write:

Code:
echo 'export PATH="${PATH}:$HOME/bin"' >> ~/.profile

Once I did that, nothing worked - and any other scripts I wrote afterwards and are linked to bin are not working either. I tried every combination I could and nothing, only command not found. I went to .profile and opened it with the vi editor - deleted the export blablabla out and saved the changes. Now at least ./mylocate works again but nothing else and only when I have moved to bin - anywhere else I get the same error message as before.

.profile says first something about its execution, when and when not it's read, where the default is set (in /etc/profile unmask 022), some info about if running bash (my shell is bash) and then the last if statement is:

Code:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

So my private bin exists, the command I was supposed to write was $HOME/bin - and as $HOME is /home/ubuntu it should work, shouldn't it? What do I have to type (and more importantly why) to actually link the new bin to .profile (or would I have to link it to /etc/profile???) so I could actually execute it like I can ls or cat or cp or any other command? (wherever I am..)

Sorry for this lengthy thread. I hope I haven't left out any important information - if I did, please let me know.

Thank you so much!

Last edited by pludi; 08-31-2011 at 07:02 AM..
Sponsored Links
    #2  
Old 08-31-2011
yazu yazu is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 15 December 2014, 11:26 AM EST
Location: From far
Posts: 987
Thanks: 21
Thanked 232 Times in 226 Posts
.profile is executes only on login. You should logout and login. The better way is to add your changes in PATH to .bashrc - it executes every time an interactive shell (bash) starts.

PS: And I could'n read the whole post.

PSS: Just 5 cents. I have the file ".shrc" where all common commands for all shells are (like export PATH) and source this file in every specific "rc" file - .bashrc, .kshrc, and .zshrc in my case.
The Following User Says Thank You to yazu For This Useful Post:
Tolmac (09-01-2011)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Modifying Linux in WesternDigital net disks mosndup Linux 2 12-16-2010 07:10 AM
Ubuntu samba server path royalibrahim Ubuntu 0 09-24-2010 08:21 AM
Modifying $PATH variable in /etc/profile Deepali UNIX for Dummies Questions & Answers 3 03-12-2001 12:17 PM



All times are GMT -4. The time now is 01:37 AM.