Learn some unix Mac user!

A short hands-on introduction to the concept of unix for the Mac user.

Hey, Mac user. Did you know that there is a foundation of Unix underneath your Mac OSX operating system? Unix? What’s that? Unix was an important part of how computer operating systems came to be what they are. And unix harkens back to the old days of computing, when communication with your computer was by way of a keyboard and text screen. You type commands to your computer and it responds with text on the screen.  Besides its nostalgic appeal and historical interest, there is a great deal of raw computational power in a text based command system that unix made possible, and that is still useful to this day, and thus, the Mac user should take the opportunity learn a little history of some revolutionary principles that unix introduced to the world of computers, while learning to control your computer in a completely different way.

Unix is not any one single operating system or user interface, but a whole family of them, related in an evolutionary hierarchy with ever growing branches. In that sense unix is more of a concept than any one particular software package. The revolutionary and evolutionary aspect of unix is its fundamental reprogrammability. The user is encouraged from the outset to customize their environment by defining environment variables and aliases, writing shell scripts and c programs, to expand on and improve on the basic original unix, and besides the hard-core kernel of unix that does the lowest level tasks, the great majority of the unix interface is an accumulation of scripts and programs that people have written over the years, and are still writing, that expand on and improve on the system. If you don’t like the way a command works, redefine it to make it work the way you want. And that was the beginning of a long evolution of a number of different variations of unix all evolving in parallel, while also borrowing from each other their best features, and that evolution continues to this day.

To open a unix command window on your Mac use Finder to find to your

Applications > Utilities > Terminal.app,

or click the Terminal icon     Screen shot 2014-02-25 at 7.30.49 AM    on your command bar, if it is there. This will open a text window that speaks unix!

First, type “whoami”. This is what happens when I do it. (The $ [dollar] sign below is the original standard unix prompt, although on your Mac the prompt is more likely “slehars-MacBook:~ slehar$” or something similar.)

$ whoami

It answers that I am slehar, the username I chose for myself when I set up my account. Next, type “pwd” which means “print working directory” or print the name of the directory that I am currently working in. Here’s what happens when I type it.

$ pwd

Now lets see what is in this directory, lets get a directory listing, which is done with the command “ls”. Here’s what my directory contained when I wrote this.

$ ls
Applications Library Public bubw2
Desktop Movies Sites cprogs
Documents Music bin sandbox
Downloads Pictures bp tst

These are all files or folders in my directory. We can get a clearer picture of what they are with the “-F” command-line argument to the “ls” command, by typing “ls -F” which yields

$ ls -F
Applications/ Library/ Public/ bubw2/
Desktop/ Movies/ Sites/ cprogs/
Documents/ Music/ bin/ sandbox/
Downloads/ Pictures/ bp@ tst*

The names that have a trailing/ slash/ are directories that contain files or other directories, whereas the names without a trailing slash are the names of files. Here’s another variation on the ls command using the “-a” command-line argument to show all files and folders. There is an old unix convention that any filenames that .begin .with .a .dot are “invisible” files, they are not normally listed in a directory listing, but they can be made visible again with the -a flag as shown below

ls -a
. Documents Music
.. Downloads Pictures
.CFUser TextEncoding Library Public
Desktop Movies Sites

Here we see new files like .CFUser. There are also always two special files in every directory, one called . (dot), which means THIS directory, the other called .. (dot dot) which means the parent of this directory. Typing “ls” is equivalent to typing “ls .” which means list THIS directory.

To get the most detailed directory listing use the “-l” long listing command-line flag

