How do I get information from the logs on my computer when I only have access to the command line?

Seth

For various reasons I can no longer access my graphical desktop, and can only login via a tty (Ctrl+Alt+F1 through F6 by default).

To help diagnose and solve my problem I need to look through the logs and maybe put some of the info into my question or forum thread.

How can I get this information?

Seth

First here is a list of some of the common log files and what they contain:

  • /var/log/messages : General message and system related stuff
  • /var/log/auth.log : Authenication logs.
  • /var/log/kern.log : Kernel logs.
  • /var/log/cron.log : Cron daemon logs.
  • /var/log/Xorg.0.log : Log for the X server.
  • ~/.xsession-errors : Logs related to the last X session (and the one before that, in xsession-errors.old)

After you've logged into the tty it's a good idea to move to the folder where the logs are located (usually /var/log). For this we use the cd command:

cd /var/log  

Now that we're in the folder where the logs are stored we use the ls command to see what logs exist:

ls -a

There will probably be quite a few, these instructions should apply to all of them.

Once you find a log you want to view, you can use the less command:

less kern.log  

Use the up/down arrow keys to browse through the file. When you're done, press Q to quit less. If you want to search the logs for a certain keyword you can use grep:

sudo grep "apparmor" kern.log 

Grep also accepts regular expressions. See man grep for more information.

If you just need the output of a certain command see this question about saving terminal output to a file which you can then give to someone assisting you following one of the methods below.


This is all shiny and great you might say, but I don't have a single clue what I'm looking for, and I just need to give the log file to someone else to help me. We can do that too!

If you are getting help from someone on the internet (like this site!) the best way to share this information with them is to upload the file(s) to http://paste.ubuntu.com and provide them with the link. If your machine has an active internet connection you can do this in one step as described in method 2, otherwise follow the steps in method 1 and upload the files from another computer that can access the internet.

Method 1: Put them on external media..

such as a flash drive or SD card. Plug one in. Ubuntu should automatically mount it in /media so run

ls /media  

If you see the name of your flash drive/SD card there then you can continue. Otherwise you'll have to mount it manually. (don't worry! It isn't scary at all).

Once you have your drive mounted you can use the cp command to copy over any logs or files you need:

cp /var/log/kern.log /media/myFlashDrive/

When you're done unmount the drive:

sudo umount /media/myFlashDrive  

Method 2: Upload the files directly to a pastebin..

like paste.ubuntu.com. For this use the pastebinit command. First we need to install pastebinit:

sudo apt-get install pastebinit  

then upload the files like so:

pastebinit file1 file2 file3  

Where file1 file2 file3 is a space delimited list of the files you would like to upload. For example, if I was uploading kern.log and Xorg.0.log I would use the command:

pastebinit /var/log/kern.log /var/log/Xorg.0.log  

Pastebinit will return a link for each file uploaded. Share these links with the people helping you.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I get information from a UITableViewCell?

분류에서Dev

How can I get my public IP address from the command line, if I am behind a router?

분류에서Dev

How do I get python to fetch information from command prompt such as 'tasklist'

분류에서Dev

How do I get detailed logs from the Roku?

분류에서Dev

How do I run Logstalgia if root login is disabled and ssh user doesn't have access to logs?

분류에서Dev

How do I get a list of running applications by using the command line?

분류에서Dev

How do I get debug information from rsyslog?

분류에서Dev

How do I create a blank PDF from the command line?

분류에서Dev

How do I install the latest version of cmake from the command line?

분류에서Dev

How do I start tty from the command-line?

분류에서Dev

How do I run a gui app from the command line?

분류에서Dev

How do I only allow access to my MySQL database from my iOS app? (Using webapp as gateway to db)

분류에서Dev

How do I get access permissions right for my backup?

분류에서Dev

How to get the hash only from command line?

분류에서Dev

Do I have multiple python on my computer? and how to uninstall one of them?

분류에서Dev

How do I close a stream when my Get Controller is deleted from memory?

분류에서Dev

How do I get PPTP VPN working from my home network when it already works elsewhere?

분류에서Dev

How do I clean dust from a computer?

분류에서Dev

How do I get root access to hard drive from livecd?

분류에서Dev

How do I get only the PID, without any extra information, of a process running on port 3000?

분류에서Dev

How do I recursively compress only certain file extensions with 7zip command line?

분류에서Dev

How do I access a hard drive from a computer where windows is deleted?

분류에서Dev

How do I make files copied over the network from my Windows computer be owned by me?

분류에서Dev

How do I prevent removing a USB drive from waking my computer?

분류에서Dev

How do I fix Unity from freezing and artifacts on my screen when I'm charging my laptop?

분류에서Dev

How can I extend my functionality to also have the cd command?

분류에서Dev

How do I move my encrypted /home to a new computer?

분류에서Dev

How do I find add-ons for packages when using the command line?

분류에서Dev

How do I show apt-get package management history via command line?

Related 관련 기사

  1. 1

    How do I get information from a UITableViewCell?

  2. 2

    How can I get my public IP address from the command line, if I am behind a router?

  3. 3

    How do I get python to fetch information from command prompt such as 'tasklist'

  4. 4

    How do I get detailed logs from the Roku?

  5. 5

    How do I run Logstalgia if root login is disabled and ssh user doesn't have access to logs?

  6. 6

    How do I get a list of running applications by using the command line?

  7. 7

    How do I get debug information from rsyslog?

  8. 8

    How do I create a blank PDF from the command line?

  9. 9

    How do I install the latest version of cmake from the command line?

  10. 10

    How do I start tty from the command-line?

  11. 11

    How do I run a gui app from the command line?

  12. 12

    How do I only allow access to my MySQL database from my iOS app? (Using webapp as gateway to db)

  13. 13

    How do I get access permissions right for my backup?

  14. 14

    How to get the hash only from command line?

  15. 15

    Do I have multiple python on my computer? and how to uninstall one of them?

  16. 16

    How do I close a stream when my Get Controller is deleted from memory?

  17. 17

    How do I get PPTP VPN working from my home network when it already works elsewhere?

  18. 18

    How do I clean dust from a computer?

  19. 19

    How do I get root access to hard drive from livecd?

  20. 20

    How do I get only the PID, without any extra information, of a process running on port 3000?

  21. 21

    How do I recursively compress only certain file extensions with 7zip command line?

  22. 22

    How do I access a hard drive from a computer where windows is deleted?

  23. 23

    How do I make files copied over the network from my Windows computer be owned by me?

  24. 24

    How do I prevent removing a USB drive from waking my computer?

  25. 25

    How do I fix Unity from freezing and artifacts on my screen when I'm charging my laptop?

  26. 26

    How can I extend my functionality to also have the cd command?

  27. 27

    How do I move my encrypted /home to a new computer?

  28. 28

    How do I find add-ons for packages when using the command line?

  29. 29

    How do I show apt-get package management history via command line?

뜨겁다태그

보관