Live data from Hacker News

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

reddit.com

211–216 of 216 posts

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

#211
post #3

100% agree with CTRL-R. It changed my life. Others that I love: screen, pdsh, perl -pi -e 's/find/replace/g' *.txt redis-cli's new ability to have piped in data be the last argument of a command. vim -o file1.txt file2.txt file3.txt (opening multiple files with vim) Using vim instead of less as a pager: cat file.txt | vim -

C-R was one of a few watershed moments for me. I discovered it over a decade a go as a cow-orker was flying through commands way faster than was humanly possible. "How did you do that?". And so I learned.

It, along with other readline functionality, shell functions, substitutions, expansions, scripts, and the bazillion utilities are what make Linux (and Unix) shell so much more than just "it's like DOS, right?".

Yeah, kind of, in the same way that ... a cross between a Prius, a Mack Truck, an Lamborghini, an F-16 fighter, a helicopter, and a freight train are like a pushcart. It's an interface that helps you manage your computers, the things on them, and the things they're connected to. It's also a hugely efficient and effective way to process information and issue commands and controls in a useful way.

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

#212

Earlier quoted context omitted.

Instead of kill -9 (a nuke), you can often get results with just kill, kill -INT or kill -HUP. (The advantage is that the "weaker" signals allow your runaway program to do some cleanup, but kill -9 doesn't.) There's a nice write-up and a function automating attempts to run increasingly strong signals on this site: http://web.archive.org/web/20080610070315/http://sial.org/ho... (Thank god for the wayback machine. That…

It's still there, just without a domain: http://72.14.189.113/

Thanks for letting me know. It's still probably easier to use the Wayback Machine since all of the site's internal links point to http://sial.org/ so browsing within the site is very painful. Still, I'm glad to see the content is all still online. I may just mirror the whole thing (there's tons of good reference material in there, especially for Perl, but also for Unix generally).

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

#213
post #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.

The only solution I've seen is to start up gdb with the process and point the process's 0, 1 & 2 file descriptors to the shell's STDIN, STDOUT and STDERR, then detach the process and quit gdb.

I can't remember the exact details, but that should be enough to set you up for some googling.

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

#214
post #76
post #52

Earlier quoted context omitted.

Many comments seem to be shell- and bash-related. Perhaps the thread exposes how difficult to read the bash manpage is. On my system, the bash 4.1 manpage is 41026 words long, or about 80 pages. Manpages are most useful to me when they are short and to-the-point so I can find what I am looking for before I lose interest in skimming through an 80 page book.

I'm baffled all the time by the lack of clear examples on many manpages.

You could try the OpenBSD man pages. One of OpenBSD's must-haves is good documentation. If I'm looking for an example and the Linux man doesn't have one, I'll often google for "openbsd man xxxx".

Of course, watch out for differences in the utility. OpenBSD (usually) won't have any GNU extensions, for example.

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

#215
post #130
post #45

Earlier quoted context omitted.

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.

Screen is the only real answer, I've ever found.

I'm still a die-hard (and vertical-split-patched) screen user, but it seems tmux is the only suggested alternative. The combination of the more orthogonal dvtm[1] (for window management) and dtach[2] (for screen's killer feature: detaching) is flexible and compelling and sadly doesn't seem to have been mentioned here.

I currently use dvtm to split terminals and connect to multiple screen sessions in a single window. The downside of dvtm is it takes the dwm[3] approach of using #defines rather than configuration files.

1. http://www.brain-dump.org/projects/dvtm/ 2. http://dtach.sourceforge.net/ 3. http://dwm.suckless.org/

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

#216
post #110
post #52

Earlier quoted context omitted.

Many comments seem to be shell- and bash-related. Perhaps the thread exposes how difficult to read the bash manpage is. On my system, the bash 4.1 manpage is 41026 words long, or about 80 pages. Manpages are most useful to me when they are short and to-the-point so I can find what I am looking for before I lose interest in skimming through an 80 page book.

'info bash' is much better than 'man bash', give it a try.

Or, for another alternative, w3mman, which is bundled with the w3m browser. Tabbed manpage browsing in the terminal with URLs converted into links and "foo(1)" converted into a link to the man page for "foo". Don't leave home without it.
Post reply on HN