$ ls -l
drwxr-xr-x   2 slehar  staff    68 Mar  6 13:49 Applications
drwx------+  4 slehar  staff   136 Mar 28 06:59 Desktop
drwx------+ 16 slehar  staff   544 Mar 28 06:57 Documents
drwx------+ 59 slehar  staff  2006 Mar 31 06:48 Downloads
drwx------+ 38 slehar  staff  1292 Mar 21 19:48 Library
drwx------+  7 slehar  staff   238 Feb  2 14:20 Movies
drwx------+  8 slehar  staff   272 Feb  2 14:22 Music
drwx------+ 16 slehar  staff   544 Mar 22 16:21 Pictures
drwxr-xr-x+  5 slehar  staff   170 Jan  9 19:33 Public
drwxr-xr-x+  5 slehar  staff   170 Jan  9 19:33 Sites
drwxr-xr-x  27 slehar  staff   918 Mar 20 16:03 bin
lrwxr-xr-x   1 slehar  staff    13 Feb 23 20:19 bp -> .bash_profile
drwxr-xr-x  35 slehar  staff  1190 Jan 10 21:28 bubw2
drwxr-xr-x   3 slehar  staff   102 Feb 12 08:06 cprogs
drwxr-xr-x   9 slehar  staff   306 Feb 21 13:37 sandbox
-rwxr-xr-x   1 slehar  staff    72 Feb 18 08:29 tst

This gives you a lot of detailed information about the files.

File Types and Permissions

The first letter on the left indicates whether its a regular file “-” or a directory “d”. (or l for a symbolic link). The next group of letters record the read/write/execute permissions on each file or directory for user/group/other with the code rwx (read, write, execute) for the user, rwx for the group, and rwx for other, in a single string. For example the string rwxrwxrwx means that everyone has permission for everything, whereas with these letters replaced with a minus, e.g. rw-rw-rw- means user group and other all have read/write permission but none can execute, whereas rwxrwx— means user and group have read/write/execute permission, but other has no permissions for anything.

The next colums give the file size in k bytes, the owner, the group, the date and time of modification, and finally the file or directory name, and for symbolic links, the -> file to which they are linked. Thats about all the information the unix operating system stores about the file, besides the data it contains.

The command-line arguments to the ls command exemplify a common feature of many unix commands, a way to modify the command with extra flags like -F or -a to modify the function of the command. The flags can be provided in any order, ls -l -a does the same thing as ls -a -l, and they can even be combined as in  ls -al in any order, ls -la to provide some specific desired behavior, ls -laF.

Another fundamental flexibility inherent in the design of unix was the possibility to change the behavior of the commands to suite your personal preferences. For example if you prefer the format of “ls -F” (which is the format I prefer) then you can redefine the ls command for yourself by defining an alias, like this

$ alias ls=‘ls -F’

This says any time I type “ls” behave as if I had typed “ls -F”. If you want to preserve the original behavior of ls (which is usually a good idea) it is better practice to define your own new command, for example call it “lf” to mean “ls -F” as distinct from “ls”.

Type this command into your terminal:

$ alias lf=‘ls -F’

Note no spaces either side of the=equals=sign. Now type

$ lf

and see what happens. Do you get the  same thing you get when you type “ls -F”?

An alias redefines a command. You can see what aliases you have defined by just typing alias without an argument

$ alias
alias lf=‘ls -F’

Now lets try out the history feature. Hit up-arrow to recall the last command. If you hit Enter it will repeat the last command as if you had typed it in again. If you hit up-arrow more than once, you go back to earlier commands and execute them with Return. And you can edit those previous commands to make new ones.

For example hit up-arrow until you recall this command

$ alias lf=‘ls -F’

then hit left arrow and type “a” to edit the command to

$ alias lf=‘ls -aF’


$ alias lf=‘ls -laF’

You can also type “history” and get a history listing of all your previous commands in this session, in a numbered list, and you can recall any command from the list by typing ! and the list number.

This makes it easy to do quick trial-and-error experiments to find out what works and what doesn’t.

Now before we start exploring our directory structure, let us set up a fancy lf alias that will show the path to the directory in a ====[ header line ]==== over the directory listing. Copy and paste this command (without the $) into your terminal window and hit Return.

$ alias lf='echo =====[ `pwd` ]=====; ls -F'

alias lf='echo =====[ `pwd` ]=====; ls -F'

