-2

Due to my new job, I have to deal with GNU Linux. I've taken a 50 videos tutorial series, and I don't know how to install software from a terminal, or do it properly, at least, because when I restarted the terminal no change had been saved! I did it all as root, not sudo from my user.

I'll put an example, but I don't want you to focus on a particular software. I need the more generalized method. I'm trying to install modpoll, a software for ModBus emulating communications. I've download it from internet, so it should be OK. It comes in a zip file that, once unzipped, showed a .tgz archive. Using tar -xvzf modpoll.3.15.tgz I unzipped the .tgz archive.

The unpacked file shows other directories with the names of GNU Linux versions architecture (X86, ARM,i686...). I have no idea what's mine, so I tried to install them all. It seems to be simple - get into one of those and type modpoll to run modpoll.

I must advise an USB serial port adapter was properly installed and plugged at the time I was trying to launch modpoll. There's a problem here since it didn't recognize the device even when I already checked it out in /dev plugging and unplugging usbtty0 device (so it was right), but that's not my problem now.

The next, as I've already read, is to create a permanent path to the binaries so Ubuntu will find it when I eventually call modpoll from wherever in my terminal. So I've typed PATH=$PATH:/home/user/Apps/modpoll (the path to modpoll binary files in my system).

Then it seemed to work alright since, al least, modpoll is responding a communication error with the device and I don't have to stay in modpoll installation directories. Just from my home directory I can call modpoll and it is there.

I repeat, I'm logging as root, I type su then the root password and then I did it all I've mentioned, but when I restart the terminal and tried to run modpoll then I get modpoll: command not found. I restarted Ubuntu, and as before no modpoll command is located. What am I doing wrong?

karel
  • 122,292
  • 133
  • 301
  • 332
jotape
  • 1

1 Answers1

0

(added after). What about specifily modpoll. What they call "installation" is really is not that. That works only once "for try". You must select a place, where to put your folder modpoll, or just single binary for your arch (you may follow solution below). If it's all that folder ... Fo my, i find it convinient to create folder for such programns, prog -- in my home folder. Put it there. And add path assignment into .profile or .bashrc. Like this:

PATH="$HOME/prog/modpoll/x86_64-linux-gnu:$PATH"

In any case, further it's better to start read .... Star from

man bash

=======

Your skills really miss basics, so answer wont be short and souliton wont be fast for you.

Actually, as in Windows, interpreter looks for a file in PATH, but, unlike DOS/Windows, ignore current folder. So if you have working binary, right way to execute as is add a "./" before name, or full path, e.g. "/home/jotape/".

You as about install... I.e. to put binary file somewere, and have a possibility to just execute it by name from anywhere. So if you have working binary (i.e. you do not need to compile it from source), you may put it in some folder, like ~/.local/bin/ - simplest way, if you do not need to provide it to other users, and now you must add this to your path. Or if you want and have root rights, put it into /usr/local/bin/. This in PATH already.

PATH. Usually it defined in /etc/profile. In your home folder surely exist ".profile" file, that among other things look for presence of "bin" folder and add it to PATH, if any (mine from debain):

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

set PATH so it includes user's private bin if it exists

if [ -d "$HOME/.local/bin" ] ; then PATH="$HOME/.local/bin:$PATH" fi

So, as I say, create ~/bin or ~/.local/bin/ folder and put your binary there. Next time you log in, you have it in PATH.

*** Not always ~/.profile parsed. In most cases some program parses /etc/pfofile, then ~/.profile, that may parse ~/.bashrc. If user's shell is bash, bash usually read ~/.profile and ~/.bashrc. But it may not, if some parameters specified. In my case -- LXDE -- LXTerminal invoke bash with parameters to read .bashrc, so ~/.profile is not in play, and PATH will not be updated.

If it's your case too (you create bin folder, BUT it did not appear in PATH), you must find out, what is your shell:

echo $0

If bash, add to your ~/.bashrc :

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    if [[ ! "$PATH" =~  *"$HOME/bin"* ]] ; then
        PATH="$HOME/bin:$PATH"
    fi
fi

set PATH so it includes user's private bin if it exists

if [ -d "$HOME/.local/bin" ] ; then if [[ ! "$PATH" =~ "$HOME/.local/bin" ]]; then PATH="$HOME/.local/bin:$PATH" fi fi

Actually, you may just copy that lines from .profile, but without such modifications there will be situations, when it PATH appears doubles of your paths. It will work, you will not feel it, but it's ugly.

Hex
  • 11