Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new to Unix. I am using a default installation of FreeBSD, with the C shell (csh).

Suppose I have a command I can run by executing this: /sbin/abc, but cannot run by executing abc. How can I set certain path or something that make abc runnable everywhere?

share|improve this question

migrated from stackoverflow.com Dec 22 '10 at 19:27

This question came from our site for professional and enthusiast programmers.

    
    
what shell do you use? setting your path is done slightly differently in bash, csh, sh, tcsh, etc. You can generally run echo $SHELL to find out which shell you're using. –  Tim Dec 22 '10 at 7:08

2 Answers 2

up vote 5 down vote accepted

Aha, FreeBSD. That's tcsh, I believe.

So:

set path=(/sbin $path)
share|improve this answer

bash syntax:

export PATH=${PATH}:/sbin

sh syntax (two separate commands):

PATH=${PATH}:/sbin
export PATH

csh and tcsh:

setenv PATH "${PATH}:/sbin"
set path=($path /sbin)

This will append /sbin to your path, so when you type abc, the shell will also look in /sbin for it. You can also add the command to your ~/.bashrc file (or ~/.cshrc, ~/.tcshrc, ~/.profile, ~/.login—depending on which shell you use).

share|improve this answer
    
I got "export command not found" I am using Freebsd 8.1 –  Andy Leman Dec 22 '10 at 7:08
    
Let me know which shell you're using, and I'll update the syntax. –  Tim Dec 22 '10 at 7:09
    
I have no idea which shell I am using. It's default FreeBSD, i didn't change anything... –  Andy Leman Dec 22 '10 at 7:11
1  
type echo $SHELL to find out which shell you're using, and run the appropriate commands (I'm guessing tcsh/csh since you don't have export). I've updated this answer with syntax for all three. –  Tim Dec 22 '10 at 7:12
    
/bin/csh [ word padding...................] –  Andy Leman Dec 22 '10 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.