Changing Your ksh Path


Changing Your ksh Path

The path statement tells the shell where to look for commands, scripts, and programs. For example, if you issue a command, the path statement tells the system to look in the named directories in a specific order.

As the following steps show, you change your ksh path by first identifying where your path statement is located, then editing the file that contains it (Code Listing 8.15).

Code Listing 8.15. First, find out the location of your path statement(s).

$  grep PATH ~/.profile ~/.kshrc /home/users/e/ejray/.profile:PATH=/usr/  bin:/usr/local/bin:/usr/sbin: /home/users/e/ejray/.profile:export PATH $ 

To change your ksh path:

1.

grep PATH ~/.profile ~/.kshrc

To begin, check for path statements in the configuration files located in your home directory. If you wanted, you could also review the /etc/profile file, but you cannot edit that one.

2.

Look through your system configuration files for a path statement. As Code Listing 8.15 shows, it'll look something like PATH=/usr/bin:/usr/local/bin:/ usr/sbin. Remember, if you have more than one path statement, find the last one executed. If you don't have a path statement in your personal configuration files at all, then add one.

3.

cp ~/.profile ~/.profile.backup

Make a copy of the file containing the path statement so that you can recover if you make mistakes. See Chapter 2 if you need more information on copying files.

4.

vi ~/.profile

Use the editor of your choice to edit the configuration file with the path statement.

5.

PATH=$PATH:$HOME/scripts

Add a new path statement immediately below the last path statement. In this example, PATH is set to its current value ($PATH) plus the directory ($HOME/scripts) you wish to append to your path. (Figure 8.5).

Figure 8.5. Add or modify a ksh path statement in your editor.


6.

Save the file and exit from your editor. Refer to Chapter 4 for help if you need it.

7.

su - yourid

As you learned back in Chapter 3, this command starts a new login shell so you can test your changes before logging out.

8.

echo $PATH

Display the current path environment variable. This should include the addition you just made (see Code Listing 8.16).

Code Listing 8.16. Verify that your new path statement exists.

$ echo $PATH /usr/bin:/usr/local/bin:/usr/sbin:/home/  users/e/ejray/bin:. $ 




Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net