Unix Tricks
41–50 of 166 posts
Re: Unix Tricks
#42for cmd in $(compgen -c); do if [[ $cmd =~ ^[0-9a-zA-Z]+$ ]]; then eval "alias $cmd?='man $cmd'"; fi; done
in my .bashrc to alias command?=man command, saves some typing to get to man pages ( which I do very often )
Re: Unix Tricks
#43You might want to try out the more modern fish shell as well: http://fishshell.com/ It makes history searching even easier.
I love fish and have happily been using it for years. Every time it comes up here, though, someone inevitably will complain about compatibility - and I will admit that RVM, for instance, has definitely caused me problems with fish in the past. I guess it depends quite a lot on your particular usage and requirements.
Re: Unix Tricks
#44Earlier quoted context omitted.
The article doesn't say, so it's worth mentioning that you can type ctrl-R multiple times to search further back into command history.
I use C-r constantly. But sometimes I need to find a command, and then edit it before running it. What is the proper way to exit "search mode" and go into the normal "edit" mode?
It's so ingrained I had to actually do it in a shell to know what it was I did.
Re: Unix Tricks
#45One to add: Unfreezing terminal after pressing Ctrl+S by accident. Press Ctrl-Q.
One that I needed to use a lot in the old days, and still occasionally need: If your font is all messed up, echo C-v C-o. C-v puts you into a literal mode, and C-o gets you back into the normal character set. (You probably got there by emitting a C-p at some point.)
Re: Unix Tricks
#46 while sleep 0.1; do nc -w 1 -z host 22; done
Useful when waiting for systems to boot.Re: Unix Tricks
#47 ProxyCommand ssh -T host1 'nc %h %p'
one should use this instead: ProxyCommand ssh -W %h:%p host1Re: Unix Tricks
#48 ssh -R 12345:localhost:22 server.com "sleep 1000; exit"
use ssh -R 12345:localhost:22 -n server.com
The -n flag tells ssh to only make a connection, without ever running a shell. This means it even works when you don't have shell access (say, with a command= entry in .authorized_keys).Also, I cannot recommend envoy enough in lieu of ssh-agent, if you're not using a GUI ssh agent already (e.g OSX keychain or GNOME keyring)
Last, I guarantee you don't want "$@" in those aliases, but either "$*" or $@ (certainly the latter).
Re: Unix Tricks
#49Earlier quoted context omitted.
The article doesn't say, so it's worth mentioning that you can type ctrl-R multiple times to search further back into command history.
I use C-r constantly. But sometimes I need to find a command, and then edit it before running it. What is the proper way to exit "search mode" and go into the normal "edit" mode?
Re: Unix Tricks
#50man hier is pretty cool. It explains the root directory structure of the system.
Nice to see something I've gradually learned about by gut feel summarized. Why do some distributions use /opt a lot while others don't seem to use it at all?
https://en.wikipedia.org/wiki/Unix_filesystem
"Contains locally installed software. Originated in System V, which has a package manager that installs software to this directory (one subdirectory per package)."
Solaris made extensive use of /opt, that flowed into some Linux packagers. It then fell out of favor as everyone put everything in /usr