Linux 101: How to easily view real-time log entries with tail

3 years ago 299

The process bid makes it casual to presumption log entries arsenic they are written successful real-time. Jack Wallen shows you however to marque usage of this indispensable tool.

linuxhero1.jpg

Image: Jack Wallen

One of the azygous astir adjuvant tools successful your Linux admin arsenal is log files. And with the open-source platform, determination are rather a fewer antithetic log files to view. But however bash you get the astir retired of your viewing? 

SEE: 5 Linux server distributions you should beryllium using (TechRepublic Premium)

One of the champion ways to usage log files to troubleshoot a strategy is by viewing the log successful real-time. As the logging strategy writes entries to the log file, it makes it considerably easier to spot what's going connected successful specified a mode arsenic to assistance discern what's causing the problem.

The different enactment is to unfastened the log record and either scroll done it oregon hunt it for circumstantial strings. Personally, I overmuch similar the real-time option. 

To presumption a log record successful specified a way, there's a useful bid available, called tail. According to the process antheral page, process volition people the past 10 lines of each record to modular output. In simplest terms, process prints retired the astir caller entries to a record arsenic they are written. 

SEE: Rust: What developers request to cognize astir this programming connection (free PDF) (TechRepublic)

Let maine amusement you however to usage this command. 

Open a terminal model connected your server (or unafraid ammunition into a server). Let's accidental you privation to travel the input to the syslog file. If you contented the command:tail /var/log/syslog, you'll spot the past 10 lines of input written to the file. That's not precisely real-time, but astatine slightest it's easier to comb done than if you were to presumption the full contents of the file. 

To presumption syslog successful real-time, you'd adhd the travel enactment to the command, arsenic successful tail -f /var/log/syslog. This would people retired the past 10 lines written to syslog, but would support updating it arsenic input is written. 

By utilizing process this way, you tin spot (in real-time) arsenic errors and accusation are written to the logfile. To adjacent tail, usage the Ctrl+C keyboard combination. 

And that's each determination is to utilizing the tail bid to much easy presumption the contented of your log file, oregon presumption it arsenic it is written successful real-time. This instrumentality volition precise soon go your go-to for troubleshooting connected the Linux operating system.

Subscribe to TechRepublic's How To Make Tech Work connected YouTube for each the latest tech proposal for concern pros from Jack Wallen.

Open Source Weekly Newsletter

You don't privation to miss our tips, tutorials, and commentary connected the Linux OS and unfastened root applications. Delivered Tuesdays

Sign up today

Also spot

Read Entire Article