Friday, October 11, 2013

Starting x11 and the BASH shell

"Any sufficiently advanced technology is indistinguishable from magic."
 William C. Clarke 
This blog post provides further information about the use of the xll terminal as demonstrated through Cygwin's Xll emulation program running on Windows 7 for SPA Computer club students. The second half of the post provides information generic to BASH shell first use.  These instructions are brief and are designed for 5th - 10th graders first using x11.  The use of a full featured UNIX shell is intimidating to everyone new to that shell. Use reason and patience and take a break if you find yourself confused. The good news is that learning a shell programming language is the gateway to understanding all computer management and development interfaces. You can email me or google chat me if you need help. Come as early to class to as possible next week if you feel stumped.

The setup routine for Cygwin will have you choose the 64 bit version for any reasonably modern version of Windows. After selecting installation types, path, source provider URL, you will choose from the package installer (with a click!) not 'default' but 'install' package option for at least the categories admin, base, devel, net, shells, system, utils, text, xll packages.  You may want to spend some time looking through the other package listings and changing the 'default' install to 'install'.

The Cygwin installation can take some and involves post processing. By default, Cygwin will install itself into C:\Cygwin64 on most Windows systems. At a Windows administrative cmd prompt, cd to C:\Cygwin64 and type 'cygwin'. You will then start the shell by typing 'cygwin'. These contents of the (windows) cmd file cygwin.bat that will activate the bash shell for Cygwin's x11:

  • @echo off
  • C:
  • chdir C:\cygwin\bin
  • bash --login -i

A shell prompt will appear. Type 'startx' or 'startx&'. A Cygwin x11 window should appear:

After this point in the tutorial, all instructions should apply to any x11 terminal on MAC or other UNIX variants. In any x11 terminal, type at least some of these commands to assure a working installation for this course:

  • gcc --help
  • g++ --help
  • vi --help
  • gdb.exe --help
  • objdump
  • ldd --help
  • ld --help
Left clicking on the Cygwin background will present the user with Cygwin options as does holding down CTRL while doing the same. A right click on the xll background will allow the user start another x11 terminal. Holding CTRL while right clicking on any terminal window will allow the user to change font size. If you have never worked with the UNIX shell before you will want to type either or both:
  • man man
  • man info
Important man and BASH shell navigation commands at this point include:
  • 'Page Down' and 'Page UP' scrolls the information as will the space bar.
  •  Pressing 'Enter' scrolls by line. 
  • 'q' will allow the user the quit the screen.
  • 'clear' will clear the screen buffer.
  • CTRL+C will terminate any running cmd.
  • 'exit' will return you from your last shell or kill the instance of your the last shell.
  • ALT-F4 should kill all of x11
"RTFM" is an expression with a long history in UNIX programming. For this course we paraphrase: Please "Read The Fine Man (Pages)". UNIX man pages are intimidating. Chew on them a bit at time. Skim them,then play with the commands  For this course, I would start your BASH shell introduction with either the man or info pages for these commands: bash, gcc, vi. Other important shell commands and programs essential to UNIX navigation, development and programming are:
  • cd
  • pwd
  • ls
  • ps
  • kill
  • pkill
  • cp
  • set
  • export
  • make
You can see the short version of the options for each command by suffixing '--help' after any command. For more information, use 'man commandname' or 'info commandname'. You will probably find the legendary UNIX text editor vi uncomfortable to start. You can save files to your path from any MAC, Windows, or x11 text editor. Typing notepad on Cygwin's x11 works just fine. Much more information on the use of UNIX shells and specifically the bash shell can be found on the web. Some links are below. I recommend and if you wish to purchase books online.

No comments:

Post a Comment