command line - What's the real and correct way to install things in Ubuntu? - Ask Ubuntu


i know should apt-get things, i'm asking binaries aren't there, or ones need latest version. every time search how install these binaries on ubuntu, different answers. of course can paste bin /bin or directories in path, lots of apps full of other files, shouldn't best way. see instructions telling me add folder of app in path, happen if install like, 100 apps technique? wouldn't path variable big , messy? also, i'd passing path every app open, don't see better way install things in linux.

so, right way? also, if has path, correct way add paths path? see lots of ways, , confused.

i'd end once , all, because i'm tired of installing things in different ways, , wanted in correct , elegant way.

purpose of path variable

path meant shell - tells shell commands type in supposed live. example of on opensuse box once had. on ubuntu can type in iconfig command , bash go " oh, know - i'll run /sbin/ifconfig". well, on opensuse default path , doesn't have /sbin added it, bash "sorry, don't know ifconfig , i've no record of such file." have either run /sbin/ifconfig ( i.e. full path ) or in smart way - add /sbin path.

good example of why want when install custom scripts or binaries. let's have saved in /opt/my_stuff folder , , want call my_command name. well, have add /opt/my_stuff path.

how add directories path

the basic idea want append or join original $path new directory. may or may not know, items in path variable delimited :. want export variable, other programs ( children of shell ) know stuff. stuff must happen @ end of ~/.bashrc, when open shell , has read ~/.bashrc config, knows located.

here's example ~/.bashrc :

export path=$path:"/opt/microchip/xc16/v1.25/bin" 

in case , original $path expanded string of directories. add 1 more it, , save back. nothing complicated.

what have installing software

if installing file .deb archive or .run script, shouldn't worry path part. it's responsibility of software author simplify installation process. typically, they'll configure installation save stuff 1 of common directories belong path: installation script say, "hey, install software /usr/bin` , able use without effort.

if software authors install somewhere that's not typically in path, have configure path variable or have yourself. in example above, directory /opt/microchip created when installing microchip's ide , compiler. installer automatically put line ~/.bashrc. write scripts go /opt , mention in instructions users have configure path themselves.

the ~/bin directory

you see people recommending save script , other types of software ~/bin. folder belongs - user, if don't want share app other people on machine - that's you'd put it. difference /opt mentioned in few places , /opt neutral ground. if system administrator want both family have access app accounts - that's i'd put it.

as far bash shell goes, handles ~/bin being added path you. other shells, /bin/sh , or tcsh or ksh won't it, keep in mind if working on different system or want use different shell in ubuntu.

addressing specific parts of question

i see instructions telling me add folder of app in path, happen if install like, 100 apps technique? wouldn't path variable big , messy?

not - what's supposed go path directories. if typically install software in single directory ( such ~/bin or /opt ) require adding /opt. if each software has live in own folder under /opt , yes - you'd have add each , every single 1 path. can , however, write script add directories path. , let's say:

$ item in /opt/* ;                                                                                        if [ -d "$item" ];      path="$path:$item"      echo "$var"  fi  done 

and can live fine function @ end of ~/.bashrc , each time open shell, directories under /opt added automatically.

in example, write lot of scripts. live in ~/bin since of them single files, , there's no need them live in separate directories.

also, i'd passing path every app open, don't see better way install things in linux.

that's export variable for. passes stuff child processes of shell. user don't have anything. also, mentioned, it's not typically done - software authors create packages go directories in path /usr/bin.

the directories not in /opt neutral ground , sort of way developers "hey, our app 3rd party, it's not default."

using gui apps without path variable

once thing haven't been covered here .desktop files. put , these linux's version of windows shortcut , on steroids. lets i've build gui app in python, , want live in /opt folder, don't want user call command line - want them use nice , neat desktop shortcut. well, that's .desktop files come play. here's example:

$ cat /home/xieerqi/.local/share/applications/vivaldi.desktop                                                   [desktop entry] encoding=utf-8 version=1.0 type=application name=周迅 mv - youtube icon=vivaldi path=/home/xieerqi exec=/opt/vivaldi/vivaldi-bin --ppapi-flash-path --ppapi-flash-version --always-authorize-plugins --enable-npapi --no-first-run startupnotify=false startupwmclass=vivaldi onlyshowin=unity; x-unitygenerated=true 

while vivaldi app lives happily in /opt without ever needing referenced in path , can use .desktop shortcut launch it. again, you'd need manually create 1 each , every app, can guess linux has scripting ways automate that.

conclusion

so real , correct way install software on linux ? there none, there isn't way on windows or mac os x. windows app single .exe or folder .exe , live fine in c:\ folder. same here - on linux can have script or whole suite of software live in /opt, or ~/bin or wherever choose. choices , of course, must extend justified. want app available root only, only , or shared ? want accessible via name, or want type in full path app ?

additional information


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User