Rixstep
 About | ACP | Buy | Industry Watch | Learning Curve | News | Products | Search | Substack
Home » Learning Curve

Learn To Mode

Study your octals. They're very important.


Get It

Try It

It's not widely known who came up with the Unix mode system, whether it was Ken Thompson or Dennis Ritchie. (Probably was Ken.) But no matter, for it's utterly brilliant.

As to why the octal radix was chosen, that's not as much of a mystery, as octal was popular back then.

But again no matter, for the Unix mode notation system is brilliant.

It's so brilliant, in fact, that there's no need to ever 'spell things out'. (For that we have the ACP learning utility TMI - 'Too Much Information').

A programmer, an admin, a power user, and even a regular Unix user knows what '0600' means. It means read and write for the owner and nothing for anyone else.

They likewise know what '0644' means - the inverse of the 'umask', or what's to be subtracted from the mode when saving regular files (022). For '0600' minus '0022' in octal is indeed '0644'.



Anyone with any experience in Unix systems knows this by heart.

The mode system is ingenious. It assigns read/write/execute privileges to owner, group, and 'other', read left to right as the three rightmost digits of the mode, with a value of '4' for read, '2' for write, and '1' for execute.

One of Brian Kernighan's classic tutorials in one of his many classic books deals with this. He shows you how to create a shell script, but then shows you the script won't run until it gets the execute bit set.

% ./test
zsh: permission denied: ./test

Set the bit and all is fine.

% ./test
This script is running.

Unfortunately this is yet another thing that Apple kept out of user reach. Nowhere is it explained, nowhere does the 'Apple' part of the OS explain that you have to set the execute bit to get things running.

Try it on TextEdit - scoot over and change the mode of the binary from 0755 to 0644 and see what you get.

You get nada.

What's Apple supposed to do for you at this impasse? After all it's only a bit. A binary digit. Shit happens. So what are they going to tell you? Fix permissions? Wipe and reinstall your entire operating system?

As they've given up on the lame 'fix permissions' ever since the Month of Apple Bugs exposed how that could be exploited to gain control of a system, pretty much all you're left with today is 'wipe and reinstall'.

But isn't that the same ludicrous thing Microsoft used to tell their (l)users?

The Other Digits

Thanks to Apple, there are more digits today. And they're not in octal either. In fact and in theory there's so much as to be a bit overwhelming. Very little of this is authentic Unix. The most of this is simply and exclusively 'Apple'. But if you're stuck in an Apple shop, poor you, you'll need to deal with these digits from time to time.

In addition to standard Unix modes, you have system and user flags, as well as access control lists.

Access control lists are collections of access control entries, and both are beyond the scope of this tutorial - but are taken care of by the ACP utility ACL.



The system and user flags aren't standard either, and are depicted in hex, not octal. The ACP helper applet MC ('Mode Calculator') can help a bit with that.



How these flags and bits compare, which take precedent, which override which others: that's 'Apple-defined' (but not officially, as Apple will seldom be as factual as that).

Still the same, it appears for now that the system/user flags override ACEs which override standard modes.

You'll most often have to deal only with standard 'ugo' modes, so learn to mode.

About Rixstep

Stockholm/London-based Rixstep are a constellation of programmers and support staff from Radsoft Laboratories who tired of Windows vulnerabilities, Linux driver issues, and cursing x86 hardware all day long. Rixstep have many years of experience behind their efforts, with teaching and consulting credentials from the likes of British Aerospace, General Electric, Lockheed Martin, Lloyds TSB, SAAB Defence Systems, British Broadcasting Corporation, Barclays Bank, IBM, Microsoft, and Sony/Ericsson.

Rixstep and Radsoft products are or have been in use by Sweden's Royal Mail, Sony/Ericsson, the US Department of Defense, the offices of the US Supreme Court, the Government of Western Australia, the German Federal Police, Verizon Wireless, Los Alamos National Laboratory, Microsoft Corporation, the New York Times, Apple Inc, Oxford University, and hundreds of research institutes around the globe. See here.

All Content and Software Copyright © Rixstep. All Rights Reserved.

CONTACT INFO:
John Cattelin
Media Contact
contact@rixstep.com
PURCHASE INFO:
ACP/Xfile licences
User/Family/Business
http://rixstep.com/buy
About | ACP | Buy | Industry Watch | Learning Curve | News | Products | Search | Substack
Copyright © Rixstep. All rights reserved.