Live data from Hacker News

Linux utils that you might not know

shiroyasha.io

101–110 of 159 posts

Re: Linux utils that you might not know

#101

Anyone here will probably enjoy checking out commandlinefu: http://commandlinefu.com Especially looking down the list of all time greats: http://www.commandlinefu.com/commands/browse/sort-by-votes

Bringing this on a small tangent, but I've never been comfortable with 'sudo !!' and I can't really articulate why aside from wanting to be as explicit as possible.

, , type sudo and enter is nearly as quick and much more explicit for me.

Re: Linux utils that you might not know

#102
post #76

Earlier quoted context omitted.

Although these tools are great, I'm afraid these are of limited use, as these aren't preinstalled but must be explicitly installed. For personal use these are great. But if you write a shell script to be executed on different machines where you can't install anything, these tools won't be available to you. And if you don't have that requirement, i.e. you can install everything, just install appropriate Perl/Python/Ru…

Why assume python? It's huge compared to bash or perl. Lots of minimal configuration operational systems won't have python. More likely than go/ruby/node though.

If you're on RH derived systems, you're going to have a python 2.6 installed for rpm and yum to work.

This bit us in our ass with centos 6.8 , when another package required python 2.7... If you install 2.7 directly, your system fails with a thousand cuts. A chroot is needed for that, unfortunately.

Re: Linux utils that you might not know

#103
post #68

Just look at anything in the "moreutils" package. Just great stuff. Excerpt: - ifdata: do not parse the output of ifconfig/ip anymore. Just use this tool. - sponge: when you need to overwrite an input file at the end of pipe. sponge will wait for the pipe to end before overwriting, preventing any data loss - vidir: edit a given dir with your EDITOR. Awesome for mass renames/deletes. - ts: add timestamps to a command…

One of my favorite moreutils tools is combine[1]. It allows you to compare the contents of text files with boolean operations. For example, want to know what lines are in file1 but not file2? Use: combine file1 not file2 1. http://manpages.ubuntu.com/manpages/zesty/en/man1/combine.1....

You can use comm from coreutils for that too: `comm -1 file1 file2`

Re: Linux utils that you might not know

#104
post #88

Earlier quoted context omitted.

Why crazy?

A large proportion (if not the majority) of the world starts their calanders on Monday. While the ordering is arbitrary, I always thought of the weekend as a single block of days so it's odd to say that the week ends in the middle of the weekend (rather than at the end of the week end ).

I always saw "weekend" in the same way as "book end", that is, that one is at the beginning of the week (one starting end), and one is at the conclusion of the week (the finishing end). Because our weeks come successively, the end of one is immediately followed by the beginning of the next, hence the "block" called the "weekend".

Re: Linux utils that you might not know

#105
post #76
post #68

Just look at anything in the "moreutils" package. Just great stuff. Excerpt: - ifdata: do not parse the output of ifconfig/ip anymore. Just use this tool. - sponge: when you need to overwrite an input file at the end of pipe. sponge will wait for the pipe to end before overwriting, preventing any data loss - vidir: edit a given dir with your EDITOR. Awesome for mass renames/deletes. - ts: add timestamps to a command…

Although these tools are great, I'm afraid these are of limited use, as these aren't preinstalled but must be explicitly installed. For personal use these are great. But if you write a shell script to be executed on different machines where you can't install anything, these tools won't be available to you. And if you don't have that requirement, i.e. you can install everything, just install appropriate Perl/Python/Ru…

Most of the time, I try not to care. It's packaged everywhere, so either install it or ask the script users to do so.

When you're using Python/Perl/Ruby you'll often have to use pip/cpan/rvm for dependencies, and you're back to square one.

Re: Linux utils that you might not know

#106
post #82

Earlier quoted context omitted.

Is that really a problem anymore? Not being able to install things was common in multi-user thin-client type systems, but these days with containerisation and VMs, if you're allowed to execute a script, you're probably allowed to install new packages No?

Sadly, no. It is often possible to install things locally, i.e. not using apt. The idea that everyone has sudo privs is unrealistic. A version of apt that added a per user subset would be very useful.

There are other ways. fakeroot/fakechroot for a poor man's "container" (I cringe inside when I say that). Cross compilation + copying binaries. Or compiling on target with an appropriate ./configure --prefix.

Re: Linux utils that you might not know

#107
post #85
post #58

"cal -3" is quite useful, I use it all the time. To show the week-of-year use "ncal -w". Add "-S" if you want ncal to start weeks on Sunday (crazy!).

Use `cal -m` if you want a week to start on a Monday. AFAIK Sunday is the (US centric) default.

`cal` does try to use the expected first day of the week based on the locale. It seems to at least use LC_TIME from some quick local testing:

  bratch@serenity ~ $ LC_TIME=en_GB cal | head -n2
        May 2017      
  Mo Tu We Th Fr Sa Su
  
  bratch@serenity ~ $ LC_TIME=en_US cal | head -n2
        May 2017      
  Su Mo Tu We Th Fr Sa

Re: Linux utils that you might not know

#108

Earlier quoted context omitted.

One of my favorite moreutils tools is combine[1]. It allows you to compare the contents of text files with boolean operations. For example, want to know what lines are in file1 but not file2? Use: combine file1 not file2 1. http://manpages.ubuntu.com/manpages/zesty/en/man1/combine.1....

You can use comm from coreutils for that too: `comm -1 file1 file2`

Yep, but you'll have to read the man everytime to figure out if you need -1, -2 or -3, or a combination of those. combine gives you a better interface with boolean operators you know.

Re: Linux utils that you might not know

#109
post #101

Anyone here will probably enjoy checking out commandlinefu: http://commandlinefu.com Especially looking down the list of all time greats: http://www.commandlinefu.com/commands/browse/sort-by-votes

Bringing this on a small tangent, but I've never been comfortable with 'sudo !!' and I can't really articulate why aside from wanting to be as explicit as possible. , , type sudo and enter is nearly as quick and much more explicit for me.

Also instead of for extra touchtype points.

Re: Linux utils that you might not know

#110
I like how this article's title doesn't claim that it's about utils "that you don't know". Yet I was expecting utils that have something to do with the Linux kernel, not generic *nix command-line tools.
Post reply on HN