Try it out. Does it work like this?

$ lf
=====[ /Users/slehar ]=====
Applications/    Documents/    Library/    Music/    Public/
Desktop/    Downloads/    Movies/    Pictures/    Sites/

Type the command “pwd” which means “print working directory” and you should get something like this:

$ pwd

Now type this:

$ echo pwd

The echo command simply echos back what is given to it.

$ echo `pwd`

The `back ticks` (or `back quotes`) have a special meaning, they execute the command between the `back ticks` as if it had been typed to the terminal, and returns the text returned by the command. In this case pwd, when typed in as a command, prints the working directory, “/Users/slehar” which echo then echos.

Now type the command

$ lf -a
=====[ /Users/slehar ]=====
./    .dvdcss/    Documents/
../    .fontconfig/    Downloads/
.CFUserTextEncoding    .jnlp-applet/    Library/
.DS_Store    .serverauth.218    Movies/
.Trash/    .serverauth.363    Music/
.Xauthority    .ssh/    Pictures/
.bash_history    .viminfo    Public/
.cups/    Applications/    Sites/
.cvspass    Desktop/

and we see a lot of “invisible” files and directories whose names start with a .dot they only are visible with the -a (all) flag to ls. Among them are two special directories that appear as


The trailing/ slash/ indicates that they are directories, their real names are just . and .. respectively. “.” means this directory, the present working directory, the one we are in. And the special name “..” means the directory above us, our “parent” directory, in this case it is /User, under which we exist as /User/AGuest.


$ lf ..
=====[ /Users/slehar]=====
AGuest/    Shared/    andy/    gregmillington/    slehar/

The ==[ path in the header line ]== is wrong, this is a listing of its parent directory, /Users, as you can see by typing these commands

$ cd ..
$ lf
=====[ /Users ]=====
AGuest/    Shared/    andy/    gregmillington/    slehar/

which shows the correct path in the header line. We can go one higher with the command

$ cd ..
$ lf
=====[ / ]=====
Applications/    dev/
Developer/    etc@
Library/    home/
Network/    mach_kernel
Nik Software/    net/
System/    private/
User Guides And Information@    sbin/
Users/    tmp@
Volumes/    usr/
bin/    var@

This is the root directory, “/”, the root of the whole tree. Don’t mess with these folders, this is system stuff that you should not monkey with. Lets go back to your home directory.

Type the following commands:

$ echo $HOME

HOME is an “environment variable” whose value is retrieved by prepending a $dollar. You can use echo to check what the value of $HOME is, or you can use it directly in a command to go back to your home directory.

$ cd $HOME

$ lf
=====[ /Users/slehar ]=====
Applications/    Documents/    Library/    Music/    Public/
Desktop/    Downloads/    Movies/    Pictures/    Sites/

And if you’re not back home where you started, you’ve done something wrong. If you get real messed up, just open another terminal window Shell > New Window > Terminal > Basic and start from scratch.

Well thats enough unix for the first lesson, perhaps I might be motivated to add another later.

Posted in Uncategorized | Leave a comment

Experience the Transcendent Moment of Cosmic Consciousness

In his book This Is It: and Other Essays on Zen and Spiritual Experience (1958) Alan Watts discusses the experience of “cosmic consciousness” reported “from all historical times and cultures, of the same unmistakable sensation emerging, as a rule, quite suddenly and unexpectedly and from no clearly understood cause.

To the individual thus enlightened it appears as a vivid and overwhelming certainty that the universe, precisely as it is at this moment, is so completely right as to need no explanation or justification beyond what it simply is. … the mind is so wonder-struck at the self-evident and self-sufficient fitness of things as they are … that they cannot find any word strong enough to express the perfection and beauty of the experience” (p. 11)

I have had that experience of cosmic consciousness on more than one occasion, and indeed, I believe I can intellectualized it so that anyone can have that experience by just adopting the right perspective.

