Day 21 Learnings: System Administration and Control in Linux

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

  1. Find Executable Paths:
    Checked the path of the python binary:

     which python
    

Using the whereis Command

  1. Locate Command Files:
    Located binaries and man pages for ls:

     whereis ls
    
  2. Search for Custom Commands:
    Identified files for a custom executable.

Using the locate Command

  1. Search for Files:
    Quickly searched for a file named notes.txt:

     locate notes.txt
    
  2. Update Database:
    Ensured the database was current before searching:

     sudo updatedb
    

Using the date Command

  1. Display System Date and Time:

     date
    
  2. 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

  1. Display Current Month:

     cal
    
  2. Show Specific Years:
    Displayed the calendar for 2023:

     cal 2023
    

Using the systemctl Command

  1. Start, Stop, and Restart Services:
    Managed the Apache web server:

     sudo systemctl start apache2
     sudo systemctl stop apache2
     sudo systemctl restart apache2
    
  2. Check Service Status:
    Verified the status of the Apache service:

     sudo systemctl status apache2
    

Using the shutdown Command

  1. Schedule a Shutdown:
    Shut down the system in 10 minutes:

     sudo shutdown +10
    
  2. Cancel a Scheduled Shutdown:
    Aborted the scheduled shutdown:

     sudo shutdown -c
    
  3. Restart the System:

     sudo shutdown -r now
    

Problems I Encountered

  1. locate Command Not Returning Results:
    The database was outdated.

  2. Incorrect Time Format for date:
    Encountered errors when setting time.


How I Solved These Problems

  1. Updated the locate Database:
    Ran the following command to refresh the database:

     sudo updatedb
    
  2. 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!