LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Running tar files (https://www.linuxquestions.org/questions/linux-software-2/running-tar-files-686106/)

bobland 11-25-2008 06:06 PM

Running tar files
 
I recently had a problem after upgrading Ubuntu 7.10 32 bit to 8.10 64 bit. Sunbird would not work. I had to reinstall it but it would only install the 64 bit version which would not read my files.

I downloaded the 32 bit version and untared it to my download directory. It would not recognize the binary run files.

Found a web page that advised to move the sunbird directory to opt and make a link to usr. Worked like a charm!

Sunbird is the only directory in my /opt dir. Where does one normally put untared files for programs and what is the trick to get them to run?

I guess this question applies only to tars that untar in the pwd.

Thanks,
bobland

uberNUT69 11-25-2008 06:49 PM

If you want to execute a program without typing it's full path, then it needs to be in your $PATH.
That would usually mean that you put it in /usr/local/bin or $HOME/bin, or a link from the extracted binary to one of those locations.

rlhartmann 11-25-2008 08:05 PM

Other options are to add the location to your PATH variable by
adding to it in the ~/.bash_profile as

PATH=$PATH:/path_to_program

or to simply add an alias in ~/.bashrc to the

alias pro='/opt/path/bin/program'

or to similar files for different shells.

bobland 11-26-2008 10:12 AM

I can understand adding the program to the path variable but why wouldn't it run from its own directory?

bobland

uberNUT69 11-26-2008 10:39 AM

if your current working directory ($PWD) is not in the $PATH then precede the command with ./

eg.
$ ls
mycommand.sh
$ mycommand.sh
bash: mycommand.sh: command not found
$ ./mycommand.sh
HOORAY!

;)

i92guboj 11-26-2008 11:20 AM

Quote:

Originally Posted by bobland (Post 3355431)
I can understand adding the program to the path variable but why wouldn't it run from its own directory?

bobland

Because "./" (current dir) is not in $PATH.

You can add it, but it's considered a security risk. If you download some malware or someone place a binary file called "ls" in your home directory, and you have ./ in your $PATH it might be run instead of the system command ls, which might result in very bad things if it's indeed some kind of malware.

I advice you to follow the convention, and run the program as ./myprog, which is what everyone else does.


All times are GMT -5. The time now is 08:13 PM.