Live data from Hacker News

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

reddit.com

141–150 of 216 posts

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

#141
post #104
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 -

> screen Unless you only use GPL software, there's no reason to not use tmux these days. Well, maybe if you're on HP-UX or something. http://tmux.sourceforge.net/

Is tmux as available as screen?

I often have to fix servers that are not from own group, so all my knowledge is honed around tools that i can find anywhere.

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

#142
post #137
post #104

Earlier quoted context omitted.

> screen Unless you only use GPL software, there's no reason to not use tmux these days. Well, maybe if you're on HP-UX or something. http://tmux.sourceforge.net/

I've switched from screen to tmux about a year or two ago, after decades of using screen.. and I'm perfectly happy with tmux, as it fits my needs. However, it's not true that screen has no advantages over tmux. Each program has its own strengths and weaknesses. For instance, screen is scriptable via its Lua bindings, tmux is not. Screen has zmodem support built in, tmux does not. There are probably many other example…

tmux is scriptable from the shell via its command-line arguments, so any language can script it.

It's certainly true that screen does have tons of small old features... but I sort of swept that in with "unless you're using HP-UX or something." zmodem support isn't exactly relevant to the overwhelming majority of programmers, but yes, I admit these things are still relevant to a few niches.

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

#143
post #141
post #104

Earlier quoted context omitted.

> screen Unless you only use GPL software, there's no reason to not use tmux these days. Well, maybe if you're on HP-UX or something. http://tmux.sourceforge.net/

Is tmux as available as screen? I often have to fix servers that are not from own group, so all my knowledge is honed around tools that i can find anywhere.

Perhaps not, but tmux's bindings are nearly all backwards-compatible with screen's. Well, the default escape char is ctrl-B but I (and I think most folks) just remap it to ctrl-A immediately.

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

#144
post #65
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.

How would you make the bash manpage short and to the point, considering the complexity that it implements?

I wish there was an easy way to get info about builtin commands. So things like man bash-disown would work (similar to git).

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

#145
post #4

For me it was definitely find. I went through a ton of contortions to replicate its behavior several times before somebody knowledgeable clued me in. Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is: cat `find . --name *.java` | wc -l

zsh's extended globbing support makes the use of find unnecessary in most cases. See the "extended globbing" section of the link below[1] for some examples.

zsh also has the 'zargs' command, which works something like xargs, except that it gets its arguments from the command line (often in conjunction with extended globbing) rather than from stdin.

You might also be interested in reading about the "useless uses of cat"[2]

[1] - http://linuxgazette.net/184/silva.html

[2] - http://partmaps.org/era/unix/award.html

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

#146
post #142
post #137

Earlier quoted context omitted.

I've switched from screen to tmux about a year or two ago, after decades of using screen.. and I'm perfectly happy with tmux, as it fits my needs. However, it's not true that screen has no advantages over tmux. Each program has its own strengths and weaknesses. For instance, screen is scriptable via its Lua bindings, tmux is not. Screen has zmodem support built in, tmux does not. There are probably many other example…

tmux is scriptable from the shell via its command-line arguments, so any language can script it. It's certainly true that screen does have tons of small old features... but I sort of swept that in with "unless you're using HP-UX or something." zmodem support isn't exactly relevant to the overwhelming majority of programmers, but yes, I admit these things are still relevant to a few niches.

"tmux is scriptable from the shell via its command-line arguments, so any language can script it."

I'm not sure if tmux is scriptable to the same extent that screen is via screen's Lua bindings, as the latter probably exposes many of screen's internals, while scriptability of tmux is limited to what you could do with its command line arguments. I haven't researched the matter, though, so I may well be wrong.

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

#147
post #114
post #98

For me, it was using 'cd' without argument. (It takes you back to your ~). Also, learning the various options of grep (-v, -i, -A, -B) made its use really more powerful.

A useful one I somehow missed early on is cd - to change back to whichever directory you were just in. Every once in a while most of us find ourselves facing someone's "how could you not know that?" look.

Also along these lines are the directory stack manipulation commands: "pushd", "popd", and "dirs" -- along with some related environment variables.

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

#148
post #123

The "^[." (esc-.) keybinding. In zsh it maps to insert-last-word which allows you to do this: echo hi > /tmp/blah.txt ls -l There's a bunch of complementary commands to go with it too.

Is this only in zsh? I've been recommending this and not marking it explicitly as a zsh thing. alt-. works too. In the shell ESC is the same as alt- . The difference being that with alt- you hold alt and press , then release them both. with ESC you press escape, release, and then press and release .

It's bash too.

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

#149
post #65

Earlier quoted context omitted.

How would you make the bash manpage short and to the point, considering the complexity that it implements?

I wish there was an easy way to get info about builtin commands. So things like man bash-disown would work (similar to git).

The 'help' command is exactly what you're looking for -- e.g., 'help disown' will describe the 'disown' command. Definitely beats searching the entire bash man page for the command you want (which is what I did for far too long, until I found out about 'help').

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

#150
post #135
post #130

Earlier quoted context omitted.

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

There's also 'tmux': http://tmux.sourceforge.net/

Which according to reports has the benefit of being maintainable.

GNU screen, which I love and use to obscene extents daily, has an exceptionally hairy codebase. That said, I've got to get my tmux on and learn how to do screen equivalents with it....

http://www.techrepublic.com/blog/opensource/is-tmux-the-gnu-...

Post reply on HN