In our normal everyday experience of the world, everything seems pedantic, perfectly normal, nothing going on here. I am now sitting in my armchair at home, on a perfectly normal morning before going off to work to my normal daily job, and besides the writing of this blog, I can report that “nothing happened” this morning, it was just another day.

And yet, there is another totally different perspective that you can adopt any time you choose to. Just ask yourself some basic foundational questions, and you will run right into the wonder of Cosmic Consciousness. What exactly is this “normal” day that is happening here? Well, I am a man, that is, a semi-intelligent ape-man, evolved over millions of years from apes that lived in the trees, who in turn evolved from early mammals who evolved from reptiles who evolved from fish who evolved from slugs and slime  and amoebas that emerged spontaneously from the primal goo. Primal goo? Where did that even come from? Well we live on a planet, a giant ball of red hot magma with a huge iron core floating in empty space, with a very thin crust or veneer of solid rock that is wrinkled and rumpled by the convection currents in the viscous semi-liquid magma. Life is sustained by a GIANT ball of fire, I mean really GIANT, humongous, incredibly vast and huge beyond our capacity to imagine it in all its glory. And that ball of fire is fueled by nuclear reactions going on in its core, that have been going on for about four and a half BILLION years! BILLION, I tell you! I’m sure you know how many zeros it has, but I’ll bet you have NO IDEA how long a billion years really is! And that star formed from the collapse of clouds of gas expelled from other stars, which in turn were formed from the hydrogen gas that resulted from the original Big Bang.  Big Bang? Is that for real? The entire universe appeared spontaneously out of nothing in the middle of nowhere, and now here it is? Are we supposed to believe that? Is that really credible at any level?

And perhaps the most incredible of all the mysteries of the universe is the fact that a semi-intelligent ape-man whose brain is made of living tissue, can have a conscious experience of himself and of a local piece of the universe as if his mind can extend out of his skull and make direct contact with the world around him. Of all possible things that could possibly have happened, I find myself in a universe that exploded into existence spontaneously out of nowhere. What are the odds of that? And of all the stars and planets in all the galaxies of the universe, I happen to exist on the planet where life emerged spontaneously out of nowhere, picked itself up right out of the primal goo and started evolving. And of all the living creatures that have lived or will live on this planet, I happen to be a human, the master species and ruler of this planet,  and living in a time of peace and prosperity as has never been known before. And I was born in the most extraordinary era that has ever happened in the history of the earth, with technology exploding into extraordinary new possibilities, the internet that I saw emerge in my lifetime, uniting the information from all the libraries of the world to a giant super-super-library that we can access immediately from a little device that fits in my pocket!

Not only that, but I also have a job that I go to every day, that pays the bills and lets me enjoy the privilege of sitting in my chair on an ordinary morning of an ordinary day before work, and enjoy a quiet little moment of Cosmic Consciousness right here in my armchair!

The ignorant man marvels at the exceptional; the wise man marvels at the common.
– Jonathan Edwards

 The most incomprehensible thing about the world is that it is comprehensible.

– Albert Einstein

Two men look out through the same bars: One sees the mud, and one the stars.

– Frederick Langbridge

Posted in Uncategorized | 2 Comments

The World In Your Head

Look into a bright light bulb or a camera flash, then look away and examine the after-image. What is it exactly that you are looking at? It is a patch of color due to saturation of the retina by the bright light. But think about it — are you looking at your retina when you view that colored patch? No, because my retina is up there in the back of my eyeball, but this image is out there in space before me, although it jumps to wherever I turn my gaze, as if it were being projected out of my retina into empty space. Is that what is going on? Well, to trace the causal chain of vision, light from the world enters your eye, where it is transduced to an electrochemical signal which is transmitted up the optic nerve to your brain. The colored patch that you see is the effect of the retinal saturation on the image sent from the eye to the brain. But my brain is back here inside my skull, and that image is hanging in space out in front of my eyes!

