Reset Ubuntu password for Jetson device: by mounting root to another Linux system

16970809:

In this article, we will explain how to reset your Ubuntu 20.04 password if you forgot it. We will do this by mounting Ubuntu's root directory to another Linux system. We will also cover the functionality of the chroot command.

1. Background

Recently, our R&D team encountered a difficult problem. A Jetson Orin device used for research and development and used by multiple people suddenly failed to allow everyone to connect and displayed an incorrect password. Every team member said they had not changed their passwords, which led me to wonder if a cyberattack or an insecure remote tool connection was causing the problem.

In this case, we need to reset the device's password and resume normal use as soon as possible. At the same time, this incident also reminds us to always pay attention to network security and guard against potential network threats. In order to ensure the data security of team members and the normal operation of the equipment, we need to take certain security measures, such as regularly updating passwords, using secure remote connection tools, and avoiding connecting equipment in unsafe network environments.

In this article, we will explain how to reset Ubuntu 20.04 password by mounting the root directory to another Linux system to solve this problem. At the same time, we will also explore the usage of chroot, which plays an important role in system recovery, software testing, and security enhancement. I hope this article can help everyone quickly find solutions when encountering similar problems and improve network security awareness.

2. Introduction to chroot command

chroot (change root) is an operation that changes the running environment of a process in Unix and Unix-like operating systems. It allows processes to run in an isolated file system, which is called a "chroot environment". Processes in a chroot environment cannot access other directories on the system, providing a useful tool for testing, recovery, and security scenarios.

2.1 Purpose of chroot

Here are some of the tasks chroot can be used to accomplish:

  • Recovering the system: When something goes wrong with the main system, chroot can be used to restore files and configurations from a backup or other Linux systems.
  • Software testing: Testing new software in an isolated environment to ensure it does not affect the main system.
  • Security enhancement: chroot can help reduce security risks by restricting the file system that a process can access.
  • System installation and maintenance: chroot can be used to create and maintain a new operating system instance, such as creating a new environment for development.

2.2 Things to note

When using chroot, you need to pay attention to the following points:

  • Ensure that the target system's architecture is compatible with the current system. If it is not compatible, programs in the chroot environment may not run properly.
  • In a chroot environment, you can use the exit command to exit and return to the original system.
  • You need to run the chroot command with root privileges because it involves system-level operations.

3. Reset Ubuntu password

The Jetson Orin device does not have onboard eMMC storage and uses an nvme hard drive. This also facilitates our subsequent operations. We can directly disassemble the machine and install the hard drive on another Ubuntu computer. After handling the prerequisites, you can follow the steps below. Steps to reset password.

3.1 Mount the hard disk on another Linux system

First, we need to mount the root directory of Ubuntu 20.04 to another Linux system.

Create a directory for mounting the partition, for example /mnt/ubuntu:

sudo mkdir /mnt/ubuntu

Use the mount command to mount the partition. In this example, the partition device is /dev/sda1and the mount point is/mnt/ubuntu

sudo mount /dev/sda1 /mnt/ubuntu

3.2 Use chroot command

Now, we have successfully mounted the root directory of Ubuntu 20.04. Next, we will chrootswitch to the mounted Ubuntu system using the command:

sudo chroot /mnt/ubuntu

This is a note we put forward at the beginning. We need to ensure that the architecture of the target system is compatible with the current system. This is also a pitfall that I encountered when using it for the first time. Fortunately, the error message made me immediately realize that I was using it amd64. The same architecture is easy to solve, just plug the hard drive into the TX2 next to it and operate it.

Please add image description

3.3 Reset password

Resetting the password is relatively simple, passwdjust use the command directly. For example, to set a new password for the user named "user", enter:

passwd user

Then follow the prompts to enter your new password.

Please add image description

3.4 Exit the chroot environment and uninstall the root directory

exitExit the environment using the command chroot:

exit

Finally, unmount the mounted root directory:

sudo umount /mnt/ubuntu

4. Finally

In this article, we covered how to reset your password by mounting the root directory of Ubuntu 20.04 to another Linux system. We also covered the functionality of the chroot command. Hope this information helps you solve similar problems.

Guess you like

Origin blog.csdn.net/marin1993/article/details/133469759
Recommended