×

Qué logs puedo revisar en Linux

Qué logs puedo revisar en Linux

LogsRevision Qué logs puedo revisar en Linux
En el Universo Extendido de Linux (UEL) sabemos que existen muchas distribuciones, algunas más usadas y populares que otras; sin embargo debemos de tomar en cuenta que las distros de Linux se basan en una estructura estandarizada que deben de contener cada uno de ellos.

A continuación, vamos a mencionar la estructura de directorios que los Linux deben de tener:

Estáticos. Son todos aquellos directorios que sus archivos no son modificados, en ellos encontraremos directorios como de comandos, instalaciones, etc.

Dinámicos. Son todos aquellos directorios que constantemente cambian sus archivos (modificados), como ejemplo logs de sistemas, de aplicaciones, etc.

Y la pregunta del millón: ¿Qué directorios están dentro de cada categoría? veamos el siguiente diagrama donde clasificamos los directorios:

jerarquia-archivos Qué logs puedo revisar en Linux

Una vez que ya tenemos el panorama de los directorios que están en Linux, podemos ya continuar con el objetivo de este post que es saber donde revisar y qué logs.
Debemos entender que existen logs de sistema y logs de aplicaciones; por lo cual veremos los logs de sistema. La mayoría de los logs los vamos a encontrar en /var/log, en el cual coloco la siguiente descripción en cada uno de los logs:

Normal
0

21

false
false
false

ES-MX
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:8.0pt;
mso-para-margin-left:0cm;
line-height:107%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

/var/log/messages (f): Este log registra todos los enviados
por el Sistema Operativo (ssh, procesos, ftp, kernel, etc.)
/var/log/maillog (f): Este log guarda la información de mail
que tengamos configurado en nuestro servidor.
/var/log/boot.log (f): En este log se guarda la información
de boot del servidor, cada que nuestro servidor se reinicia y los distintos
demonios se levantan, ahí podemos consultar lo que se haya levantado.
/var/log/btmp (f) y /var/log/wtmp (f): En ellos se guarda la
información de logueos y deslogueos de nuestro Sistema Operativo.
/var/log/yum.log (f): Log de la herramienta yum, en el cual
registra errores, actualizaciones e instalaciones que se realicen con el
comando yum.
/var/log/cron (f): Se visualiza los crons ejecutados, la
hora, al usuario que pertenece y puede visualizar también si lo puesto en el
cron si lanza shells, etc.
/var/log/audit (d): Este directorio guarda los logs de
audit, en el caso que lo tengamos configurado en nuestro servidor, el archivo a
revisar es audit.log
También podemos revisar información tipo log en nuestro Linux pero referente más a buffer, con el comando dmesg. A continuación pongo la información sobre dmesg:

NAME         top

       dmesg - print or control the kernel ring buffer

SYNOPSIS         top

       dmesg [options]

       dmesg --clear
       dmesg --read-clear [options]
       dmesg --console-level level
       dmesg --console-on
       dmesg --console-off

DESCRIPTION         top

       dmesg is used to examine or control the kernel ring buffer.

       The default action is to display all messages from the kernel ring
       buffer.

¿Qué comandos puedo usar para revisar los logs?

Es una buena pregunta, muy interesante, muy sabia… y entonces ¿Qué comandos? no desesperemos, vamos a poner la lista de comandos con los que podemos manipular la información en logs:

  1. cat
  2. more
  3. tail
  4. head
  5. split
  6. grep
  7. wc
  8. sort
  9. uniq
  10. less

Por si algunos desconocen lo que hace cada comando, coloco su información:

CAT(1)                          User Commands                         CAT(1)

NAME         top

       cat - concatenate files and print on the standard output

SYNOPSIS         top

       cat [OPTION]... [FILE]...

DESCRIPTION         top

       Concatenate FILE(s) to standard output.

       With no FILE, or when FILE is -, read standard input.

MORE(1)                         User Commands                        MORE(1)

NAME         top

       more - file perusal filter for crt viewing

SYNOPSIS         top

       more [options] file...

DESCRIPTION         top

       more is a filter for paging through text one screenful at a time.
       This version is especially primitive.  Users should realize that
       less(1) provides more(1) emulation plus extensive enhancements.

TAIL(1)                         User Commands                        TAIL(1)

NAME         top

       tail - output the last part of files

SYNOPSIS         top

       tail [OPTION]... [FILE]...

