1. Which command restarts a running service?
systemctl restart stops and then starts a service again. It’s used to apply new configurations or recover from temporary failures.
sudo systemctl restart nginx
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Linux & Shell Scripting · Question Set
Package Management & System Services interview questions for placements and exams.
Questions
14
Included in this set
Subject
Linux & Shell Scripting
Explore more sets
Difficulty
Mixed
Level of this set
Go through each question and its explanation. Use this set as a focused practice pack for Linux & Shell Scripting.
systemctl restart stops and then starts a service again. It’s used to apply new configurations or recover from temporary failures.
sudo systemctl restart nginx
For complete preparation, combine this set with full subject-wise practice for Linux & Shell Scripting. You can also explore other subjects and sets from the links below.
yum (Yellowdog Updater Modified) is used for package management on Red Hat-based systems. It handles installation, dependency resolution, and updates automatically.
sudo yum install httpd -y
dpkg installs or removes .deb files manually without fetching from repositories. It’s often used for troubleshooting or offline installations when APT is not available.
sudo dpkg -i package.deb
systemctl is the primary command to manage services on systems using systemd. You can start, stop, enable, or check the status of services using it.
sudo systemctl start nginx
systemctl enable creates a symbolic link in the system startup directories. It ensures the service automatically starts during system boot without manual execution.
sudo systemctl enable docker
systemctl status displays whether a service is active, inactive, or failed. It also shows logs from the systemd journal, helping quickly diagnose service issues.
sudo systemctl status nginx
journalctl is part of systemd and displays log entries collected by it. Use -u followed by the service name to see logs specific to that unit, and -f to follow in real time.
journalctl -u ssh -f
On Debian systems, use apt update to refresh the package index, then apt upgrade to install new versions. On RHEL or CentOS, use yum update. Always run updates with sudo to apply them system-wide.
sudo apt update && sudo apt upgrade -y
Start by checking the service status with systemctl status servicename. Then use journalctl -u servicename to review detailed logs and identify errors. Fix missing dependencies or configuration syntax errors accordingly.
systemctl status nginx journalctl -u nginx
Use apt autoremove or yum autoremove depending on the system. This removes the specified package and related libraries not used by others. It helps keep servers lean and avoids unnecessary storage usage.
sudo apt remove nginx -y && sudo apt autoremove -y
Use systemctl list-unit-files --type=service to see which units are enabled or disabled. You can also run systemctl is-enabled servicename to check the startup behavior of a specific service.
systemctl list-unit-files --type=service | grep enabled
Unit files define how systemd manages services, sockets, targets, and timers. They are stored under /etc/systemd/system for custom services and /lib/systemd/system for system-managed ones.
/etc/systemd/system/myapp.service
APT (Advanced Package Tool) is used on Debian-based systems like Ubuntu to install, remove, and update packages. The command apt install <package_name> downloads and installs the package along with dependencies.
sudo apt install nginx -y
reload signals the service to re-read configuration files without a full restart. This reduces downtime, making it ideal for web or database servers where uptime is critical.
sudo systemctl reload nginx