Boot and Run app

Hi, I am very new to Linux. I have a console app that Ive written in Pascal, runs great. It needs a valid wifi connection to run.
It is doing some SPI calls to get device info. Now, Im ready to deploy this. I get so frustrated with the whole security concepts in Linux… I just want to something to boot and run and app… Pretty much like we used to do in DOS.

  1. I noticed that the default user is Root… does that imply that the root user has assumed sudo rights? Meaning that I can simple changed the password, and that user by its nature has full control?
  2. How do I make that user login automatically?

I dont know why peple are so bent on passwords, if Im the only person in the world using this device.

Gord

ghamm
The root user always exists and has full permissions, yes. If you never open access to the device to www, especially not the SSH port 22, and the device is at home only accessible by yourself, the root user password indeed has no practical relevance. However it is better to give higher security recommendations by default then too low, e.g. when users open their SSH port to www for remot access, or it is a VPS, so every bot can brute-force to root access.

You can automatically login on boot via dietpi-autostart option ‘7’ ‘: Automatic login’. You can choose the user (e.g. root) there which should log in.

To run a script on boot, you have plenty possibilities. If you are not too experienced, you can simply put it into /var/lib/dietpi/postboot.d. The DietPi boot scripts will execute it automatically with root permissions then, once the boot process has fully finished, thus network is assured, but BEFORE login/outside the login shell.

If you want to have the script run after login (so inside the user shell session), you can add the script call (or the script lines themselves, if those are shell commands) to ~/.bashrc. This file/script is executed once the related user logs in, so as well automatically if you chose autologin. If the script is to execute some graphical program of print info etc (so it is no background task/service) then this is the way to go.

Thank you, just what I needed

Just to be clear, im still a litte fuzzy…
If I am logged in as root, does that mean I no longer need to use sudo before each command? Ive never understood why i linux when you are logged in as the admin (pi), why I need to use sudo to act as an Admin.
I hate sudo.

When you login as root, you don’t need to use sudo.
On most OSes (e.g. Raspbian), by default a non-root user exist (e.g. “pi”), while root login is disabled (no password assigned). There is no “admin” user btw, there are only users which have “sudo” permission, thus are allowed to use “sudo” and others are not. For security reasons this makes sense, not only if your machine is accessible by other persons (via local access or SSH), but as well for unexperienced users, since one cannot accidentally destroy the system that easily. E.g. one “problem” on Linux console is that rm /path/to/file will unrecoverable remove the file since no trashbin is used. I had some accidents with this myself by time :wink:.

However DietPi is a little “weaker” in this. It was founded in 2015 as pure root systems, so even most software titles ran as root users with full system access, which makes all such file access permissions things easier. However if some software has a bug or is harmful, it can then destroy the system, read/write private data and such. So nowadays most software titles run with limited permission as their own user, althougt this makes permission handling necessary by times. However by default DietPi is shipped with root user and assigned password for comfort reasons, the other user “dietpi” is optional available for login (similar to “pi” on Raspbian).

Thanks…

Ok, I have my build up and going. So far, im pleased… but ,

  1. When it boots, it gets the one of the end messages and stalls for 15-30 or so seconds… Its a different message most times. Once it boots, all seems to be well. Is this normal?

  2. Like I said before, i just want my pi to boot and run my app. So, the config menu has the option of logging in automatically, or manually… Im confused about this… If it will be headless, and no screen, only booting and running my app, does it need to be logged in to run my app at startup? or does autologin pertain only when you are using a screen?

Thanks again.

ghamm
If the app requires a login session or not depends on the app. But at least in most cases it should be possible to run it outside any user session. If you want to try it, place the execute line as a script into /var/lib/dietpi/postboot.d as mentioned above.
A more advanced solution would be to create an own systemd unit/service that runs the script at a desired boot stage, which can then be much earlier then the postboot solution.

Generally login session have nothing to do with an actual screen being attached or not. It just opens a shell (bash by default) with the chosen user authentication (thus permissions), so is actually an overhead. Even without any input devices (mouse/keyboard etc) a shell session can be opened, e.g. when logging in via SSH. With a systemd service/unit you can as well choose a user and set permissions much more precisely to your needs, so this is usually best but requires some reading about systemd :wink:.