AMITIAE - Saturday 13 October 2012


Command Line Work: New Users and Terminal (14) -- Passwords, Purging and Closing Notes


apple and chopsticks



advertisement


By Graham K. Rogers


Terminal


Ever since the first Macs appeared, they have been known for the graphical user interface (GUI): icons instead of command line work which before the mid-1980s was the norm. Paradoxically, the arrival of OS X brought with it easy access to the command line should users ever want this, although it is possible to use the computer without ever needing to work at the command line at all.


Passwd

There are occasions when a user may need to change the password in an account on a Mac running OS X. This is usually effected by entering System Preferences > Users & Groups, and clicking on the Change Password button in the specific user's panel.

There may be times when this is not possible: the panel is locked in a user account and the Admin account is not accessible; the user has forgotten the password; the Admin user has forgotten the password. There may be other situations where the password cannot be changed using System Preferences. The command used is passwd.

As ever, care is needed for what is a fairly simple command and one that sysadmins of Linux- or Unix-based networks apply when their users forget passwords. The command may be used in a number of ways:

  • In a user account when the old password is known and System Preferences is not accessible with the help of Admin;

  • By an admin user to change a user password;

  • In Single User mode to change any password (brute force).


If a user wants to use this method in Terminal, the system will ask for the current password. It will only continue if the correct password is entered. When the new password is entered, the user is asked to enter this again (like in System Preferences) to make sure they match.

The man passwd entry indicates that new password should be at least six characters long and not purely alphabetic. Its total length should be less than 128 characters (currently). Users are urged to use numbers, upper case letters, and other characters (e.g. & $ > *) for security reasons.

When the password has been verified, the information is entered into the directory system. However, users of OS X may need to use the old password one time with Keychain Access to confirm the changes and allow continued access to passwords in that utility.


If the Admin user is to use this command to change a user's password, the command would be

passwd username

Even as Admin in OS X 10.8 (I am using 10.8.2), the command prompts for the old password before allowing the process to continue.


There is also the brute force method which may need to be used if a user has forgotten the password and no amount of memory-jogging has succeeded in bringing it back. It may be necessary to start the computer in single user mode and then mount the disk. This is not really for the user trying out the Terminal as a novice, so I suggest finding someone who knows what they are doing, like a local repair service.

Basic information on this is in an item by David Mendez on OS X Daily; and dire warnings about the risks in an article on Secure Mac. I would also add that, as this can be dangerous in the wrong hands, users run the Firmware Password Utility (in the Rescue utilities, accessed by using the keystrokes Command + R at startup). Forgetting that password will cause other problems, however.


Purge

There are occasions when the system on any computer begins to slow and one of the suggested tasks that might speed things up (there are many) is to empty the disk cache. Remember there is also a cache for a browser: this disk cache is not the same. However, there is a command that will allow a user to flush and empty the cache: purge.

That is it: simple and straight forward. It takes about 15 seconds to run on my Mac. However, while cleaning out the problem parts of a cache, the useful parts will also go and the system will have to rebuild cache following this operation.

Additional information in the brief manual entry tells us the command "can be used to approximate initial boot conditions with a cold disk buffer cache for performance analysis. It does not affect anonymous memory that has been allocated through . . ." certain system processes.


Closing Notes

The series of commands I have been writing about (see list below) were not intended as a definitive guide to using Unix commands on a Mac, but more as a way for new users who might be unfamiliar with a command line interface to try one or two commands (in relative safety) and gain interest.

I had intended to include the debug command, but others have beaten me to it this week and there is no point reinventing the wheel. Early in the week, Paul Horowitz on OS X Daily wrote an article, "10 of the Best Defaults Write Commands to Improve Mac OS X" which illustrate how certain applications settings may be changed writing to the files that control the applications. There are many more and some may be found on Internet sources.

Later in the week, Topher Kessler on MacFixit (now part of CNET) completed the circle in an article which outlines some of the ways defaults may be used to read, write, and delete Mac OS X user defaults from the command line. These two articles, plus man defaults will give those interested enough to be going on with.


As ever, If in doubt, Don't.



See Also -

  • New Users and Terminal (1) -- A Quick Look Round
  • New Users and Terminal (2) -- Basic Navigation
  • New Users and Terminal (3) -- Shell Basics
  • New Users and Terminal (4) -- Lists and Manuals
  • New Users and Terminal (5) -- Internet Use
  • New Users and Terminal (6) -- Questions of Identity
  • New Users and Terminal (7) -- A Little More Discovery
  • New Users and Terminal (8) -- File Commands and More
  • New Users and Terminal (9) -- Process Identification and Termination
  • New Users and Terminal (10) -- Browsing the Web using Unix
  • New Users and Terminal (11) -- Unix Tricks from OS X Daily
  • New Users and Terminal (12) -- Installed Text Editors - emacs, nano, pico, vi and vim
  • New Users and Terminal (13) -- Installing and Using the Utility, WGET
  • New Users and Terminal (15) -- Permissions and chmod


    Graham K. Rogers teaches at the Faculty of Engineering, Mahidol University in Thailand. He wrote in the Bangkok Post, Database supplement on IT subjects. For the last seven years of Database he wrote a column on Apple and Macs.


  • advertisement



    Google


    Made on Mac

    For further information, e-mail to

    information Tag information Tag

    Back to eXtensions
    Back to Home Page