Live data from Hacker News

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

reddit.com

31–40 of 216 posts

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

#32
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 -

sed -i does the same thing as perl -pi. Though I've not encountered a system that doesn't have both.

sed's regular expressions are different from those perl uses (even when using the (¿gnu sed?) flag that tells sed to use extended regular expressions). Especially if you "live in perl", that can be a problem.

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

#33
post #5

Awk. Actually a full programming language but i usually use it for quick one liners: http://gregable.com/2010/09/why-you-should-know-just-little-...

every developer should know sed and awk. it is amazing how many devs write cumbersome scripts or little programs to handle tasks that are built for sed and awk.

my ~/bin folder has ~50 different little scripts that handle all sorts of small tasks.

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

#34
For me, netcat. I mostly use it for

* Copying files across machines (`cat file| nc -l port` and `nc host port`)

* Remote pasteboard (on OSX w/ pbcopy, `while true; do nc -l port| pbcopy; done`)

Not a life changing, but I wish I know it earlier.

Only if there's a way to make "remote $EDITOR" with Netcat...

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

#35
post #24

That reddit thread is delightful, because it is full of wonderful commands that I didn't know, or rarely use, or had forgotten. But it's also terrifying, because it exposes how many people will post questions before using man.

If that is surprising to you, then much of human behaviour must utterly baffle you.

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

#36
post #33
post #5

Awk. Actually a full programming language but i usually use it for quick one liners: http://gregable.com/2010/09/why-you-should-know-just-little-...

every developer should know sed and awk. it is amazing how many devs write cumbersome scripts or little programs to handle tasks that are built for sed and awk. my ~/bin folder has ~50 different little scripts that handle all sorts of small tasks.

I don't really know a lot about this stuff, but my understanding is that Perl was more or less replaced sed and awk.

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

#37
post #25

Earlier quoted context omitted.

"!ssh" to run the most recent ssh command without having to type out the long list of arguments I use and the host name.

It helps to put your most frequent entries in ~/.ssh/config Host somewhere HostName somewhere.example.com User username IdentityFile ~/.ssh/somewhere_key.pub

yes and do you know about proxycommand ?

let you set up hops when you don't have direct access to a server.

e.g. if you don't have direct access to serverB but have direct access to a serverA that has direct access to serverB

put this in your ~/.ssh/config file

  host serverA
  hostname serverA.domainname.com

  host serverB
  hostname serverB.domainname.com
  ProxyCommand ssh serverA "nc %h %p"
then typing ssh serverB will log you on serverB

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

#38
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 from SIGHUP when you quit your ssh session. Bash (and, to be fair, zsh and others have copied much of this) has some wonderful job control features most people are completely oblivious of - even veterans of 20 years.

Post reply on HN