Linux adduser Command In Hindi

Blogs ❯❯ Linux

Image could not load

Image on pixabay

Linux adduser

Linux में adduser command का use आपके Linux machine new user create करने के लिए किया जाता है। यह command , useradd Command की तरह ही कुछ default configurations के साथ new user create करती है।

Linux में new user को add करने के लिए दो commands का use किया जाता है -

  1. useradd

  2. adduser

adduser Vs useradd

Linux में adduser command , useradd Command की symbolic link ही है। और इनमे सबसे बड़ा difference यह है कि useradd command system के साथ compile की गयी native binary है, जबकि adduser Command एक Perl script है जो background में तो useradd binary ही use करती है।

चूंकि useradd Command native command है means इसे use करने के लिए आपको install नहीं करना पड़ेगा , और adduser command use करने के लिए आपको install करना पड़ेगा।

इसके अलावा useradd Command द्वारा create किये गए user से सिर्फ user ही create होता है , extra configurations आपको अलग से manually set करनी पड़ेगी जबकि adduser Command new user के लिए सभी default configurations automatically set कर देती है।

***

इस article में हम adduser command के बारे में बात करेंगे।

Linux install adduser

adduser command को use करने के लिए आपको इसे install करना पड़ेगा। install करने के लिए नीचे दी गयी command को run करें -

$ sudo apt update
$ sudo apt install adduser

Linux adduser Example

नीचे Example में user1 नाम का एक user create किया है। औरआप output में देख सकते हैं कि user create करते समय कुछ information को fill करने के लिए कहा गया है , हालाँकि ये optional हैं।

$ sudo adduser user1
Adding user `user1' ...
Adding new group `user1' (1001) ...
Adding new user `user1' (1001) with group `user1' ...
Creating home directory `/home/user1' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for user1
Enter the new value, or press ENTER for the default
        Full Name []: User 1
        Room Number []: 1234
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] Y

ध्यान रहे new user account को create करने के लिए useradd command को root या कोई ऐसा user जिसके पास sudo privileges हैं वही run कर सकता है।

जब हम कोई new user create करते हैं तो निम्नलिखित files में changes होते हैं -

  • /etc/passwd

  • /etc/shadow

  • /etc/group

  • /etc/gshadow

  • और /home में new user के लिए एक directory भी create होती है।

See user detail

create किये गए user की information like : user id, group id और assign किये गए groups देखने के लिए id username command का use किया जाता है।

$ id user1
uid=1001(user1) gid=1001(user1) groups=1001(user1)

Linux create user with different shell

By default create किया गया user bash (shell) के साथ create होता है , check करने के लिए आप नीचे दी गयी command run करें -

$ tail -1 /etc/passwd
user1:x:1001:1001:User 1,1234,,:/home/user1:/bin/bash

Output में आप देख सकते हैं कि user1 को bash के साथ create किया गया है।

new user को different shell के साथ create करने के लिए --shell option का use किया जाता है।

$ sudo adduser user2 --shell /bin/sh
Adding user `user2' ...
Adding new group `user2' (1002) ...
Adding new user `user2' (1002) with group `user2' ...
Creating home directory `/home/user2' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
No password has been supplied.
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for user2
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] Y

check करने के लिए again आप tail command का use कर सकते हैं।

$ tail -2 /etc/passwd
user1:x:1001:1001:User 1,1234,,:/home/user1:/bin/bash
user2:x:1002:1002:,,,:/home/user2:/bin/sh

Login user

user create करने के बाद आप su username command का use करके system में login कर सकते हैं ।

$ whoami
ubuntu
$ su user1
Password:
$ whoami
user1

और logout करने के लिए आप exit use कर सकते हैं।

adduser Command Options

adduser Command के सभी Options को देखने के लिए आप adduser --help command run कर सकते हैं।

$ adduser --help
Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook