Day 9 – Linux Output Redirection and Error Logs


On Day 9 of my DevOps journey, I focused on redirecting output, logging errors, generating basic system reports, and searching files effectively with grep
, find
, and locate
.
Commands I Practiced
📄 Output Redirection & System Info Logging
Created a basic system status report:
echo "########################################" > /tmp/sysinfo.txt date >> /tmp/sysinfo.txt echo "########################################" >> /tmp/sysinfo.txt uptime >> /tmp/sysinfo.txt free -m >> /tmp/sysinfo.txt df -h >> /tmp/sysinfo.txt
Redirected output:
uptime > /tmp/sysinfo.txt uptime >> /tmp/sysinfo.txt
Overwrote and appended to files using:
>
for overwrite>>
for append2>>
for error loggin
Error Redirection
Captured command errors:
freeeee -m 2>> /tmp/error.log
freesdsd -m &>> /tmp/error.log
cat /tmp/error.log
Combined standard output and error:
free -m &>> /tmp/error.log
📊 Text & File Utilities
Counted lines:
Grep & pipe combinations:
File search:
Installed and used
mlocate
:- searches a prebuilt database rather than scanning the filesystem each time, making searches very quick.
🚀 Key Learnings
✅ Redirection is crucial for logging and automation
✅ 2>>
and &>>
help track and isolate errors
✅ grep
, find
, and locate
are essential for sysadmin file discovery
✅ Created a real-world sysinfo.txt
file combining date, uptime, memory, and disk usage
Subscribe to my newsletter
Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
