Hey,

Basically I want to be able to type something like 'editor &' and have an editor of my choice open. Similar to if you type 'emacs &' emacs opens. I was wondering where this information is kept and how to edit it for the desired results.

Thank you

Most shells provide the EDITOR environment variable (or you can set to have it exported in your rc file). If that is set the way you want you can use that. For example:

${EDITOR} &

would open Emacs if the environment had EDITOR exported as emacs.

Another way you might approach this would be to set an alias. Although, at that point why not just type the command you want in the first place?

The editor was just an example. For instance I may have written a program that I want to call without using the entire pathname and insteaad just want to call it 'move' or 'john'. What I am asking is how do I get linux to understand that 'John' means execute a program at location x.

Thank you

Either of my suggestions work. You can also write a bash (or whatever shell you use) function to do more complicated things like search paths and environment variables.

You can also create your own bin directory somewhere and add that to your $PATH. The $PATH environment variable is searched when a command is typed on the command line; first match is executed.

AFAIK, with most Linux distros which use Bash as the default shell; many of them already have $PATH set up to check for a bin sub-directory in the users home directory (or it might be something in .bashrc... can't remember offhand! But it's definitely there!).

So if you create a sub-directory called 'bin' in your home directory, you can copy any programs or scripts you've created into your personal bin folder and you should be able to access them from anywhere on the terminal without having to mess around with $PATH. Just type the name of the command as you would with any other program.

I always copy scripts/programs into my personal bin folder in my home directory if they are strictly for my own use. But if I come up with something that is useful to other users of my systems, I'll often copy them to /usr/local/bin/, which is already included in the system search path.

As a rule, I try to avoid copying my scripts into system directories like /bin/, /sbin/, /usr/bin/, /usr/sbin/ etc. Generally, the only scripts/programs that end up in those directories are ones that are put there by the package manager for whatever distro that particular machine happens to be running.

So my two cents is: Copy your own scripts/programs to /home/yourname/bin/ or /usr/local/bin/ depending on how accessible you need them to be.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.