Commands tagged zgrep (3)

  • This command checks for the number of times when someone has tried to login to your server and failed. If there are a lot, then that user is being targeted on your system and you might want to make sure that user either has remote logins disabled, or has a strong password, or both. If your output has an "invalid" line, it is a summary of all logins from users that don't exist on your system. Show Sample Output


    9
    zgrep "Failed password" /var/log/auth.log* | awk '{print $9}' | sort | uniq -c | sort -nr | less
    dbart · 2009-03-03 13:45:56 14
  • I use zgrep because it also parses non gzip files. With ls -tr, we parse logs in time order. Greping the empty string just concatenates all logs, but you can also grep an IP, an URL...


    2
    zgrep -h "" `ls -tr access.log*`
    dooblem · 2010-06-19 09:44:05 5
  • This will extract all the apt-get install commands issued on the box, even if they are in the gzipped history files. Show Sample Output


    0
    zgrep --color=always 'get install' /var/log/apt/history.log*
    saherr1969 · 2012-04-18 00:06:14 7

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

list block devices
Shows all block devices in a tree with descruptions of what they are.

Blue Matrix
Same as original, but works in bash

check open ports without netstat or lsof

check open ports without netstat or lsof

Grep log between range of minutes
Returns logs between HH:M[Mx-My], for example, between 13:40 and 13:45.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

how to allow a program to listen through the firewall
To allow a program ("programmaautorizzato" in example) to listen through the firewall

urldecoding

list files recursively by size


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: