
Ask HN: Any pro-tips for a Unix n00b? - rottyguy
Started a job developing under unix (aix, solarix, linux).  Any pro tips for a guy with tons of Windows development (c++&#x2F;c#) but not much with unix?  Particularly looking for tips and tricks to make your life easier on an every day basis (eg setting up your environment (we xterm from a windows desktop), editor tricks, etc)
======
gjvc
fetch people's dotfiles from github and experiment with them to help you
stretch everyday tools in ways you probably hadn't thought of. hint
[https://github.com/gjvc/etc/](https://github.com/gjvc/etc/) :-)

------
a3n
Read man pages.

For every command you run, assume there is a man page, and assume there is
quick help, there usually and often are both.

$ man man # The man command has a man page about itself.

$ man -help # The man command has quick help.

A lot of this stuff is 40 years of accumulated and evolving conventions. Quick
ref might not be available for a particular command, or might be found with
-h, -help or --help.

Read the bash man page. Or whichever shell you're using, but if you haven't
set it yourself it's probably bash.

The bash man page is pretty large, so don't read it all at once. Here's table
of contents script that will give you a man page's table of contents. Make
yourself a bin directory at /home/yourlogin/bin, then put it and other little
tools that you write in there. Make them executable, and put that directory on
your path. ("bin" is an old convention for "binary" or compiled programs.
Ironically, most of what you put in there will not be binary. :)

    
    
      $ cat ~/bin/toc
      #! /usr/bin/env bash
      
      if [[ $# == 2 ]]; then
          man -S $2 -P "grep -E '^[^ ]'"  $1
      else
          man -P "grep -E '^[^ ]'" $1
      fi
    
      $ toc time
      TIME(1)                       General Commands Manual                       TIME(1)
      NAME
      SYNOPSIS
      DESCRIPTION
      OPTIONS
      FORMATTING THE OUTPUT
      EXAMPLES
      ACCURACY
      DIAGNOSTICS
      AUTHOR
      SEE ALSO
    
      $ toc time 2
      TIME(2)                      Linux Programmer's Manual                      TIME(2)
      NAME
      SYNOPSIS
      DESCRIPTION
      RETURN VALUE
      ERRORS
      CONFORMING TO
      NOTES
      SEE ALSO
      COLOPHON
      Linux                                2011-09-09                             TIME(2)
    

C functions often have their own man page, as in time(2) above. Run this to
see:

    
    
      $ man -S 2 time # As opposed to $ man time
    

Without a section number, man will show you the default, usually from section
1, general commands, which is often what you want.

    
    
      $ man -k time # Show every man page title that has "time" in the tile or synopsis.
    

Gradually add little convenience scripts to your ~/bin directory, but don't go
wild. A good guide is when you find yourself doing a series of tasks
repeatedly, gather those commands together into a script.

Learn about command history, and command line recall and editing

    
    
      $ history # Shows all your recent commands.
    

You can use emacs style editing or vi style editing. I prefer vi.

[http://www.pixelbeat.org/cmdline.html](http://www.pixelbeat.org/cmdline.html)

[http://bash.cumulonim.biz/BashPitfalls.html](http://bash.cumulonim.biz/BashPitfalls.html)
but don't worry too much about this yet, you have actual work to do instead.
Just tuck it away for later.

[http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html](http://tldp.org/HOWTO/Bash-
Prog-Intro-HOWTO.html) same, later.

Learn about pipes, redirection and command substitution.
[https://duckduckgo.com/?t=lm&q=bash+command+substitution&ia=...](https://duckduckgo.com/?t=lm&q=bash+command+substitution&ia=qa)

Use vim. Or emacs. But vim.

I use the urxvt terminal emulator. In my package repository it's called rxvt-
unicode-256color. It has nice color support and unicode support, and a nice,
very simple tab system.

Use tmux if you can, when/if you need it. My use of urxvt means I almost never
need tmux (at home). I use it all the time at work, for its tab-like behavior.
Most people who use tmux use it for its session management (I think).

Two good books:

Effective Computation in Physics
[http://shop.oreilly.com/product/0636920033424.do](http://shop.oreilly.com/product/0636920033424.do)

It's a decent intro to Python, if you need/want that. But even if you don't
care much about Python, or physics (I don't), it's also a decent introduction
to how to use Unix to get shit done.

Unix Power Tools
[http://shop.oreilly.com/product/9780596003302.do](http://shop.oreilly.com/product/9780596003302.do)

It's a door stop, but you can it it as an ebook (and all O'reilly digital
products are DRM-free). Remember I said an accumulation of 40 years? It's all
in here. I love this book.

