- Linux: загрузка в однопользовательском режиме (single mode)
- Однопользовательский режим при использовании GRUB
- Однопользовательский режим при использовании LILO
- How to boot into single user mode in RHEL/CentOS 7/8 Linux
- 1. Boot into single user mode or rescue mode (rescue.target)
- 1.1 Boot into maintenance mode using ISO
- 1.2 Change runlevel to rescue.target from a valid shell
- 1.3 Boot into rescue mode using GRUB2
- 2. Boot into emergency mode (emergency.target)
- 2.1 Change runlevel to emergency.target with a valid shell
- 2.2 Boot into emergency mode using GRUB2
- Related Posts
- 3 thoughts on “How to boot into single user mode in RHEL/CentOS 7/8 Linux”
- Как мне загрузиться в однопользовательском режиме от GRUB?
- Boot Linux Grub Into Single User Mode
- Procedure: Boot Linux Grub Boot Loader into single user mode
- See also:
Linux: загрузка в однопользовательском режиме (single mode)
Сегодня в статье поговорим о однопользовательском режиме (single mode). Single mode прекрасно подходит для изменения конфигурации системы или выполнения задач по ее обслуживанию. Кроме того, этот режим может быть единственно доступным при работе в поврежденной системе.
Чаще всего переход в однопользовательский режим выполняют путем передачи аргументов программе начальной загрузки. Однако обычно переход в однопользовательский режим с другого уровня выполнения можно выполнить с помощью команды telinit 1 . При этом перезагрузку можно и не выполнять. Если только не требуется устранять какую- либо проблему начальной загрузки.
В качестве меры безопасности корневой каталог системы монтируется в режиме только для чтения. Это вызывает ряд неудобств, если вам надо исправить что либо в системе. Чтобы выйти из положения, начните однопользовательский сеанс с повторного монтирования корневой директории в режиме чтения/записи. Нужное действие выполняет команда:
Конкретные процедуры перехода в однопользовательский режим при использовании загрузчиков GRUB и LILO различаются между собой.
Однопользовательский режим при использовании GRUB
Чтобы выполнить загрузку в однопользовательском режиме при использовании загрузчика GRUB, не нужно применять опции командной строки. Авторы этого загрузчика пришли к выводу, что параметры начальной загрузки должны легко поддаваться изменению, и что клавиша ‘ a ‘ — вполне подходящее средство для решения этой задачи. Когда откроется экран начальной загрузки GRUB, выделите нужное ядро и нажмите клавишу ‘ a ‘, чтобы дополнить опции начальной загрузки. Чтобы обеспечить загрузку в однопользовательском режиме, добавьте флаг single в конец существующих опций ядра. Пример типичной конфигурации мог бы выглядеть следующим образом:
Однопользовательский режим при использовании LILO
Различные дистрибутивы предлагают различные средства открытия командного приглашения LILO. Пользователи Debian и Ubuntu должны нажать и удерживать нажатой клавишу shift сразу после того, как BIOS завершит проверку памяти и другие тесты самопроверки.
В строке приглашения LILO введите метку ядра (она задана в файле lilo.conf ), которое требуется загрузить, а затем — опцию -s или single . Например, стандартное ядро дистрибутива Debian имеет метку “ linux ”, поэтому, чтобы загрузиться в однопользовательском режиме, необходимо ввести следующее:
Если есть вопросы, то пишем в комментариях.
Также можете вступить в Телеграм канал, ВК или подписаться на Twitter. Ссылки в шапки страницы.
Заранее всем спасибо.
Источник
How to boot into single user mode in RHEL/CentOS 7/8 Linux
Table of Contents
How to boot in single user mode in linux. Boot into rescue mode or emergency mode in Red Hat 7/8 Linux. Difference between rescue.target and emergency.target in Linux. How to boot into the emergency target (formally single user mode) with and without ISO CD-ROM. How to boot into maintenance mode in Linux.
Single user mode term was used with CentOS/RHEL 6 and earlier but now with CentOS/RHEL 7 and 8 we have rescue and emergency mode. Now in this article I will share the steps to boot into maintenance mode using systemd.unit
1. Boot into single user mode or rescue mode (rescue.target)
- Rescue mode provides a convenient single-user environment and allows you to repair your system in situations when it is unable to complete a regular booting process.
- In rescue mode, the system attempts to mount all local file systems and start some important system services
- Although it does not activate network interfaces or allow more users to be logged into the system at the same time.
- In Red Hat/CentOS 7/8, rescue mode is equivalent to single user mode and requires the root password.
1.1 Boot into maintenance mode using ISO
1.2 Change runlevel to rescue.target from a valid shell
If you already have a valid shell then you can change runlevel and boot into single user mode or rescue mode using systemctl from the command line.
Here,
isolate means start the unit specified on the command line and its dependencies and stop all others
or alternatively you can also use
Next check the graphical console of your CentOS/RHEL 7/8 Linux host, it will prompt for root user password. Once you provide the root user password you will get a working shell.
1.3 Boot into rescue mode using GRUB2
- Now assuming you don’t have a valid shell then you can boot into single user mode or rescue mode then you can use GRUB2. Boot your CentOS/RHEL 7/8 host till the GRUB2 menu appears.
- On the GRUB2 menu press any button to halt the boot up. Next select the kernel using which you wish to boot into single user mode or rescue mode and press «e» to edit the GRUB2 menu.
In CentOS/Red Hat 7 look out for the line starting with linux16 as shown below
In CentOS/Red Hat 8 look out for the line starting with linux
- Based on your environment append systemd.unit=rescue.target , at the end of line starting with linux or linux16, for example below is a snippet from CentOS/Red Hat 8 node
- Press Ctrl+x to boot the CentOS/RHEL 7/8 Linux node into single user mode or rescue mode and you get the same prompt to put root user’s password
2. Boot into emergency mode (emergency.target)
- Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode.
- In emergency mode, the system mounts the root file system only for reading, does not attempt to mount any other local file systems, does not activate network interfaces, and only starts a few essential services.
2.1 Change runlevel to emergency.target with a valid shell
If you already have a valid shell and you wish to change runlevel to emergency mode then you can use systemctl :
Next check the console of your Linux host and provide the root user password to complete the runlevel change.
2.2 Boot into emergency mode using GRUB2
Similar to the steps explained under boot into single user mode , for Red Hat/CentOS 7 you will have a line starting with linux16 and for CentOS/Red Hat 8 you will have a line starting with linux in the GRUB2 menu respectively.
So based on your environment append systemd.unit=emergency.target at the end of linux or linux16 line. For example below screenshot is from CentOS/Red Hat 8 Linux node to boot into emergency mode
Press ctrl+x to continue with the booting and at the end the screen will again prompt for root user password as I had shown earlier. provide the root user password to get a shell where you can further troubleshoot your environment.
Lastly I hope the steps from the article to boot into single user mode or maintenance mode (rescue mode and emergency mode) in RHEL/CentOS 7/8 Linux was helpful. So, let me know your suggestions and feedback using the comment section.
Related Posts
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.
Thank You for your support!!
3 thoughts on “How to boot into single user mode in RHEL/CentOS 7/8 Linux”
hello,
there is any possibility to switch off providing password during switching into rescue mode ?
cheers,
Piotr
You can use Live ISO Image to boot to GRUB which will not prompt for any password
Not in any of the “rescue modes” provided by systemd.
But yes, you possible still may avoid it completely: put ‘init=/sysroot/bin/sh’ w/o quotes instead of “systemd…blah-blah”.
Your system will be booted without pivot-root, so chroot /sysroot before anything else.
And do ‘touch /.autorelabel’ if you change anything, or you will not be able to login again (no selinux in this mode)
Источник
Как мне загрузиться в однопользовательском режиме от GRUB?
После изменения нескольких строк в xorg.conf я больше не могу загружать Ubuntu (я полагаю, он ломается при попытке загрузить X), поэтому мне нужен способ загрузки в однопользовательском режиме. Тем не менее, в Интернете, похоже, нет нулевых руководств, потому что все они предполагают, что я действительно могу редактировать файлы на своем компьютере, а я, очевидно, не могу.
Так как мне загрузить Ubuntu в однопользовательском режиме?
Когда я отключил заставку, я понял проблему: всякий раз, когда Ubuntu не может загрузить X-сервер из-за какой-либо ошибки, он переключается на tty1 и ждет приглашения, но не выключает заставку.
Для загрузки в single user режиме вы редактируете инструкции по загрузке для пункта меню GRUB, который вы хотите загрузить, и добавляете параметр / опцию ядра single . Краткие инструкции о том, как это сделать, приведены ниже.
- Во Shift время перезагрузки удерживайте нажатой левую клавишу, чтобы вызвать меню GRUB.
- Выберите (выделите) пункт меню загрузки GRUB, который вы хотите использовать.
- Нажмите e для редактирования команд загрузки GRUB для выбранного пункта меню загрузки.
Посмотрите внизу списка команд для строк, похожих на
Измените среднюю строку в (4), добавив параметр загрузки ядра single в конец строки (т.е. после ro quiet splash ).
Для этого примера вы бы изменили:
Нажмите Ctrl + X или F10 для загрузки с использованием этих параметров ядра.
Примечание. Эти изменения не являются постоянными. Любое изменение параметров загрузки ядра, сделанное таким образом, повлияет только на следующую загрузку и только в том случае, если вы начнете эту загрузку нажатием Ctrl + X или, F10 находясь в режиме редактирования GRUB.
Источник
Boot Linux Grub Into Single User Mode
Q . How do I boot a Linux system into single user mode?
A . Single user mode is useful to fix some system problem. Following are steps you need to use to boot Grub boot loader into single user mode.
Procedure: Boot Linux Grub Boot Loader into single user mode
(1) At grub boot screen (after restart)
(2) Select the kernel
(3) Press the e key to edit the entry
(4) Select second line (the line starting with the word kernel)
(5) Press the e key to edit kernel entry so that you can append single user mode
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
(6) Append the letter S (or word Single) to the end of the (kernel) line
(7) Press ENTER key
(8) Now press the b key to boot the Linux kernel into single user mode
(9) When prompted give root password and you be allowed to login into single user mode.
See also:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
am using red hat 9.
user should not be allowed to change root password in single user mode,as it’s in SUSE.
i have already tried grub password.
i want some other method.
pls help me out.
i have tried the possible causes regarding the problem that i have encountered…..the username and passowrd has expired has been prompt when i logged in into my redhat ubuntu. can you please help me out.
Hi folks,
Thank you so so much for all these informations, I really needed them badly.
Tahnks again
ENJOY
Hi,
I have a red hat entreprise 5. A technician change the motherboard of computer. When I restart, the computer does not find the etho eth1 and I decide to pass by single user mode. But when i make step 5, i don’t have the good line and I can’t modify the line. How must i make ? does this problem come from other hardware probleme?
Hi friends
Thank you for you help.
This is my problem:
I can follow this instructions up to step 5
After that I am stuck. for example:
The inf guide on this screen is different from my screen
my GNU grub version is 0.97 (640k lower/1037859k upper memory
When it comes to edit the kernel and add the letter ‘S’, I dont have that option, so I dont know what else to do. Plese tell me what is the next step. I have not use that computer in months , because of this problem. Thank you
With GRUB, using the keywork “Single” does not work, it has to be lowercase : “single”.
Using only “S” also works.
Using “1” also works
Thank You very very much. I really needed badly. Thanks.
Hi ,
I have a computer in the company and we are four use this computer with four accounts.
I have the root password .. By using Single User Mode the others are able to change the root password …!!
It’s a big problem … I need away to prevent the Single User Mode …
How to make bootable usb drive
Hi, i REALLY need help! I have a dell mini linux/ubuntu 8.04 version laptop with only one account which i forgot the password to. I was working on my setup options trying to get a new password and changed the system and HDD passwords. When i said ok my computer wouldnt boot and it prompted me for the passwords i enter in for the HDD/system ones. Now im stuck in grub mode and just wanna get back to my normal set up. Im sooooo confused. Help would be GREATLY appreciated thankyou! (btw: im getting a message saying kernal must be booted before i can boot my computer. How could i go about booting kernel?) thankyou!
you can set grub password and the password for the cmos. make sure the chasis is locked.
hey when i restart the system then it stop to the following line..then i can’t cross over the step…
GNU Grub version 0.97
[Minimal BASH-like line editing is supported. For the first word, tab lists possible command completiions. Anywhere else TAB lists the possible completions of a device/filename]
plz how to cross over from here…..hope u all suggest me..
i have followed the whole procedure but i don’t know what to do when i get the place asking for root password or an option of Ctrl-D to continue.
how do i bypass this since i dont remember my root password?
pls help!
This is useful information can anyone send me this type of information in details
MUST BE “S” or “single”. Screenshot above of “Single” is wrong.
I have also stuck exactly where Baariu Martin is.. Kindly help with more info.. Thanks 🙂
Put ‘single’ in lowercase for this to work.
I have ubuntu 8.04 and it is not allowing me to enter the single user mode. I have used the option e for the same and entered single at the end of the line but it does not work please let me know what should i do and what option should i use.
There are two hard disk create 1+0 raid and OS has been failed . how to retrieve data in the hard disk . OS is in separate partition and data in separate partition. Pls help it out
Thanks for Info 😀
I am working on Solaris 10 , somehow the project file in /etc directory got edited or deleted now i am not able to login to the servers.
Can anyone suggest the solution..for this ..ASAP
Apply power.
When prompted hit any key in 3 seconds, this brings up GRUB
Type ‘a’ to get to append mode (modify kernel arguments), then type:
1
boot 1
You will come up to single user prompt #
I am in real trouble when I reboot I don’t see a grup prompt to get into the single user mode. All that I see is some options such as F2 for setup and several other F options. I tried entering into each of these but never got anything that will let me enter single user mode. I am completely lost. Sorry for these novice rants. I am using RH 6.2 enterprise version. Any help will be greatly appreciated.
Thanks to help me
i did Successfully
i have encounterd a problem regarding my centOS .95
file system has been currepted plz help me to come out..
Regards
Amit shukla
how to edit “/etc/default/grub” from grub menu from commandline (c) . as “sudo nano /etc/default/grub.” does not work. there
This will help you.
]# chage -l
Usage: chage [options] [LOGIN]
Options:
-d, –lastday LAST_DAY set date of last password change to LAST_DAY
-E, –expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-h, –help display this help message and exit
-I, –inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, –list show account aging information
-m, –mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-M, –maxdays MAX_DAYS set maximim number of days before password
change to MAX_DAYS
-W, –warndays WARN_DAYS set expiration warning days to WARN_DAYS
]# chage -l root
Last password change : Aug 09, 2013
Password expires : Nov 07, 2013
Password inactive : never
Account expires : never
Minimum number of days between password change : 1
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
[root@oc15082013
thanks guys for the help, it worked …
I was able to boot my system after it was stuck at grub>
change “Single” in kernel row ro to rw and add init=/bin/bash then press F10, then you will have root command line
Thanks Alex, your solution worked for my requirements…thank you very much
i’m using centos 5.5 and forgotten root password.
but to reset password using single user mode i don’t see ‘e’ or ‘a’ option in grub menu.
It only shows ‘p’ for password. can any1 help me out of this so that i can see ‘e’ option to edit ………..
Hi,
Am not able to login in single user mode centos 6.0, it’s asking to enter root password or control -D, to continue, if I give password it’s not accepting…..can any one help me to come out firm this……olz
Источник