Output Redirection
Details of how to manage command output in Linux using redirection operators
Standard Output (stdout)
■ Default output stream for command results
■ Displays output on the terminal screen
Basic Output Redirection (>)
■ Redirects standard output to a file
■ Overwrites existing file content
Example of >
echo Hello, world! > greetings.txt
Append Output Redirection (»)
■ Appends output to the end of an existing file
■ Preserves previously recorded content
Example of »_space;
echo “Apache service restarted successfully”»_space; /var/log/service.log
Standard Error (stderr)
■ Separate stream for error messages
■ Allows redirection of error messages independently from regular output
Example of stderr
systemctl restart apache 2> /var/log/apache_error.log
2»
Append error output
&>
Redirect both stdout and stderr
Captures all output and error messages into one log file