Skip to Content
CentOS System Administration Essentials
book

CentOS System Administration Essentials

by Andrew Mallett
November 2014
Beginner
174 pages
3h 50m
English
Packt Publishing
Content preview from CentOS System Administration Essentials

Scripting user creation

User creation will now consist of three steps:

  • useradd: This creates the user
  • passwd: This sets the password
  • setquota: This sets the disk limits

We can ensure that all this happens correctly and uniformly using scripts to ensure the procedural integrity of the user creation process. It is also going to save you time. As a very quick solution, the following script provides all that we need:

#!/bin/bash
useradd -m -G users $1 
echo Password123 | passwd --stdin $1
passwd -e $1
setquota -u $1 20000 25000 0 0 /home

We will need to run the script with the new username as the argument, as shown in the following example:

# userscript.sh bob

Reading the script though line by line can explain the script contents as follows:

  • #!/bin/bash ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

CentOS 8 Essentials

CentOS 8 Essentials

Neil Smyth
Mastering CentOS 7 Linux Server

Mastering CentOS 7 Linux Server

Mohamed Alibi, BHASKARJYOTI ROY

Publisher Resources

ISBN: 9781783985920