PDF download Download Article
View and analyze error logs using Putty as an SSH client
PDF download Download Article

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.
Section 1 of 3:

Checking Linux Logs with PuTTY

PDF download Download Article
  1. 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.
  2. 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]
    Advertisement
  3. 3
    Type 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.
  4. 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] }}
      • 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]
      • 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.
  5. Advertisement
Section 2 of 3:

Checking PuTTY Session Logs

PDF download Download Article
  1. 1
    Enable 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]
    • 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 .
  2. 2
    Select 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.
  3. 3
    Open 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 .
  4. Advertisement
Section 3 of 3:

FAQ

PDF download Download Article
  1. 1
    How do I view logs in Linux? The most common location for logs is /var/logs. Type cd /var/logs to enter the directory, then type ls -a to see which logs are in the directory. To view a log, type more <log file name> , then use the spacebar to page through each screen.
  2. 2
    How do I check files in PuTTY? To see which files are in a directory, type ls -a . Or, use ls -al to see all files and subdirectories, as well as their permissions. To view the contents of a text file, type cat <filename> , or use more <filename> to browse the file screen by screen.
  3. 3
    How do I search logs in the Linux terminal? Use the "grep" command to search for text in any file, including log files. For example, grep -l "error" *.* will search for the word "error" in all files within the current directory. You can also use cat <logfilename> to find text within a specific log file.
  4. Advertisement

Community Q&A

Search
Add New Question
  • Question
    My Raspi3 has a password. Putty shows access denied. Why?
    Sam
    Community Answer
    Recheck 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
      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!

      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.

      Is this article up to date?

      Advertisement