7

I'm connected to a Linux box through SSH on which I don't have administrative privileges. The command I wish to use is called tree, but it isn't installed.

Is there any way I can load the tree program into my home directory and run it without the need to install it system wide?

6

tree doesn't seem to have particular dependencies (libc6) so I guess you can simply copy the executable (located in which tree on another system with tree installed or alternatively you can compile it from source, here's the home page of the project) in a directory on the Linux box which you're connected, say ~/bin/, then you just need to update your $PATH environment variable to add that directory.

If you're using Bash put this in your ~/.bashrc:

PATH=$PATH:~/bin/

Note: Be sure to match architecture and OS.

4
  • I can tell it's running linux by calling "echo $(uname)", but how do I figure out the architecture? – Corey T Foote Sep 19 '10 at 23:26
  • Show me the output of uname -m. – cYrus Sep 19 '10 at 23:33
  • That gives you the machine hardware name (e.g. x86_64, i686, ...). – cYrus Sep 19 '10 at 23:42
  • 1
    @Corey: echo is unnecessary. uname (and most others) do their own output. – Dennis Williamson Sep 19 '10 at 23:47
5
cd $HOME
# download latest tree source to home directory
wget http://mama.indstate.edu/users/ice/tree/src/tree-1.7.0.tgz
# unpack
tar xzfv tree-1.7.0.tgz
cd tree-1.7.0/
make
# install to $HOME directory
make install prefix=$HOME/bin
# this will create folders bin, and man
cd $HOME
# remove original source folder
rm -rf tree-1.7.0

# run tree
$HOME/bin/tree
# view man page
$HOME/man tree
1
  • 1
    Isnt't there an excedent /bin in the prefix ? The executable I get is /home/[myUsername]/bin/bin/tree. Bah, the essential part is that it works with a simple copy/paste – Balmipour Nov 20 '17 at 11:02
3

You would usually build and install it on the prefix $HOME. That means the binary would go into $HOME/bin, libraries into $HOME/lib and so on. Then you insure that these directories appear on $PATH, $LD_LIBRARY_PATH, $MAN_PATH, etc (usualy by editting your shell startup files) and it will work transparently.

Here's a recipe that will work with many programs

$ cd $HOME
$ mkdir src
$ cd src
$ wget http://host.name/path/to/program.tgz
$ tar xzfv program.tgz
$ cd program
$ ./configure --PREFIX=$HOME
$ make
$ make install

Note that unlike installing on /usr/local there is never any need for root privilege.

2
  • 1
    I suggest putting stuff in $HOME/local/ to keep the root folder a bit tidier. – user31752 Sep 20 '10 at 1:22
  • @mankoff: I never thought of that. I've simple stopped seeing those directories. – dmckee --- ex-moderator kitten Sep 20 '10 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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