Live data from Hacker News

What's the one Linux command you wish you knew years ago?

reddit.com

41–50 of 216 posts

Re: What's the one Linux command you wish you knew years ago?

#43
post #16

uptime. I had a phone screening itw with Google and it was the answer to one question. I answered sar, which is much more powerful, and top, but caller wasn't tech and I probably missed a checkbox.

I always use "w" instead. It give the same information as uptime plus some more (basically "who"), for much less typing.

Re: What's the one Linux command you wish you knew years ago?

#44
post #8
post #6

Earlier quoted context omitted.

Never thought to use ``. I always used xargs: find . -name *.java | xargs cat | wc -l

Your approach works better than backtick expansion, since it won't run into 'command line too long' issues; but it will still break on "weird" file names (e.g., file names with spaces in them). The correct way to do this is find . -name *.java -print0 | xargs -0 cat | wc -l

BTW, recent versions of linux don't have a fixed limit on command line length.

The command line can be a large as available memory (for a single processes). (Although the ratio between command line length and allocated memory is not obvious since it depends on the number of words in the command line.)

Re: What's the one Linux command you wish you knew years ago?

#45

Actually the new top comment blew me away. I'm in the 20 year veteran category and was also oblivious. Quoted: disown - bash built in. You know how you always start that mega long rsync in an ssh session from your laptop and then realize you have to go offline halfway through? You forgot to start it in screen or nohup, didn't you? You can pause it (ctrl+z), background it (bg), and then disown it so it is protected fr…

disown is great. However, I don't know if it's possible to start up a new shell, then bring back that process to the foreground. 'jobs' will return no entries, and fg doesn't take a PID parameter. Any ideas? It would be brilliant if that were possible with bash alone.

Re: What's the one Linux command you wish you knew years ago?

#47
pv - very useful to put in the middle of a series of piped commands to provide feedback on what, if anything, is happening.

I could've used this many times to catch cases where the amount of work being performed didn't match my expectations; usually an indication of an incorrect assumption or mistake I had made. Instead I sat there waiting for something way longer than I should've, only because I had a bad feedback loop.

Re: What's the one Linux command you wish you knew years ago?

#49

Actually the new top comment blew me away. I'm in the 20 year veteran category and was also oblivious. Quoted: disown - bash built in. You know how you always start that mega long rsync in an ssh session from your laptop and then realize you have to go offline halfway through? You forgot to start it in screen or nohup, didn't you? You can pause it (ctrl+z), background it (bg), and then disown it so it is protected fr…

You will be pleased to know that there is a site full of little gems like this:

http://www.commandlinefu.com/commands/browse/sort-by-votes

Most of my time savers that I've never thought of were found there.

Post reply on HN