Simplified Drupal Sites with Drush
Illustration by John Hersey

User management


From:

Simplified Drupal Sites with Drush

with Jon Peck

Video: User management

Managing users is an everyday task for many Drupal site administrators. So Drush provides an interface for that as well. Let's start with getting information about a user. drush help user information. The User information command, aliased as uinf, displays information about a user. The argument passed as a comma separated list of usernames UIDs and email addresses. Right now there's only one user on the system, the admin user that was created during site installation.

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Simplified Drupal Sites with Drush
1h 22m Intermediate Dec 06, 2012

Viewers: in countries Watching now:

Manage your Drupal sites even more efficiently with Drush, the shell interface for managing and scripting Drupal site development. In this quick course, author Jon Peck describes what Drush is, how to install it, and how to use it effectively for everyday—and exceptional—tasks.

The course describes how to manage users, download and install modules and themes, archive and restore your entire site, and employ site variables for fast, full control over your Drupal sites. Plus, discover how to script an entire Drupal site installation with and without site profiles.

Topics include:
  • What is Drush?
  • Installing the prerequisite files
  • Installing Drush with PEAR, manually, and just for Windows
  • Installing Drupal sites
  • Managing themes
  • Controlling user access
  • Controlling cache and cron
  • Reading logs
  • Updating modules
Subjects:
Developer Web
Software:
Drupal Drush
Author:
Jon Peck

User management

Managing users is an everyday task for many Drupal site administrators. So Drush provides an interface for that as well. Let's start with getting information about a user. drush help user information. The User information command, aliased as uinf, displays information about a user. The argument passed as a comma separated list of usernames UIDs and email addresses. Right now there's only one user on the system, the admin user that was created during site installation.

So I will get information about that user, drush uinf admin. The user id, name, mail, roles and status are displayed. Additional information can be shown using the option --full. The full view is a bit more extreme and is useful for low-level debugging. For example, the password is shown in a sense. It's the hashed password not the actual password which in this case is admin.

A common problem is that users are constantly forgetting their passwords. Drupal's Password API hashes passwords using a secured stretched hash, meaning that it's both salted and hashed multiple times to increase the complexity of the stored password to reduce the risk of brute force decryption. Due to these privacy and security restrictions this means the passwords cannot be read even by administrators, despite whatever a client may request or demand. Instead, Drupal's administrative interface provides a mechanism that allows users to request one time Logins and allows administrators to arbitrarily set a user's password.

I will demonstrate both of these techniques using Drush. First, setting passwords manually, this is useful when working on a local duplicated copy of a client site and the particular password is not known. drush user password, or just aliased as upwd sets, the password for a user. The only argument is the username and there is a required option, yes that's oxymoronic but it is required names password containing the new password in plain text. So I am going to set password for admin with the required option, password =hello.

I can also put quotes around the password if the target password contains quotes or spaces. "Hello" isn't a good password so set it back to admin which is still insecure but easy to remember in a development environment. drush upwd admin password=admin. The second technique, generates a one- time login URL which can be given to a user. This is preferable to setting a password for user as administrators should never know a users password.

The user login command aliased uli will generate these log in URLs for a given user, drush uli admin. Depending on the way the site was set up Drush may not know the actual site URL and out-of-the-box the URL is not set which is why it's showing as http default. Always look at the output before blindly passing it on to the user. These generated one time log-ins are not emailed by Drush, the administrator needs to manually use these URLs in whatever way they see fit.

Drush user interaction goes beyond passwords, users can be created, blocked and unblocked and even canceled. I will start by creating a test user using the User Create command aliased as ucrt, drush help ucrt. User create takes an argument containing the username followed by the two options with a mail and password. drush ucrt test mail="test@ example.com" and password=test.

Now if I get user information on the test user, drush uinf test, I will see the same information as I was shown when I created the user. While user create is used on one user at a time the block and unblock commands will work on multiple users at a time. The user list can be separated by commas and the users can be specified by UID, email or username. Be careful with this command as there is no prompt and Drush will respect whatever email preferences that have been set on the site such as not notifying on blocks and sending an activation email when unblocking.

To block a user I would use the user block command aliased as ublk followed by an argument containing the users. drush ublk, let's get the help for that, I will block both the admin user by UID and the test user, by user name. Notice that I am not using the additional options specifying that I'm using a UID or username, Drush will do the work for me. Verify that the admin user is blocked with the command line. drush uinf 1.

Then, return to the browser and attempt to navigate to a page. Being blocked, the admin user is kicked out. The user status is shown as blocked, given that it's easy to block someone without a prompt the block can be also similarly removed, user unblock operates in a very similar manner and has a similar alias, uublk. I will leave the test user blocked, drush uublk 1.

I'm shown an error regarding e-mail as my local development environment was not set up to send email at this time and by default Drupal will send an email upon account activation. Finally, if I want to gracefully get rid of an account I can cancel a user using the user cancel command. Ironically aliased as ucan, drush help ucan. By default all contents owned by the user reverts to UID 1. I will cancel the test account now as I'm done with it.

User cancel takes one argument a single user to cancel, an optional argument will just arbitrarily delete all content created by the user as well, drush ucan test delete content. Following a prompt the user in all their content will be deleted. Throughout this chapter I've covered a number of core functionalities for everyday operation, including: site installation and introspection for building a site from the ground up and getting a high-level perspective of site configuration, listing and managing modules which is useful for downloading, enabling and disabling modules, theme and variable management using variable set and get in user management including creation, blocking and unblocking and cancellation.

In the next chapter, I will discuss more advanced and low-level site management techniques

There are currently no FAQs about Simplified Drupal Sites with Drush.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Simplified Drupal Sites with Drush.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.