DESCRIPTION         top

       Print the last 10 lines of each FILE to standard output.  With more
       than one FILE, precede each with a header giving the file name.

       With no FILE, or when FILE is -, read standard input.

       Mandatory arguments to long options are mandatory for short options
       too.

HEAD(1)                         User Commands                        HEAD(1)

NAME         top

       head - output the first part of files

SYNOPSIS         top

       head [OPTION]... [FILE]...

DESCRIPTION         top

       Print the first 10 lines of each FILE to standard output.  With more
       than one FILE, precede each with a header giving the file name.

       With no FILE, or when FILE is -, read standard input.

       Mandatory arguments to long options are mandatory for short options
       too.

SPLIT(1)                        User Commands                       SPLIT(1)

NAME         top

       split - split a file into pieces

SYNOPSIS         top

       split [OPTION]... [FILE [PREFIX]]

DESCRIPTION         top

       Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is
       1000 lines, and default PREFIX is 'x'.

       With no FILE, or when FILE is -, read standard input.

       Mandatory arguments to long options are mandatory for short options
       too.

GREP(1)                    General Commands Manual                   GREP(1)

NAME         top

       grep, egrep, fgrep - print lines matching a pattern

SYNOPSIS         top

       grep [OPTIONS] PATTERN [FILE...]
       grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

DESCRIPTION         top

       grep searches the named input FILEs for lines containing a match to
       the given PATTERN.  If no files are specified, or if the file “-” is
       given, grep searches standard input.  By default, grep prints the
       matching lines.

       In addition, the variant programs egrep and fgrep are the same as
       grep -E and grep -F, respectively.  These variants are deprecated,
       but are provided for backward compatibility.

WC(1)                           User Commands                          WC(1)

NAME         top

       wc - print newline, word, and byte counts for each file

SYNOPSIS         top

       wc [OPTION]... [FILE]...
       wc [OPTION]... --files0-from=F

DESCRIPTION         top

       Print newline, word, and byte counts for each FILE, and a total line
       if more than one FILE is specified.  A word is a non-zero-length
       sequence of characters delimited by white space.

       With no FILE, or when FILE is -, read standard input.

       The options below may be used to select which counts are printed,
       always in the following order: newline, word, character, byte,
       maximum line length.

SORT(1)                         User Commands                        SORT(1)

NAME         top

       sort - sort lines of text files

SYNOPSIS         top

       sort [OPTION]... [FILE]...
       sort [OPTION]... --files0-from=F

DESCRIPTION         top

       Write sorted concatenation of all FILE(s) to standard output.

       With no FILE, or when FILE is -, read standard input.

UNIQ(1)                         User Commands                        UNIQ(1)

NAME         top

       uniq - report or omit repeated lines

SYNOPSIS         top

       uniq [OPTION]... [INPUT [OUTPUT]]

DESCRIPTION         top

       Filter adjacent matching lines from INPUT (or standard input),
       writing to OUTPUT (or standard output).

       With no options, matching lines are merged to the first occurrence.

 

LESS(1)                    General Commands Manual                   LESS(1)

NAME         top

       less - opposite of more

SYNOPSIS         top

       less -?
       less --help
       less -V
       less --version
       less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
            [-b space] [-h lines] [-j line] [-k keyfile]
            [-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
            [-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
            [-# shift] [+[+]cmd] [--] [filename]...
       (See the OPTIONS section for alternate option syntax with long option
       names.)

DESCRIPTION         top

       Less is a program similar to more (1), but which allows backward
       movement in the file as well as forward movement.  Also, less does
       not have to read the entire input file before starting, so with large
       input files it starts up faster than text editors like vi (1).  Less
       uses termcap (or terminfo on some systems), so it can run on a
       variety of terminals.  There is even limited support for hardcopy
       terminals.  (On a hardcopy terminal, lines which should be printed at
       the top of the screen are prefixed with a caret.)

       Commands are based on both more and vi.  Commands may be preceded by
       a decimal number, called N in the descriptions below.  The number is
       used by some commands, as indicated.
Espero que la información puesta, nos permite una revisión mejor de nuestro Linux, si tienes dudas puedes dejar tus comentarios en este post. Recuerda que si requieres el servicio de administración de servidores en tu empresa o negocio, puedes contactarnos al correo asesoria@cosvernauta.com

Bytes.

Publicar comentario