Consider another peculiarity of vision: Close your eyes and see what happens. The world you saw around you suddenly disappears, as if your eyelids were blocking the view from your eyeballs so all you can see is the inside of the closed lids. Is that what is really happening? Lets think about it: The world around you can be factored into objective and subjective components. There is the world itself that exists independent of my experience of it, and then there is my experience of the world as I see it with eyes open. When I close my eyes, the objective world continues to exist uninterrupted, but my subjective experience of the world has blinked out of existence due to the blockage of my view by my eyelids. So the colored three-dimensional world that blinks out of existence when we lower our lids, whose existence is causally dependent on the state of my eyelids, that is the subjective world of my experience, a view of the world from my perspective. How can three-dimensional colored moving images exist in the seething grey matter of my brain? Or are the images of our experience projected out of our head to appear superimposed on the world around us?

There is a third peculiarity of vision that you can see if you stand in a long hallway. Does the far end of the hallway look smaller than the nearer portions? Do the sides of the hallway seem to converge in the distance? Do the sides of the hallway actually converge into the distance? If not, then why do they appear as if they do?  And when you stand on a long straight road or a railway track, the sides of the road appear to converge to a point on the horizon.

Subjects in a hallway are presented with three cardboard models, and asked which model most resembled their experience of the hallway. Most subjects picked model B.

They were then offered a third model with grid lines overlaid, and they were told that this is a scale model, but that the scale varies with depth into the model. In other words this model embodies the same duality in size perception plainly evident in the hallway itself: Things in the distance appear smaller by perspective, but at the same time they appear undiminished in size!

When offered this alternative, 90% of the subjects chose this model as the best representation of their experience of the hallway.

This experiment reveals that our experience has a variable representational scale, in other words, the spatial scale of our experience gets smaller and smaller into the distance, reaching perceptual infinity at the dome of the sky, where the distant stars appear as if on a spherical surface.

Nowhere in the objective world of external reality is there anything remotely resembling perspective as we observe it in phenomenal experience. The prominant violation of Euclidean geometry in phenomenal perspective is perhaps the clearest evidence for the world of experience as an internal rather than an external entity, for the curvature of perceived space is clearly not a property of the world itself, only of our perceptual representation of it.

The Curvature of Perceived Space

What does it mean for a space to be curved? If it is the space itself which is curved, rather than just the objects within that space, then it is the definition of straightness itself which is curved in that space. In other words if the space were filled with a set of grid-lines marking straight lines with uniform spacing, those lines themselves would be curved rather than straight, as they are in Euclidean space. However the curvature would not be apparent to creatures who live in that curved space, because the curves that are followed by those grid lines are the very definition of straightess in that space. In other words a curved object in that curved space would be defined as perfectly straight, as long as the curvature of the object exactly matched the curvature of the space it was in. If you are having difficulty picturing this paradoxical concept, and suspect that it embodies a contradiction in terms, just look at phenomenal perspective which has exactly that paradoxical property. For phenomenal perspective embodies exactly that same contradiction in terms, with parallel lines meeting at two points while passing to either side of the percipient, and while being perceived to be straight and parallel and equidistant throughout their length. This absurd contradiction is clearly not a property of the physical world, which is measurably Euclidean at least at the familiar scale of our everyday environment. Therefore that curvature must be a property of perceived space, thereby confirming that perceived space is not the same as the external space of which it is an imperfect replica.

In fact, the observed warping of perceived space is exactly the property that allows the finite representational space to encode an infinite external space. This property is achieved by using a variable representational scale, i.e. the ratio of the physical distance in the perceptual representation relative to the distance in external space that it represents. This scale is observed to vary as a function of distance from the center of our perceived world, such that objects close to the body are encoded at a larger representational scale than objects in the distance, and beyond a certain limiting distance the representational scale, at least in the depth dimension, falls to zero, i.e. objects beyond a certain distance lose all perceptual depth. This is seen for example where the sun and moon and distant mountains appear as if cut out of paper and pasted against the dome of the sky.

The world really is all in your head!

Posted in Uncategorized | 2 Comments