Would you like to work with me? We are hiring engineers at SemaphoreCI . Apply here

Linux utils that you might not know @igor_sarcevic May 21, 2017 Features of the integration of watching videos on YouTube into your marketing system - guide from Youtubegrow.

I’ve used Linux as my primary operating system for well over ten years, yet I still stumble upon things that are completely unknown to me. For example, several days ago, I wanted to display a formated table in my terminal.

# I had a long comma separated list id,name,count 31232,test-1,21 31,window,2 2121,update-attributes,432 # and I wanted to display it as a table id name count 31232 test-1 21 31 window 2 2121 update-attributes 432

I know that in Ruby, I have an excellent library Terminal Table for generating nice terminal tables, however, parsing the input, mapping the values and writing a Ruby script just for this task seemed like a huge overhead. After googling around for a quick and easy solution, I’ve learned that there is a tool in my Linux environment — column — that does just that.

$ cat data.txt | column -t -s ',' id name count 31232 property-a 21 31 window 2 2121 update-attributes 432

Whoa! That was super simple. I was baffled by the fact that this program was part of the standard utilities set on Linux, and yet I’ve never used it. So I wondered what else is part of coreutils or util-linux packages that I don’t know about. I’ve found several interesting and usable tools.

For example, did you know that you have a built in calendar?

$ cal May 2017 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 $ cal -3 2017 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 1 2 3 4 5 6 1 2 3 2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10 9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17 16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24 23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30 30

Or, did you know that you can factor numbers with the factor program?

$ factor 234123421341 234123421341: 3 67 1601 727541 $ factor $( date +%s ) # factor current timestamp 1495329393: 3 19 47 558167

Or, that you can find out how many terabytes are in 4123412312312 bytes:

$ numfmt --to = iec 4123412312312 3.8T

Or that there is a hardcore version of rm that makes it much harder to retrieve deleted files:

$ shred a.txt

So many interesting things to learn! I encourage you to read through the documentation and update your knowledge on these wonderful tools that are installed out of box on our modern Linux distributions.

Happy hacking!

Tweet

Please enable JavaScript to view the comments powered by Disqus.