Executing commands on a different partition.

How do I go about executing commands which are installed on a different partition?

I guess I need to temporarily change the environment... path and ld_library_path...

Should that do it?

I'm basically trying to add /net/usr/local/bin to path and /net/usr/local/lib to library path.

Not really sure how to do that.
 
Do you mean that you have a command / application which is somewhere else than /bin, /usr/local/bin, and so on? You can execute it directly by typing ./some/another/path/command after giving execute permission to the command ( chmod a+x command). Or you can first add the permission to the command, and then add the directory of the command to the path variable.

If it is a bash script, you could start with
PATH=$PATH:~/net/usr/local/bin
and so on for LD_LIBRARY_PATH.
 
Do you mean that you have a command / application which is somewhere else than /bin, /usr/local/bin, and so on? You can execute it directly by typing ./some/another/path/command after giving execute permission to the command ( chmod a+x command). Or you can first add the permission to the command, and then add the directory of the command to the path variable.

If it is a bash script, you could start with
PATH=$PATH:~/net/usr/local/bin
and so on for LD_LIBRARY_PATH.
What is I'm using csh. (I'm constantly hearing that I shouldn't use bash on FreeBSD. Not sure about the easiest way to change $PATH.

I found out I can change LD_LIBRARY_PATH using ldconfig -m /net/usr/local/lib

Also where should I make these changes? ~/.cshrc?
 
.cshrc you can modify, you may need to log out/in or source .cshrc to pick up the changes. Syntax is something like:

setenv PATH ${PATH}:/net/usr/local/bin

Using bash is fine; writing shell scripts assuming bash without a shebang specifying bash is bad.
 
I want to set these variables when I login via ssh. Where should I set them?

.cshrc .shrc .login .profile ?
 
What is I'm using csh. (I'm constantly hearing that I shouldn't use bash on FreeBSD. Not sure about the easiest way to change $PATH.

I found out I can change LD_LIBRARY_PATH using ldconfig -m /net/usr/local/lib

Also where should I make these changes? ~/.cshrc?
I'm not sure who told you that. I use bash, zsh and ksh on FreeBSD.

I think what they were telling you is don't write bash shell scripts. Use the Bourne shell standard. It is the most portable and Bourne shell scripts will work on a FreeBSD system with no other shells installed.

BTW, Bourne shell scripts written for FreeBSD, assuming all things a equal such as path names, will work on any BSD system, on Illumos, Solaris, and AIX systems. Always code your scripts to the Bourne standard. If OTOH you're writing for Linux-only, bash scripts would be acceptable. Bourne scripts will run under bash.

The reason for this is the Bourne shell in FreeBSD has certain builtins, such as [, ], and others, that are handled by the shell whereas bash executes external commands, for these commands. Bash instead uses [[, and ]] as their builtin versions. If you're writing shell scripts for linux-only, write bash scripts. If you're writing shell scripts for FreeBSD, write Bourne scripts.

And there are other bash-isms that are incompatible with Bourne. Bash has imported ksh's arrays but implemented them in an incompatible manner. (Shell script arrays are why Oracle used to distribute ksh scripts and now distribute bash scripts.)

There's a lot more to shell scripting but for interactive use, use whatever shell you want. Just leave root's shell the default it came with. Else in an emergency you may not even be able to use your system in single user state. If you do want to use bash as your root shell, simply sudo to root and type in, exec bash. You now have a bash shell for just that one root sudo session.

One last thing. On linux /bin/sh is also bash, except that bash disables some of its advanced features.
 
I have made path and library-path changes to ~/.profile on the remote system and when logging in via ssh can run programs installed on an NFS attached server, which is nice.

Some programs, such as tmux, ytree work ok, but others such midnight commander give me errors such as:-

ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libssh2.so.1"

This file seems to exist on 13.2-R but not on 14.0-R...
 
What is it that you are trying to do? It seems that you are mounting a 13.2 share on a 14.0 system? Why not install the programs you want to run locally on the 14.0 system? It's understandable (in the 1990s sense) if you want to mount a share with a larger application locally (maybe for licensing or size reasons?), but it doesn't seem like it's worth the effort to do so for programs like tmux, etc. Does the 14.0 system have a read only local partition, or is it severally limited for space?

I know it's a hot take, but mounting another systems local (especially one with a different major freebsd version) and modifying configs to add it to the path and ld path seems like a headache that isn't worth the effort without a really good reason to do so. Besides the path and ld stuff, programs may also have dependencies on other resources (stuff in usr/local/share for example) that won't be present where expected, and would require more config modifications (some of which may not be possible).
 
What is it that you are trying to do? It seems that you are mounting a 13.2 share on a 14.0 system? Why not install the programs you want to run locally on the 14.0 system? It's understandable (in the 1990s sense) if you want to mount a share with a larger application locally (maybe for licensing or size reasons?), but it doesn't seem like it's worth the effort to do so for programs like tmux, etc. Does the 14.0 system have a read only local partition, or is it severally limited for space?

I know it's a hot take, but mounting another systems local (especially one with a different major freebsd version) and modifying configs to add it to the path and ld path seems like a headache that isn't worth the effort without a really good reason to do so. Besides the path and ld stuff, programs may also have dependencies on other resources (stuff in usr/local/share for example) that won't be present where expected, and would require more config modifications (some of which may not be possible).
It's a learning exercise... It looks like I will need to run freebsd-update on my server before too long.

Since you mention /usr/local/share, I don't know how a program is directed to look for the share directory and is it possible the append to its search path?
 
Gotcha, sounds fun.

About usr/local/share, it entirely depends on the programs you are running and where they expect to find resources. A lot of software has these paths hardcoded at compile time, some can be configured, and some programs don't have any unexpected resources outside of their binaries. There is no single global way to set it or really to know, it's the sort of thing you'll discover as you go. Other things you'll discover are askew are man pages, info pages, include paths, possibly libdata/exec paths, etc.

You can probably go pretty far with just appending to PATH and LD_LIBRARY_PATH for most simple utilities. Another setup to mount shares with executables though would be to mount them under the same prefix path that was provided when the executables were built (for example, compile your ports on the server hosting the share with a prefix of /opt, then mount that share locally to /opt). This way all the paths would remain consistent, and external resources would be present where they are expected to be present. This would require compiling from source and providing a different prefix, just a thought.

good luck!
 
Back
Top