View and analyze error logs using Putty as an SSH client
If you need to log in to a Linux server or another device using SSH on Windows, PuTTY is the best tool for the job. Once logged in, you can check error logs on the server using basic Linux commands. If you're more interested in learning how to view logs of your PuTTY sessions for debugging or analysis, that's pretty easy to do as well. Read on to learn how to check error logs in PuTTY.
Checking Log Files in PuTTY
- If you're using PuTTY to check Linux log files, use tail <filename> to view the most recent errors.
- For logs of PuTTY sessions, enable logging in PuTTY in Session > Logging and choose a location.
- The default location is C:\Program Files\PuTTY\putty.log, and you can open the file in Notepad.
Steps
Section 1 of 3:
Checking Linux Logs with PuTTY
-
Connect to the server in PuTTY. When you open PuTTY, you'll see the session tab. Type the hostname or IP address you want to connect to into the field. The default SSH port of 22 is pre-filled, but you can replace it with a different one if needed. Click Open to start the connection.
- If you don't have PuTTY, you can download it from the developer's website .
-
Go to the directory that contains your logs. Linux (and Linux applications) stores error logs in various locations, but luckily, most can be found in /var/log . To get there, type cd /var/log and press Enter . [1] X Research sourceAdvertisement
-
3Type ls -a and press ↵ Enter . This displays a list of all the files in /var/log. From here, you can see the names of the logs to determine which one you need to open.
- Some programs create sub-directories for their logs. For example, Apache stores its log files in /var/log/httpd or /var/log/apache2.
-
Enter the command to see your error logs. The command you'll use will vary depending on the length of the log and how you want to view it. The command varies between servers and operating systems, but the default is similar to: "tail error.log".
- To view the last 10 lines of a log, use tail <filename> . This is helpful if the error is recent and appears at the end of the log.
- If you want to specify the number of lines to show, use tail -n <number> <filename>
.
- For example, use tail /var/log/syslog (or just tail syslog if you're already in /var/log) to view the last 10 lines of the system log in Ubuntu. [2] X Research source }}
- To see the last 5 lines, you'd use tail -n 5 /var/log/messages instead.
- To view the entire log screen-by-screen, starting from the beginning, use less <filename>
. [3]
X
Research source
- For example, if the log you want to view is called error.log, type less error.log and press Enter to view the first page of the file.
- To move to the next page, press the Spacebar .
- To go back a page, press the B key.
- To search, use /search-pattern . For example, /kernel will bring you to the first line that mentions the kernel.
- To exit, press Q .
- To view the entire log file, use cat <filename> . This is not the best way to do things if you have a long log file, as it will display the entire thing in the terminal. But, for short files, it might be a good option.
Advertisement
Section 2 of 3:
Checking PuTTY Session Logs
-
1Enable logging in PuTTY. If you want to be able to view logs of your PuTTY sessions, including connection errors, you will need to enable logging first: [4] X Research source
- Open PuTTY.
- In the Session group that's in the left panel, select Logging .
- Select a logging type:
- If you need to log absolutely everything, select All session output . If you need to submit diagnostics to someone about a problem, this is a safe choice.
- If you need to report a bug or fix a network problem, such as to the manufacturer of an IoT device, PuTTY's help documentation recommends choosing SSH packets . Just be aware that if you log in with a password, the password might appear in the log file.
- If you just want to be able to keep logs of your sessions and read them in a text editor, select Printable output .
-
2Select a location for the log file. The default name of putty.log is OK unless you want to change it. The default PuTTY log location is C:\Program Files\PuTTY, but you can change that as well by clicking the Browse… button and selecting a location.
-
3Open your PuTTY logs in Notepad. Now that PuTTY is saving your session logs, they'll be easy to open in a text editor. Just browse to the location of the log file in File Explorer and double-click putty.log to open the file in Notepad.
- If the log opens in the wrong app, right-click the log file, select Open with , then choose PuTTY.
- You can also open Notepad first, press Ctrl + O , change the "Text documents ( .txt)" drop-down to All files ( . ) , browse to the PuTTY log location, select the putty.log , and click Open .
Advertisement
Community Q&A
Search
-
QuestionMy Raspi3 has a password. Putty shows access denied. Why?SamCommunity AnswerRecheck the username and password you are using to log into Raspberry Pi. Also check that SSH is enabled on your Raspberry Pi.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Video
Tips
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
References
- ↑ https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/deployment_guide/s1-logfiles-locating
- ↑ https://support.hpe.com/hpesc/public/docDisplay?docId=c02947726&docLocale=en_US
- ↑ https://linuxize.com/post/less-command-in-linux/
- ↑ https://tartarus.org/~simon/putty-snapshots/htmldoc/
About This Article
Article Summary
X
1. Open PuTTY.
2. Connect to your server.
3. Navigate the PuTTY window to your logs.
4. Enter the command to see your error logs.
Did this summary help you?
Thanks to all authors for creating a page that has been read 57,750 times.
Advertisement