Linux: Access directly to the shell in case of boot failure

Why

Sometimes, we mess up with Ubuntu (for example), then we are not able to boot to the graphical user interfaces. We may fix the issue with the command line, but we cannot access the command line because of failures during boot time.

In this case, we can edit the grub boot option, to access the shell. Then we made changes, then reboot.

With this trick, we can even reset the root password without remembering the current password.

How

When the grub shows the menu of operating systems to boot, press e to edit the menu of current entry.

Find the line that contains linux... vmlinux ... ro. We need to:

  1. ro => rw Any change has to be writen to the system.
  2. add init=/bin/sh
  3. Press Ctrl + X to boot

That’s it. If you know this trick, you are probably know how to fix your own issue.

I guess anyone who jumps into this post via search engine just doesn’t remember the exact parameter, but they know how already. Please comment if this post help you 🙂

InRelease’ changed its ‘Suite’ value from ‘testing’ to ‘stable’: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

If someone gets it as well then the solution is relatively simple. Run apt-get --allow-releaseinfo-change update

Before

x@pi-server-02 î‚° /etc/apt î‚° sudo apt-get update
Hit:1 https://download.docker.com/linux/raspbian bullseye InRelease
Hit:2 https://deb.nodesource.com/node_10.x bullseye InRelease
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Reading package lists… Done
E: Repository 'http://raspbian.raspberrypi.org/raspbian bullseye InRelease' changed its 'Suite' value from 'testing' to 'stable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

After

x@pi-server-02 î‚° /etc/apt î‚° sudo apt-get --allow-releaseinfo-change update
Hit:1 https://download.docker.com/linux/raspbian bullseye InRelease
Hit:2 https://deb.nodesource.com/node_10.x bullseye InRelease                    
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]      
Get:4 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB]
Get:5 http://raspbian.raspberrypi.org/raspbian bullseye/contrib armhf Packages [60.2 kB]                                                                                                                            
Get:6 http://raspbian.raspberrypi.org/raspbian bullseye/non-free armhf Packages [106 kB]                                                                                                                            
Get:7 http://raspbian.raspberrypi.org/raspbian bullseye/rpi armhf Packages [1360 B]                                                                                                                                 
Fetched 13.4 MB in 22s (621 kB/s)                                                                                                                                                                                   
Reading package lists... Done
N: Repository 'http://raspbian.raspberrypi.org/raspbian bullseye InRelease' changed its 'Suite' value from 'testing' to 'stable'

x@pi-server-02 î‚° /etc/apt î‚° sudo apt-get update                           
Hit:1 https://deb.nodesource.com/node_10.x bullseye InRelease
Hit:2 https://download.docker.com/linux/raspbian bullseye InRelease                                           
Hit:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease                                             
Reading package lists... Done

Use different Python 3.x with virtualenv

Why?

for each project, it may have different dependencies, if we upgrade global, some projects may not work.

  • each virtual environments may has a different python version, different python index package (pip)

Prerequisite

install virtualenv with pip: pip install virtualenv

Create a virtualenv, assume all environments stored in ~/Environments

cd ~/Environments
virtualenv --python=/usr/local/bin/python3.8 v38
virtualenv --python=/usr/local/bin/python2.7 v2

Activate a virtual environment: source ~/Environments/v38/bin/activate
Example:

[oracle@localhost prometheus-anomaly-detector]$ source ~/Environments/v38/bin/activate
(v38) [oracle@localhost prometheus-anomaly-detector]$ which python
# /u01/userhome/oracle/Environments/v38/bin/python
(v38) [oracle@localhost prometheus-anomaly-detector]$ which pip
# /u01/userhome/oracle/Environments/v38/bin/pip
(v38) [oracle@localhost prometheus-anomaly-detector]$ pip --version
# pip 20.2.4 from /u01/userhome/oracle/Environments/v38/lib/python3.8/site-packages/pip (python 3.8)
(v38) [oracle@localhost prometheus-anomaly-detector]$ python --version
# Python 3.8.3

Deactivate a virtual environment with deactivate

(v38) [oracle@localhost prometheus-anomaly-detector]$ deactivate 
[oracle@localhost prometheus-anomaly-detector]$ 

Install cyberpanel on Ubuntu 20.04

Basically, we can install cyberpanel just by executing a command as root:

sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)

After that, we can log in by https://<ServerIP>:8090 with username admin and a chosen password


Q: How do I remove port 8090, eg I want to use panel.example.com instead of ServerIP:8090.
A: Follow the guideline here:

  1. create a website for the domain. Eg: panel.example.com
    • configure an A record for panel of example.com to point to <ServerIP>
    • create a new website with domain panel.example.com
      • Select issue SSL option
  2. Update lsws service:
    • append to file /usr/local/lsws/conf/httpd_config.confextprocessor cyberpanel { type proxy address https://panel.example.com:8090 maxConns 100 pcKeepAliveTimeout 60 initTimeout 60 retryTimeout 0 respBuffer 0 }
    restart service: systemctl restart lsws.service
  3. Update rewrite rule:
REWRITERULE ^(.*)$ HTTP://cyberpanel/$1 [P]

FAQ:

  • Get the detault admin password of rainloop with command:
cat /usr/local/CyberCP/public/rainloop.php
  • Change/Reset the admin password of CyberPanel
oot@localhost:~# adminPass 'Newp@55w0rd!'
Admin password successfully changed!