Day 21 Learnings: System Administration and Control in Linux
Table of contents
Today focused on system administration commands for managing executable paths, services, and system settings like date, time, and shutdown operations. These are vital for controlling system behavior and monitoring processes.
What I Learned This Week
which
Command: Displays the full path of an executable file.whereis
Command: Locates binary, source, and manual files for a command.locate
Command: Searches for files by name.date
Command: Displays and sets the system date and time.cal
Command: Displays a calendar.systemctl
Command: Manages system services.shutdown
Command: Powers off or restarts the system.
Steps I Followed
Using the which
Command
Find Executable Paths:
Checked the path of thepython
binary:which python
Using the whereis
Command
Locate Command Files:
Located binaries and man pages forls
:whereis ls
Search for Custom Commands:
Identified files for a custom executable.
Using the locate
Command
Search for Files:
Quickly searched for a file namednotes.txt
:locate notes.txt
Update Database:
Ensured the database was current before searching:sudo updatedb
Using the date
Command
Display System Date and Time:
date
Set Date and Time:
Changed the system date to January 1, 2025:sudo date -s "2025-01-01 12:00:00"
Using the cal
Command
Display Current Month:
cal
Show Specific Years:
Displayed the calendar for 2023:cal 2023
Using the systemctl
Command
Start, Stop, and Restart Services:
Managed the Apache web server:sudo systemctl start apache2 sudo systemctl stop apache2 sudo systemctl restart apache2
Check Service Status:
Verified the status of the Apache service:sudo systemctl status apache2
Using the shutdown
Command
Schedule a Shutdown:
Shut down the system in 10 minutes:sudo shutdown +10
Cancel a Scheduled Shutdown:
Aborted the scheduled shutdown:sudo shutdown -c
Restart the System:
sudo shutdown -r now
Problems I Encountered
locate
Command Not Returning Results:
The database was outdated.Incorrect Time Format for
date
:
Encountered errors when setting time.
How I Solved These Problems
Updated the
locate
Database:
Ran the following command to refresh the database:sudo updatedb
Reviewed
date
Syntax:
Used the correct format for setting date and time:sudo date -s "YYYY-MM-DD HH:MM:SS"
Resources I Used
Linux Manual Pages
GeeksforGeeks: systemctl Command
Linuxize: Shutdown Command
The Linux Documentation Project
Conclusion
Today's session introduced essential tools for system administration. Commands like systemctl
and shutdown
are powerful for managing services and operations. Tools like which
, whereis
, and locate
simplify file and executable management.
Looking forward to diving deeper into advanced Linux administration topics!