LFCS: Essential Commands (20%)
This section covers essential Linux commands for Git, services, system performance, application constraints, disk troubleshooting, and SSL management.
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
- Clone a public repository.
- Make a change, commit it, and push to a forked repo.
2. Create, Configure, Troubleshoot Services
Learn
- Use
systemctlto 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
- Enable and start a service.
- 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
- Identify top 5 processes consuming CPU.
- 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
- Increase the open file limit for a user temporarily.
- 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
- Identify top 10 largest files.
- 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
- Generate a self-signed certificate.
- 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.