Adding A New User Gnu/Linux

ketik #man useradd

adduser  [-u uid [-o]] [-g group] [-G group,...]
[-d home] [-s shell] [-c comment] [-m [-k template]]
[-f inactive] [-e expire mm/dd/yy] [-p passwd] [-n] [-r] name
adduser  -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire mm/dd/yy]

baca dan perhatikan arti dari penjelan di atas 

ujicoba membuat user 

root@repo-ubuntu:~# useradd test -g users -d /home/test -s /bin/bash

cek keberadaan user baru "test"

root@repo-ubuntu:~# cat /etc/passwd | grep test
test:x:1001:100::/home/test:/bin/bash

cek sekali lagi keberaddan si user tadi 

root@repo-ubuntu:~# ls -al /home | grep test

jika tidak menghasilkan apapun (kosong) bikin direktori utk user baru tersebut 

root@repo-ubuntu:~# mkdir /home/test 

step terakhir adalah memberikan password utk si user baru tadi caranya 

root@repo-ubuntu:~# passwd test
Enter new UNIX password: 

selain itu bisa juga di bikin melalui script : 

contoh :
==============================================
#!/bin/sh
#nama file : add_single_user.sh
#skrip ini digunakan untuk membuat user linux
if [ $# -ne 2 ]
then
  echo "selamat mencba "
  echo "isi password dan usernya : $0 nama user passwordnya "
  exit 0
fi

echo $2 > /tmp/password
adduser $1
passwd $1 --stdin < /tmp/password > /dev/null
rm -f /tmp/password
===============================================
lalu jalankan scripnya : 

root@repo-ubuntu:~# sh add_single_user.sh nama_user 

==============================================
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s