Skip to main content

LFCS: Essential Commands (20%)

This sectiondocument covers essential Linux commands for Git, services, system performance, application constraints, disk troubleshooting, and SSL management.


Goals

Essential Commands 20%

    Basic Git Operations Create, configure, and troubleshoot services Monitor and troubleshoot system performance and services Determine application and service specific constraints Troubleshoot diskspace issues Work with SSL certificates

    1. Basic Git Operations

    Learn

    • Clone repositories, check status, commit, and push.

    Commands

    # Clone repository
    git clone <url>
    
    # Check status
    git status
    
    # Add files and commit
    git add <file>
    git commit -m "message"
    
    # Push to remote
    git push origin main
    
    # Pull latest changes
    git pull
    

    Exercises

    1. Clone a public repository.
    2. Make a change, commit it, and push to a forked repo.

    2. Create, Configure, Troubleshoot Services

    Learn

    • Use systemctl to manage services.
    • Check logs for troubleshooting.

    Commands

    # Start, stop, restart service
    sudo systemctl start <service>
    sudo systemctl stop <service>
    sudo systemctl restart <service>
    
    # Enable/disable at boot
    sudo systemctl enable <service>
    sudo systemctl disable <service>
    
    # Check logs
    journalctl -u <service>
    

    Exercises

    1. Enable and start a service.
    2. Check the last 20 lines of the service log.

    3. Monitor & Troubleshoot System Performance

    Learn

    • Check CPU, memory, disk usage.
    • Identify resource-consuming processes.

    Commands

    # CPU and memory
    top
    htop
    vmstat 2 5
    
    # Disk usage
    df -h
    du -sh /path/to/dir
    
    # Check running processes
    ps aux | sort -nk 3 | tail -10
    

    Exercises

    1. Identify top 5 processes consuming CPU.
    2. Check disk usage of /var/log.

    4. Application & Service Constraints

    Learn

    • Resource limits for users or services.
    • Configure ulimit.

    Commands

    # Check limits
    ulimit -a
    
    # Set temporary limit
    ulimit -n 4096
    
    # Persistent limits
    sudo nano /etc/security/limits.conf
    # user soft nofile 4096
    # user hard nofile 8192
    

    Exercises

    1. Increase the open file limit for a user temporarily.
    2. Make the change permanent.

    5. Troubleshoot Diskspace Issues

    Learn

    • Find large files or directories.
    • Free space using cleanup tools.

    Commands

    # Find large directories
    du -ah / | sort -rh | head -20
    
    # Remove old logs
    sudo journalctl --vacuum-time=7d
    

    Exercises

    1. Identify top 10 largest files.
    2. Clear old logs to free space.

    6. Work with SSL Certificates

    Learn

    • Generate, verify, and check certificates.
    • Use OpenSSL.

    Commands

    # Generate self-signed certificate
    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
    
    # Verify certificate
    openssl x509 -in server.crt -text -noout
    
    # Check SSL connection
    openssl s_client -connect example.com:443
    

    Exercises

    1. Generate a self-signed certificate.
    2. Inspect and verify the certificate using OpenSSL.

    Exam Tips

    • Practice using systemctl, top, df, du frequently.
    • Know basic Git workflows.
    • Be comfortable troubleshooting disk space and service issues.
    • Understand SSL certificate basics with OpenSSL.