# Ubiquiti UniFi

##### List users in the UniFi Controller database

```bash
# show list of users in the unifi mongodb database
mongo --port 27117 ace --eval "db.admin.find().forEach(printjson);"
```

##### Change password for a UniFi Controller user

```bash
# change <UserName> to an actual user on the unifi controller
# the command will reset that user password to 'password'
mongo --port 27117 ace --eval 'db.admin.update( { "name" : "<UserName>" }, { $set : { "x_shadow" : "$6$GgQYRQnUs4wYkRd$7g6mig.les9salut9CZjUrG/UqqF6R/2RiCaCQEpEzz/7UtAtzeeQsVDnacAW1el2KH/jvUuJ4Eh08xy.KGl0/" } } )'
```

[Decrypt a UniFi Controller backup](https://github.com/zhangyoufu/unifi-backup-decrypt)

##### Force dhcp to renew ip address

1. Get the PID of the udhcpc process
2. Send that process the USR1 signal which tells udhcpc to renew its IP address 👍

```shell
# find the PID of the udhcpc process
ps | grep udhcpc
```

```shell
# output of the above command
 4052 admin     3480 S    /sbin/udhcpc -f -i eth0 -V ubnt -A 10 -s /etc/udhcpc/udhcpc -p /var/run/udhcpc.eth0.pid
 6648 admin     3504 R    sh /usr/etc/syswrapper.sh ssh-trace-cmd -c ps | grep udhcpc -n 4 -i
 6650 admin     3480 R    grep udhcpc
```

```shell
# instruct udhcpc to renew its IP address by sending it's process the USR1 signal
kill -USR1 4052
```

:end