Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am ssh'd into a server and want to traverse through long log (5000 lines).

what is the best command to do this?

I tried tail -2000 server.log

but then I have to scroll up my SSH window....which only goes up a little.

I cant install anything new on the server..

share|improve this question

4 Answers 4

Try less server.log or zless server.log.1.gz for the compressed logs.

share|improve this answer

I'm partial to:

tail -2000 server.log | more

Or if I know specifically what I'm looking for:

grep -i somesearchstring [| more]

Or if I just want to watch the log go by:

tail -f server.log

because, well, you know, logs are fun to just watch go by.

share|improve this answer
1  
Piping a command's output into more or less ( | more ) has to be one of the most important *nix command line features to know. As squillman pointed out you can go from tail or grep, you can also go from ls, cat and any other command that normally sends its output to the console if you need the ability to scroll through the output. –  ManiacZX Jan 22 '10 at 18:23
    
Yeah piping is a core concept that every *nix admin should know. I was going to mention it in my answer but I got pulled away from my desk so I just posted what I had already written. I tend to use less rather than more though. Less is the new more. –  3dinfluence Jan 22 '10 at 20:28

Nothing wrong with using tail, but you need to add | more on the end.

For example:

tail -2000 /var/log/messages | more 

That'll make it so you have to hit return to move to the next screen. Less and More are well and good, but who wants to page down through a 200,000 line file?

share|improve this answer

Other pagers include more, most and pg.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.