Process
- OS create process to run application
- Each process will have unique pid
- on linux we use
- ps
- kill
- top
- htop
Applications and Services in Linux
- Application execution is generally on-demand, i.e. process gets created on user action (execution or double click)
- There are certain processes which we want to run all the time
- database
- web
- ssh
- The above applications are referred as services or daemons as they run in the background
Services
- Terminology
- state: running, stopped/exited
- enabled/disabled
- Linux we have two service initialization systems
- sysvinit
- older approach based on unix
- we create scripts
- systemd
- modern where we create unit files
- sysvinit
| Feature | SysVinit | Systemd |
|---|---|---|
| Startup Process | Sequential | Parallel |
| Service Management | Shell scripts | Native binaries |
| Dependency Management | Manual | Automatic (with unit files) |
| Socket Activation | No | Yes |
| Logging | Directly to console | Journald (centralized logging) |
| Compatibility | Wide range of Linux distributions | Adopted by many major distributions |
| Simplicity | Simple and reliable | More complex with a steeper learning curve |
| Debugging | Shell scripts are easy to debug | Compiled binaries may be harder to debug |
| Unix Philosophy | Adheres to the Unix philosophy of doing one thing well | Aims to be a more comprehensive system and service manager |
| Boot Speed | Boot time depends on admin optimizations | Improved boot speed due to parallel startup and socket activation |
| Resource Control | Limited built-in support | Provides cgroups for resource control |
In summary, while SysVinit is known for its simplicity and compatibility, Systemd offers improved boot speed, parallel startup, automatic dependency management, socket activation, and centralized logging. However, Systemd is more complex and has a steeper learning curve compared to the simpler SysVinit approach
- Systemd requires a unit file
- Exercise:
- how to list services
- sections of unit file
- create a sample unit file for spring petclinic Refer Here
