Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

ubuntu add user to group

sudo usermod -a -G group username
Comment

add user to group linux

sudo usermod -aG <groups> <username>
Comment

ubuntu add user to group

sudo usermod -aG groupName userName

# restart or just run
newgrp groupName
Comment

group of user ubuntu

groups <username>
Comment

add users in group ubuntu

#!/bin/bash



while [ x$username = "x" ]; do



read -p "Please enter the username you wish to create : " username



if id -u $username >/dev/null 2>&1; then



echo "User already exists"



username=""



fi



done



while [ x$group = "x" ]; do



read -p "Please enter the primary group. If group not exist, it will be created : " group



if id -g $group >/dev/null 2>&1; then



echo "Group exist"



else



groupadd $group



fi



done



read -p "Please enter bash [/bin/bash] : " bash



if [ x"$bash" = "x" ]; then



bash="/bin/bash"



fi



read -p "Please enter homedir [/home/$username] : " homedir



if [ x"$homedir" = "x" ]; then



homedir="/home/$username"



fi



read -p "Please confirm [y/n]" confirm



if [ "$confirm" = "y" ]; then



useradd -g $group -s $bash -d $homedir -m $username



fi
Comment

PREVIOUS NEXT
Code Example
Shell :: java scrip loop array 
Shell :: find bahs 
Shell :: Shell command, operator and separator/control characters: 
Shell :: bluetooth turned off even if switched on 
Shell :: install airflow spark 
Shell :: how to get the inode numbers 
Shell :: my macbook trminal has no color 
Shell :: fix kali linux asking to restart services 
Shell :: heredoc remove leading space tabs linux bash 
Shell :: Collaborators access SSH new project Github 
Shell :: Copying file permission of unixcop to monitor.txt 
Shell :: how to create malware for android in kali 
Shell :: terrminal generate uudi 
Shell :: yaml run inside folder command 
Shell :: git create rempote branch 
Shell :: apt install mp3 diags 
Shell :: kubernetes short call 
Shell :: How to redirect docker-compose command stdout stderr from docker container to file 
Shell :: remove gpg error on your installed app or package 
Shell :: Numeric calculations 
Shell :: privileged on running container 
Shell :: Command to get list of shell variables in bash 
Shell :: change directory in linux 
Shell :: remove mac ._ files windows 
Shell :: change git 
Shell :: burp suite kali linux 
Shell :: ubuntu apt shortcuts 
Shell :: Git - add all changes files at same time for commit 
Shell :: install dependencies and devDependencies at same time 
Shell :: install ignite-cli 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =