Recent

Author Topic: [SOLVED]How to start a program in Linux without ./  (Read 2069 times)

cdbc

  • Hero Member
  • *****
  • Posts: 1026
    • http://www.cdbc.dk
[SOLVED]How to start a program in Linux without ./
« on: March 01, 2021, 09:13:02 am »
Hi
I'm wondering, how come i've got to start my program with ./myapp, when f.ex Git starts without ./ ?!?
What's the difference, is there some option/parameter that I can add or adjust?  ::)
Regards Benny
« Last Edit: March 01, 2021, 04:25:56 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: How to start a program in Linux without ./
« Reply #1 on: March 01, 2021, 09:28:29 am »
No place. GIT is in a directory in the $PATH and your binary not.

balazsszekely

  • Guest
Re: How to start a program in Linux without ./
« Reply #2 on: March 01, 2021, 10:40:36 am »
Hi
I'm wondering, how come i've got to start my program with ./myapp, when f.ex Git starts without ./ ?!?
What's the difference, is there some option/parameter that I can add or adjust?  ::)
Create a deb package for you application. After install, you can start it from a terminal by typing the package name, without "./".
« Last Edit: March 01, 2021, 10:42:40 am by GetMem »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: How to start a program in Linux without ./
« Reply #3 on: March 01, 2021, 10:51:34 am »
Another practical trick:

I create a ~/bin that I put in the path (editing .bashrc).

Then I create symlinks for projects that I'm working on from the bin directory to the binary I want to run. This means the live version of the binary remains in the project dir (for easy editing/testing/updating), but allows executing without path.

cdbc

  • Hero Member
  • *****
  • Posts: 1026
    • http://www.cdbc.dk
Re: How to start a program in Linux without ./
« Reply #4 on: March 01, 2021, 01:29:36 pm »
Hi
@ getmem: my PCLinuxOS works with rpm's, and I think it's a bit overkill for my apps  ;)
@ marcov:
  1)  That makes perfectly sense, thank you.
  2)  Cool trick, i'll use that.  ;)

Thank you very much guys  :)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: How to start a program in Linux without ./
« Reply #5 on: March 01, 2021, 02:51:00 pm »
I'm wondering, how come i've got to start my program with ./myapp, when f.ex Git starts without ./ ?!?
What's the difference, is there some option/parameter that I can add or adjust?  ::)
Regards Benny

The reason is that, unlike e.g. Windows, most *nixen don't look in the current directory for the executable, only in the PATH. If a program is not installed in any of the directories in the PATH you have to tell the system where it is in the invocation.

Another practical trick:

I create a ~/bin that I put in the path (editing .bashrc).

Then I create symlinks for projects that I'm working on from the bin directory to the binary I want to run. This means the live version of the binary remains in the project dir (for easy editing/testing/updating), but allows executing without path.

I think most of us on Linux do that; it's extremely handy. We run all of our internal tools that way :D

Another "trick" is to link from /usr/bin/ (or any "bin" folder, in fact) though that usually requires being root. It's, for example, how startlazarus is invoked:
Code: Bash  [Select][+][-]
  1. $ ls -l /usr/bin/startlazarus
  2. lrwxrwxrwx 1 root root 38 jul  7  2020 /usr/bin/startlazarus -> /usr/share/lazarus/2.0.10/startlazarus
and it's used mostly for multi-user installs.
« Last Edit: March 01, 2021, 03:02:23 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: How to start a program in Linux without ./
« Reply #6 on: March 02, 2021, 11:31:47 am »
I create a ~/bin that I put in the path (editing .bashrc).
+1  ;)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018