You are not logged in.

#1 2012-06-23 19:58:40

giwrg98
Member
Registered: 2012-04-12
Posts: 81

How can I start an executable without specifying the directory?

I have downloaded the tor browser bundle and I would like to be able to start it with a command like "torbrowser" and not by specifying the full directory?

Offline

#2 2012-06-23 20:14:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,614
Website

Re: How can I start an executable without specifying the directory?

1. move it to somewhere appropriate that is already in your $PATH,
2. add it's current location to your $PATH, or
3. add the following to ~/.bashrc

alias torbrowser='/path/to/the/torbrowser'

I'd suggest one of the first two, or a combination of both.  Many people will have a "scripts" folder somewhere in their users home directory that they add to their path.

Last edited by Trilby (2012-06-23 20:14:55)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-06-23 20:17:44

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: How can I start an executable without specifying the directory?

Lots of ways.

An alias, a script (or a symlink) in /usr/bin is probably the most common. But if you place it in one of these folders it will probably work too:

/usr/local/bin
/usr/bin
/bin
/usr/local/sbin
/usr/sbin
/sbin
/usr/bin/vendor_perl
/usr/bin/core_perl
/opt/qt/bin

Got the list from here:

$ which foo
which: no foo in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/qt/bin)

"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#4 2012-06-23 20:20:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,614
Website

Re: How can I start an executable without specifying the directory?

DSpider wrote:

Got the list from here:

$ which foo
which: no foo in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/qt/bin)

or just

echo $PATH

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2012-06-23 23:36:00

RGErrDay
Member
Registered: 2012-06-17
Posts: 2

Re: How can I start an executable without specifying the directory?

you can add it to path or you can do this which is what i like to do

ln -s <path>/<to>/<execucutable> /usr/bin/<execuctablename>

for example this is what i would do for firefox in my home directory

ln -s /home/root/firefox/firefox /usr/bin/firefox

**NOTE** YOU MUST BE ROOT TO DO THEM COMMANDS EITHER VIA SU OR SUDO OR JUST BEING ROOT


Microsoft gives you Windows. Linux gives you anything you want A Small House or America

Offline

#6 2012-06-23 23:43:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,614
Website

Re: How can I start an executable without specifying the directory?

I don't see a point in putting a link in /usr/bin to something in your home directory.  If you're putting something in /usr/bin anyways, why not just move the program there?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2012-06-24 00:36:19

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,143

Re: How can I start an executable without specifying the directory?

I don't think it is a good idea to put it in /usr/bin at all but if you must, isn't it safer to move it there, as Trilby suggested? And change the permissions appropriately? That doesn't strike me as especially wise but it seems better than symlinking to an executable in your home directory from /usr/bin.

One way to mitigate security threats is to limit the PATH root uses. So for an ordinary user, you might include /usr/local/bin or ~/bin. But for root, you wouldn't include these. This makes it a little bit harder to run something malicious as root inadvertently. If you start symlinking to executables in your home directory from /usr/bin, you defeat this. For example, I use this PATH for root:

/usr/bin:/usr/sbin:/bin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl

So root can't even run stuff under /usr/local on my machine without explicitly giving the path. But if I symlinked from /usr/bin to stuff under ~/, there would be no point in the restriction.

EDIT: but I just realised sudo can... damn!

Last edited by cfr (2012-06-24 00:39:59)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#8 2012-06-24 00:39:17

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,095
Website

Re: How can I start an executable without specifying the directory?

Trilby wrote:

I don't see a point in putting a link in /usr/bin to something in your home directory.  If you're putting something in /usr/bin anyways, why not just move the program there?

Well, it would allow other users to get to the binary easily, even if they aren't sudoers. But, on a single-user machine, it's mostly user-preference which would dictate it's location. I keep a .bin folder in my home folder which I've added to the path. From there, I would symlink tor to that folder.

So that would be the following:

$ mkdir -p $HOME/.bin
$ export PATH=$PATH:/$HOME/.bin
$ ln -s /path/to/tor $HOME/.bin/tor

If you want that to persist, that second line needs to be added to either your .bashrc or your .bash_profile. Usually, I prefer the second for variable declarations, but as far as I'm aware, that's also user-preference.

All the best,

-HG

Offline

#9 2012-06-24 01:49:51

ismaelvc
Member
From: México, D.F.
Registered: 2012-02-26
Posts: 136

Re: How can I start an executable without specifying the directory?

I like to use alias, but I have a doubt.

I have my laptop set to load guake at xfce session start, the first thing I use to do is put some music I usually do this lately with:

dubstep

for example, which is an alias in ~/.bashrc:

alias dubstep='cvlc musica/dubstep.pls'

you can set alias on the fly with echo and redirection:

echo "alias covers='cvlc musica/covers.pls'" >> .bashrc

what I usualy do next is to press "Ctrl+Z" and then:

bg

So i can do something else at the prompt again, what I don't know is how to do all that in one same command, that is to make vlc (cvlc) play in the background /musica/covers.pls, by just typing [covers], I just started reading "The Linux Command Line" thats why I ask lol! wink


Laptop: LG LM70 Express                                                  Kernel: 3.14.2-1-ARCH   
CPU: Intel Pentium M processor @1.86GHz                  Hard Drive: 80G
Video: Mobility Radeon X600                                            X Driver: xf86-video-ati
Memory Size: 1.5G + zramswap: 384M + swap: 3G

Offline

#10 2012-06-24 02:03:26

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: How can I start an executable without specifying the directory?

giwrg98 wrote:

I have downloaded the tor browser bundle and I would like to be able to start it with a command like "torbrowser" and not by specifying the full directory?

Install it from AUR: http://aur.archlinux.org/packages.php?O=0&K=tor-browser

> pacman -Qlp tor-browser-en-2.2.37_rc1-1-i686.pkg.tar.xz|grep usr/bin/.
tor-browser-en /usr/bin/tor-browser-en

aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

Board footer

Powered by FluxBB