Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to learn work effectively with Unix CLI

Tags:

shell

unix

Do you know any resources that teach to good habits of working in UNIX command line?

EDIT: I don't mean general books about shell or man pages. I mean the things that you can only see watching professionals working with command line. For example when changing frequently between two directories they use "pushd" command, when repeating a command they use "history". I can read about these commands but I want to make it a habit to use them effectively.

like image 223
grigy Avatar asked Nov 22 '08 19:11

grigy


4 Answers

I am speaking out of my own experience so it may not apply to you;

The best way to be efficient is actually using it on a daily basis, instead of using graphical tools even if they make look things easy. You will then become aware of most common tasks you care about, and instead of trying to grok it at once, you get a fairly good starting point to start learning. Man pages are the first thing to look at, but there will be non-obvious tricks which you need to search anyway. Knowing what you exactly want, infinitely increases probability of finding it.

For example, you can find how to search all mp3 files easier in man page of "find" than how to deal with files in general (where to start?).

like image 194
artificialidiot Avatar answered Oct 17 '22 17:10

artificialidiot


Some common bash command line actions, not in order:

  • Command line editing: you'll want to be good with emacs or vi and apply that to editing your commands.
  • Completion: use TAB to expand file names and paths.
    • note: There is a huge set of file, command, and history completion functions, and it is configurable. Big topic.
  • "cd -" : go back to the last directory you were in
  • ~ = home directory (or ~user for users home dir)
  • "ESC ." : expands to the final arg from the previous command
  • "!string" : execute the last command starting with string
  • learn find, grep, sed, piping "|" and redirection ">". You'll often combine these to do useful things.
  • Loops from the shell prompt, e.g. "for" loop - to do repetitive actions
  • Learn your regular expressions! Often used for matching files.
    • example: ls x[0-5]*.{zip,tar} = list files starting with x, followed by a number 0 through 5, followed by any string ending in .zip or .tar

If possible ask others for their favorite tricks, read the manual, and practice.

like image 35
Markc Avatar answered Oct 17 '22 17:10

Markc


For the more advanced stuff This seems to be fairly comprehensive

like image 3
BCS Avatar answered Oct 17 '22 17:10

BCS


this is a great resource: "Rute User's Tutorial and Exposition" (http://rute.2038bug.com/index.html.gz)

like image 3
Ray Tayek Avatar answered Oct 17 '22 17:10

Ray Tayek