forgot root password or reset root password in Debian

Debian系统重置Root密码
部署运行你感兴趣的模型镜像

http://www.debianadmin.com/forgot-root-password-or-reset-root-password-in-debian.html

 

 

There are times for system administrators they might have forgot their debian machine root password and they want to reset this password.We will see the available options.

 

 

There are various methods available for resetting a root password.

Boot debian linux into single-user mode
Boot using a boot disk (like knoppix,gnoppix) and edit the password file
Mount the drive on another computer and edit the password file

 

It is possible to boot a system and log on to the root account without knowing the root password as long as one has access to the console keyboard.

This is a procedure which requires no external boot disks and no change in BIOS boot settings. Here, “Linux” is the label for booting the Linux kernel in the default Debian install.

Solution 1

At the lilo boot screen, as soon as boot: appears (you must press a shift key at this point on some systems to prevent automatic booting and when lilo uses the framebuffer you have to press TAB to see the options you type), enter:

boot: Linux init=/bin/sh

This causes the system to boot the kernel and run /bin/sh instead of its standard init. Now you have gained root privileges and a root shell. Since / is currently mounted read-only and many disk partitions have not been mounted yet, you must do the following to have a reasonably functioning system.

# mount -n -o remount,rw /

# mount -avt nonfs,noproc,nosmbfs

# cd /etc

# vi passwd

# vi shadow

(If the second data field in /etc/passwd is “x” for every username, your system uses shadow passwords, and you must edit /etc/shadow.) To disable the root password, edit the second data field in the password file so that it is empty. Now the system can be rebooted and you can log on as root without a password. When booting into runlevel 1, Debian (at least after Potato) requires a password, which some older distributions did not.

It is a good idea to have a minimal editor in /bin/ in case /usr/ is not accessible.Also consider installing the sash package. When the system becomes unbootable, execute

boot: Linux init=/bin/sash

sash serves as an interactive substitute for sh even when /bin/sh is unusable. It’s statically linked, and includes many standard utilities as built-ins.

Solution 2

Boot from any emergency boot/root disk set. If /dev/hda3 is the original root partition, the following will let one edit the password file just as easily as the above.

# mkdir recovery

# mount /dev/hda3 recovery

# cd recovery/etc

# vi shadow

# vi passwd

Scroll down to the line containing the root user’s information, which looks something like

root:weeWRSF!sfDFs:12581:0:99999:7:::

Delete everything between the first and second colons, so that the line looks like

root::12581:0:99999:7:::

Save the file and exit your editor.Type cd to return to your home directory.

Type umount mountplace to unmount the partition.

#unmount /dev/hda3 recovery

Type reboot to reboot your system

The advantage of this approach over the previous method is one does not need to know the lilo password . But to use it one must be able to access the BIOS setup to allow the system to boot from floppy disk or CD, if that is not already set.

Solution 3

Reseting passwords by mounting on another system and editing the password file is bit more work need to be done.first you need to Shut down the machine after backing up all important data.Now remove you machine hard disk and connect this hard disk as slave drive for another machine(this should be linux OS) and boot this machine.Once the system finishes booting, mount the slave drive’s root partition and edit the password file.If /dev/hda3 is the original root partition, the following will let one edit the password file just as easily as the above.

# mkdir recovery

# mount /dev/hda3 recovery

# cd recovery/etc

# vi shadow

# vi passwd

Scroll down to the line containing the root user’s information, which looks something like

root:weeWRSF!sfDFs:12581:0:99999:7:::

Delete everything between the first and second colons, so that the line looks like

root::12581:0:99999:7:::

Save the file and exit your editor.Type cd to return to your home directory.

Type umount mountplace to unmount the partition.

#unmount /dev/hda3 recovery

Type reboot to reboot your system

If you want to prevent others from resetting your root password you can use two options first one is protect your bootloader with password i.e your GRUB or LILO boot loaders and second one is protect BIOS with password.

您可能感兴趣的与本文相关的镜像

Langchain-Chatchat

Langchain-Chatchat

AI应用
Langchain

Langchain-Chatchat 是一个基于 ChatGLM 等大语言模型和 Langchain 应用框架实现的开源项目,旨在构建一个可以离线部署的本地知识库问答系统。它通过检索增强生成 (RAG) 的方法,让用户能够以自然语言与本地文件、数据库或搜索引擎进行交互,并支持多种大模型和向量数据库的集成,以及提供 WebUI 和 API 服务

### 故障排查:GitLab 登录提示 "Invalid login or password" 的解决方案 当用户在尝试登录 GitLab 时遇到 **“Invalid login or password”** 错误提示,可能涉及多个层面的问题,包括认证失败、账户状态异常、外部身份验证配置问题等。以下是对常见原因及对应的排查步骤的详细说明。 #### 检查用户名和密码输入是否正确 最常见的原因是用户名或密码输入错误。GitLab 对大小写敏感,因此需确保输入完全准确。建议在输入时关闭自动填充功能,并重新手动输入凭据[^1]。 #### 验证邮箱确认状态 如果用户是新注册用户,GitLab 通常会发送一封包含激活链接的邮件至注册邮箱。若未完成邮箱验证,账户将无法正常登录系统。请检查垃圾邮件文件夹并点击验证链接以激活账户[^1]。 #### 检查账户是否被锁定 GitLab 默认设置中,连续多次登录失败可能导致账户被临时锁定。管理员可通过访问后台管理页面查看该用户状态,并在必要时手动解锁账户。例如,在 GitLab 管理界面中进入 **Admin Area > Users**,找到对应用户并查看其状态字段。 #### 查看 LDAP 或 SSO 集成状态 对于使用 LDAP、SAML 或 OAuth2 等外部身份验证机制的部署环境,登录失败可能是由于外部认证服务同步失败或凭证无效导致的。管理员应检查 GitLab 日志(如 `/var/log/gitlab/gitlab-rails/production.log`)以获取更详细的错误信息,并确保用户的外部身份验证凭据有效[^1]。 #### 使用 API 检查用户状态 GitLab 提供了丰富的 API 接口用于查询用户状态和权限。例如,管理员可以使用如下命令查看特定用户的状态: ```bash curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users?username=<username>" ``` 该接口可帮助确认用户是否存在、是否被禁用或是否处于待审批状态[^1]。 #### 重置密码 如果用户确定自己输入的信息无误但仍无法登录,可以通过 GitLab 的“忘记密码”功能进行密码重置。进入登录页面,点击“Forgot your password?”,然后输入注册邮箱以接收重置链接。 #### 检查项目或组的成员审批设置 如果用户尝试访问某个特定项目或组,而该资源启用了 **Require membership approval** 设置,则即使账户本身有效,也可能因未通过审批而无法获得访问权限。管理员可在项目的 **Members** 页面中查看该用户的请求状态,并进行批准操作[^1]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值