Convenient Utilities Linux. Show broken links, users file count&size, big file list, etc

You know what annoys me sometimes? That I can’t see quickly a list of existing users on linux. Don’t get me wrong. I love me a bit of finger gymnastics and awk every once in a while. But to have to type all those chars EVERY time…that’s annoying.

cat /etc/passwd | awk -F: '{print $1}'
cut -d: -f1 /etc/passwd

Each one of the lines above will do the trick. It’s not much typing but why not a more convenient command?

That’s why I started writing a list of convenient linux utilities. For the convenience lovers.

Some of the utilities are rather simple in execution but convenient to use. Other are a bit more complex – filenames with spaces, I’m looking at you! From now on I swear, NEVER I’ll put spaces in my filenames again. 😛

In principle one could even use one liners AND deal with filenames that have spaces. BUT there’s a small nasty side effect – if there are no results for find (or the command that sends output to xargs) the command executed by xargs will usually show help output. Couldn’t figure out how to skip it in the one liner easily. In a script it’s doable.

Oh, and some scripts are a bit slow. That’s a side effect of calling xargs -n1 mycommand with thousands of input lines. Sometimes it can’t be helped if you desire certain results.

For example to show the biggest files fast you use find with -printf option. But It displays the size in bytes, not human readable. Right now I used this implementation. Parsing the left side raw bytes into human readable output it’s on the to do list.

On the other hand using du -h and xargs will display nicely formatted size – at the expense of speed.

Right now there’s just 7 utilities but I’ll keep adding to the list. I’m already using them on a daily basis – and not just because I wrote them.

Here’s what they do:

showbf

  • show big files. First 10 by default, current user, current dir.
  • Use it with different user, different dir.
  • Works well with files that have spaces or other “funky” chars.

showus

  • Show a user disk usage and file count in a dir. Calculates by adding file sizes owned by user.

showbl

  • show broken links. Use custom dir or custom user.

showg

  • Show groups, every group on one line.
  • It’s a simple one liner (in the script) but quite convenient to use in this form.

showp

  • Show paths added to $PATH, each on one line

showu

  • Show users, each on a separate line.

wtw

  • What’s the word? A simple one liner (in script) to show possible words for regex.

Get them while they’re hot HERE (github)