Category: Scripting

Force single user mode from the Terminal command line

Taken with thanks from this StackOverflow post: http://apple.stackexchange.com/a/241819/132943

Open Terminal.app and enter:

sudo nvram boot-args="-s"

In the future your Mac will always boot to single user mode until you remove (sudo nvram -d boot-args or sudo nvram boot-args="") or replace the boot-args.

Other boot-args directly modifying the boot mode:

sudo nvram boot-args="-v": verbose
sudo nvram boot-args="-x": safe mode

Lazy unix command line script

I don’t know about you, but as a developer, I can’t count how many times a day I use the command on my Mac Terminal command-line:

ls -al directoryname

By definition, as a developer, I am lazy and I’m tired of typing that command. So I came up with an easy alternative:-

l directoryname

Back in the early 90’s, one of the flavours of SCO Unix had this command and I kinda miss it, so I recreated it very easily here:-

sudo echo "ls -al $*" > /bin/l
sudo chmod +x /bin/l

You’re done. Now you can simply use l directoryname or any other variation on the ls command to list your files.