Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Linux server with 512MB RAM and no SWAP. How can I view 1GB file?

share|improve this question

migrated from Sep 24 '10 at 8:55

This question came from our site for professional and enthusiast programmers.

What do you actually want to view here? You have all kinds of options. more, less, tail, grep, cat, ee, vi – Ben Quick Sep 24 '10 at 9:54
up vote 1 down vote accepted

You can use split.

Another useful tool in addition to head and tail is split.

Chop that 1GB file into a bunch of smaller files.

share|improve this answer

I think "less" or "more" will work just fine here. Or you can use below Perl script to do this, just change the log file name:

open LOGFILE, "<log_file" or die "log_file: $!";
my $i=0;
while(<LOGFILE>) {
 if($i>=25) {
  print "Press Enter to see more...";
 else {
close LOG_FILE;
share|improve this answer

Emacs, vim can do it if you need to modify the file. Otherwise, "less" can do it.

Most "good" editors won't load the full file in memory.

share|improve this answer
vi: memory exhausted – d_pilot Sep 24 '10 at 9:16

Personally, I'd take the process that created the log, stop it, rename the log, touch the old filename to create a new log, then restart the process.

Move the log file to another machine so I can analyze it, store it, whatever needs to be done.

On that machine, I'd use the Linux Split command to break the file into smaller, more manageable chunks.

Get the information I need from it, then delete it when done.

Your server might thank you for more space. You might want to look at configuring logrotate for that logfile on the server itself to help with space management. Chances are pretty good you already have it on the server.

Make sure you don't play with the logfile while the parent process is still running or you may get some goofy side effects.

share|improve this answer

Download the log file to another computer that has more RAM.

You wouldn't want huge logs on a production server anyway.

Look into logrotate if it is not configured yet.

share|improve this answer

This Linux without perl. Download log file to another PC is not solution. I resolve this problem by "head" and "tail".

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.