Commands by nanoscript (2)

  • 1st log (samba) has filters to omit annoying repetetive connections and messages about cups printer sharing, and ONLY show messages pertaining to connections to a samba service. Also requires Samba be configured to use a single logfile. use the path to your single samba logfile. 2nd log (for SSH) point to your /var/log/auth.log file. change path as needed. cron is filtered out to avoid looking at processes spawned by cron. which just eats up the screen unnecessarily. 3rd log (FTP), point at the logfile for your ftp daemon. assuming it uses a single file and does so neatly. multitail has lots of options. season to your tastes. this is a highly dumbed down version of the one liner I actually use for this, which incorporates several more logs, color options, window size options etc. depending how much garbage is generated by certain logs and what strings you ignore, when spawning this you may not see any previous log lines. this can be fixed using options like "-n [number]" to search back far enough to produce some lines. otherwise don't worry, it will display newly logged lines. --follow-all is used to follow filenames instead of descriptors. an important thing when following logfiles that rotate as most do.


    0
    multitail -D --follow-all -ev "cups" -ev "CUPS" -ev "AbusiveVMnameHere" -e "connect" -i /var/log/samba/yourUnifiedSambaLog -ev "cron" -i /var/log/auth.log -i /var/log/YourFTPlog
    nanoscript · 2015-01-18 05:03:18 8
  • The only requirement to make this work is some research on what your local NOAA "zone" is. One place to take a look is: http://www.nws.noaa.gov/mirs/public/prods/maps/pfzones_list.htm Show Sample Output


    0
    wget -q -O - http://weather.noaa.gov/pub/data/observations/state_roundup/ny/nyz003.txt http://weather.noaa.gov/pub/data/forecasts/zone/ny/nyz003.txt | less
    nanoscript · 2015-01-17 05:09:05 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

Search gpg keys from commandline

Select and Edit a File in the Current Directory
This command displays a simple menu of file names in the current directory. After the user made a choice, the command invokes the default editor to edit that file. * Without the break statement, the select command will loop forever * Setting the PS3 prompt is optional * If the user types an invalid choice (such as the letter q), then the variable $f will become an empty string. * For more information, look up the bash's select command

back up your commandlinefu contributed commands
Use `zless` to read the content of your *rss.gz file: $ zless commandlinefu-contribs-backup-2009-08-10-07.40.39.rss.gz

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Let's make screen and ssh-agent friends
When you start screen as `ssh-agent screen`, agent will die after detatch. If you don't want to take care about files when stored agent's pid/socket/etc, you have to use this command.

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"

Find the package that installed a command

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Grabs a random image from "~/wallpapers" and sets as the background
don't bother spawning a bc process or counting the number of options, just pick a random one. 'sort -R' sorts randomly, so pick the top one.

Convert filenames from ISO-8859-1 to UTF-8
Nothing advanced, it just finds filenames that are stored with ISO-8859-1 characters and and converts those into UTF-8. Recommended to use without the --notest flag first so you can see what will be changed.


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: