O'Reilly logo

Wicked Cool Ruby Scripts by Steve Pugh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modifying a User

Modifying a User

modUser.rb

If you have ever administered a computer system that had multiple users, chances are you have had to modify existing accounts. In my experience, user accounts can be modified to update an expiration date, change a home directory, tweak a username, or, more commonly, to add a new group to the mix. Below you will find a generic script for guiding the user through the modification process. Keep in mind that this script needs to be run with elevated permissions.

Warning

This script is platform dependent, so ensure that your systems are compatible with the commands to avoid corrupting your user files.

The Code

 #!/usr/bin/env ruby #Using the command 'useradd' with various arguments print "Enter the username to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required