I have an assignment where I am required to back up the
/var/log/message to text files in a different folder such as the Desktop. It will also create a file called Execution.txt to record the date and time whenever the bash script is run. I do have this code that I've written yet every time I run it, it gives me:
./bash.sh: line 7: /var/log/dmesg: Permission denied ./bash.sh: line 8: /var/log/syslog: Permission denied ./bash.sh: line 9: /var/log/message: Permission denied
However, it does create these files on the desktop, but the message and dmesg files are empty. I was wondering if this is normal or have I done something wrong? Below is the code that I have written so far. Any help would be appreciated. Thanks!
#!/bin/bash cat /var/log/dmesg l nl >> /home/administrator/Desktop/dmesg cat /var/log/syslog l nl >> /home/administrator/Desktop/syslog cat /var/log/message l nl >> /home/administrator/Desktop/message echo ' ' > /var/log/dmesg echo ' ' > /var/log/syslog echo ' ' > /var/log/message date >> /home/administrator/Desktop/execution.txt