Skip to content

Instantly share code, notes, and snippets.

@pawelpanek81
Created March 20, 2018 00:27
Show Gist options
  • Save pawelpanek81/fe7d68c537efc8d35b2b63f56788bebd to your computer and use it in GitHub Desktop.
Save pawelpanek81/fe7d68c537efc8d35b2b63f56788bebd to your computer and use it in GitHub Desktop.
#Dodanie użytkowników
```#!/bin/bash
while read konto;
do
n=$(echo $konto | cut -d : -f 1)
l=$(echo $konto | cut -d : -f 2)
p=$(echo $konto | cut -d : -f 3)
adduser $l --disabled-password --gecos ""
chfn -f "$n" $l
echo "$l:$p" | chpasswd
done```
###Wynik
```root@pawel:/home/pawel/Documents# cat plik_dev | ./add_users.sh
Adding user `janko' ...
Adding new group `janko' (1001) ...
Adding new user `janko' (1001) with group `janko' ...
Creating home directory `/home/janko' ...
Copying files from `/etc/skel' ...```
#Usuniecie
```#!/bin/bash
while read konto;
do
l=$(echo $konto | cut -d : -f 2)
deluser --remove-home --quiet $l
done```
###Wynik
```root@pawel:/home/pawel/Documents# cat plik_dev | ./remove_users.sh```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment