Change UniFi User Password from Command Line

  1. SSH into the UniFi server
  2. Connect to MongoDB
  3. Find user ObjectId
  4. Update user info with new Password

You will need a hash of the password to put into the database. We don’t cover that in this post. You could copy the password from a different user account or use a different UniFi instance to change the password and then check the DB to find the hash.

SSH into the UniFi Server

ssh unifiadmin@unifiserver

Connect to MongoDB

Connect to Mongo by typing in the following.

mongo -port 27117

Then select the ace database by typing

use ace

Find user ObjectId

The admins are in the admin collection/table. Use the following command to list all the users and their name, email, and password hash.

db.admin.find({ }, { name:"" , email : "", "x_shadow" : "" })

Update user info with new Password

The following looks complex. Fortunately though you should be able to copy and paste. You should only need to change the
– ObjectId to your User Id
– Password Hash to your password hash

db.admin.update({"_id" : ObjectId("223abc5489de0a93be758493")}, {$set: { "x_shadow" : "$6$nwpi7.q2$OuD9/UZGZt5cD739Dt7j8Gb1uPtfU99p0DeDSurSNBZVizieUrFVFbRufiZMgOk2IaaDZN9BVmL9yUwQ2mC8f."}});

Note: The hash above is password. Not recommended for use.

You should receive a confirmation that it succeeded. Test the new password by logging into the UniFi Controller.

For more MongoDB commands, check out this post.

How to Restore Pixel to Factory Image

Restoring a Pixel to the factory image is a pretty straight forward operation if you are familiar with fastboot and adb. This guide assumes you have fastboot already installed and setup in your user path. If not you can refer to the following link for more information.

WARNING – THESE STEPS WILL DELETE ALL USER DATA OFF THE DEVICE.

https://developers.google.com/android/images#instructions

1. Download OTA Image

Go to the following link and download the Factory Image for your device

https://developers.google.com/android/images

Extract the file and then open a terminal or command prompt in that directory.

2. Boot up Pixel in recovery

You can do this with “adb reboot recovery” or with the volume key to boot into the Android boot menu.

3. Flash Image

On Windows you can flash the firmware with

flash-all.bat

Or on Linux

./flash-all.sh

Should take it a couple of minutes to complete.

Next we can lock bootloader with

fastboot flashing lock

You will need to confirm the lock on your phone.

Reset UniFi to Factory Defaults – Command Line

SSH into the UniFi. Note that the UniFi username and password get updated from the controller. Refer to here to find username and password.

ssh ubnt@192.168.1.20

run the syswrapper.sh script with the restore-default option

syswrapper.sh restore-default

Once the device is reset, log in over ssh and reconfigure.

Note that the username and password will now be ubnt/ubnt

Reset NextCloud admin password – Snap package

The regular command to reset the password for a NextCloud user does not work when NextCloud is installed from a snap package.

$ sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin
Could not open input file: /var/www/nextcloud/occ

The reason is that NextCloud is located in “/snap/nextcloud”

Unfortunately the occ file is not located in /snap/nextcloud/current/

However, you can run the nextcloud.occ command directly without specifying the path. Change admin to your user.

sudo nextcloud.occ user:resetpassword admin

Type in the new password twice and login.

How to reset Minecraft Demo timer without resetting the World – Linux

Note that the following commands have not been tested, but based off of other ones so should work.

Open a terminal and run the following two commands to delete level.dat and level.dat_old

rm ~/.minecraft/saves/Demo_World/level.dat 
rm ~/.minecraft/saves/Demo_World/level.dat_old 

Should be able to open up Minecraft and have the timer reset. Note that all the achievments in the game will be reset as well.

How to reset Minecraft Demo timer without resetting the World – Windows

Open Windows File Explorer, in the Address Bar paste the following and hit enter.

%APPDATA%\.minecraft\saves\Demo_World\

You should now be in the demo world folder.

Delete the “level.dat” and “level.dat_old” files and restart minecraft.  Your timer should now be reset as well as all the game objectives.

Reset WordPress admin password in MySQL

Log into MySQL from command line

mysql -u root -p

Select the correct database

USE wordpress_db;

Print current users

SELECT * FROM wp_users;

Should get something similar to the following

mysql> SELECT * FROM wp_users
-> ;
+----+------------+------------------------------------+---------------+---------------------------+----------+---------------------+------------------------------------+-------------+--------------+
| ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name |
+----+------------+------------------------------------+---------------+---------------------------+----------+---------------------+------------------------------------+-------------+--------------+
| 1 | admin | 5f4dcc3b5aa765d61d8327deb882cf99 | admin | bob@incredigeek.com | | 2018-08-09 10:10:42 | | 0 | admin |
| 2 | bob | 210805fb52a13251f4bedc7e725e575a | bob | bob@incredigeek.com | | 2019-11-01 11:31:23 | | 0 | bob smith |
+----+------------+------------------------------------+---------------+---------------------------+----------+---------------------+------------------------------------+-------------+--------------+
3 rows in set (0.00 sec)
mysql>

To update the password use

UPDATE wp_users SET user_pass = MD5('NewPass') WHERE ID=1;

The MD5 hashes the NewPass and adds it to the database. You can print the users again to verify the hash changed.

You should now be able to login using the new password you configure.

How to Reset a Windows Password

There are multiple ways to reset windows passwords.  This one replaces the sticky key program with a command prompt from which you can change the password.

To reset the forgotten windows password, follow these steps:

  1. Boot from a Windows setup DVD.  Any setup DVD should work.  Access the command prompt.
  2. Find the drive letter of the partition where Windows is installed.  In Vista, Windows 8 and XP, it is usually C:, I have read that in Windows 7, it is D: I am not sure which one it is.  In most cases because the first partition contains Startup Repair.  To find the drive letter, type C: (or D:, respectively) and search for the Windows folder.
  3. Type the following command (replace “c:” with the correct drive letter if Windows is not located on C:):
    copy c:\windows\system32\sethc.exe c:\
    This creates a copy of sethc.exe to restore later.
  4. Type this command to replace sethc.exe with cmd.exe: copy /y c:\windows\system32\cmd.exe c:\windows\system32\sethc.exe
  5. Reboot your computer and start the Windows installation where you forgot the administrator password.
  6. After you see the logon screen, press the SHIFT key five times.
  7. You should see a command prompt where you can enter the following command to reset the Windows password:net user your_user_name new_password

    If you don’t know your user name, just type net user to list the available user names.

  8. You can now log on with the new password.

 

I recommend that you replace sethc.exe with the copy you stored in the root folder of your system drive in step 3.  For this, you have to boot up again with Windows setup DVD because you can’t replace system files while the Windows installation is online.  Then you have to enter this command:

copy /y c:\sethc.exe c:\windows\system32\sethc.exe

You are now finished.