Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Created May 13, 2015 03:28
Show Gist options
  • Save CMCDragonkai/a35584049c44d459440e to your computer and use it in GitHub Desktop.
Save CMCDragonkai/a35584049c44d459440e to your computer and use it in GitHub Desktop.
Bash: Check if User Exists

Check if User Exists

id -u "Username"

You can use it in a conditional:

#!/bin/bash
if id -u "$1" >/dev/null 2>&1; then
  echo "user exists"
else
  echo "user does not exist"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment