[Linux] How to read .bashrc of general user as root user on WSL2 Ubuntu20.04

Development environment

-Host OS: windows10 Home ・ Guest OS: wsl2 Ubnutu20.04

Problems / problems

Changed the default user of wsl to root user to quickly solve problems around container permissions. Then I couldn't use the settings (mainly aliases) I wrote in /home/$USER/.bashrc.

You can copy and write the same settings to /root/.bashrc, but if possible, I would like to use the $ USER settings as they are.

What you want to achieve

Load the settings in /home/$USER/.bashrc into /root/.bashrc and reflect the settings

Implementation method

The implementation method is very easy, and if you write the following process in /root/.bashrc, it's ok (I don't know what to do about the description location. I wrote it first for the time being)

source /home/$USER/.bashrc

Note: The source command is a command that executes the script specified by the argument.

Supplement

If you read the settings of a general user even as a root user, problems may occur and it is a little scary If an error occurs, I will quietly write the setting in /root/.bashrc or create a script dedicated to alias description and read it.

Recommended Posts

[Linux] How to read .bashrc of general user as root user on WSL2 Ubuntu20.04
How to install php7.4 on Linux (Ubuntu)
How to build Java environment on Ubuntu (Linux)
How to install git on Linux such as EC2
[Tips] How to use iPhone as webcam on Linux
How to use Fujifilm X-T3 as a webcam on Ubuntu 20.04
How to register a package on PyPI (as of September 2017)
How to install VMware-Tools on Linux
How to install MBDyn (Linux Ubuntu)
How to install Go on Ubuntu
How to install aws-session-manager-plugin on Manajro Linux
How to read pydoc on python interpreter
How to install CatBoost [as of January 2020]
How to update php on Amazon linux 2
How to install python package in local environment as a general user
How to display emoji on Manjaro Linux
How to install packages on Alpine Linux
How to install Anisble on Amazon Linux 2
How to update security on CentOS Linux 8
On Ubuntu Linux, set Tab to q
Verification of how to periodically execute a script on a Linux server on Windows
How to find large files on Linux
How to access the contents of a Linux disk on a Mac (but read-only)
How to run GUI programs such as tkinter in Python environment on WSL2
[Latest] How to build Java environment on Ubuntu
How to update security on Ubuntu 19.10 Eoan Ermine
How to install Camunda Modeler on Manjaro Linux
How to read original data or external data on the Internet with scikit-learn instead of attached data set such as iris
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
How to use C216 Audio Controller on Arch Linux
How to install Linux on a 32bit UEFI PC
Linux user addition, how to use the useradd command
How to allow nologin users to log in on Linux
[Note] How to give sudo authority to user on CentOS
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
[AWS EC2] How to install Maven on Amazon Linux 2
How to build a Python environment on amazon linux 2
[AWS] How to expand disk space on Amazon linux
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
How to display a specified line of a file or command result on Linux (sed, awk)
How to read PyPI
How to read JSON
[Ubuntu] How to delete the entire contents of a directory
How to build a new python virtual environment on Ubuntu
[Linux] [C / C ++] Summary of how to get pid, ppid, tid
Add Linux user, how to use useradd command (password specification)
How to create an ISO file (CD image) on Linux
[Linux] How to disable automatic update of /etc/resolv.conf file (Redhat)
How to execute Linux commands on Windows by people who do not know Linux (ubuntu) [Until checking the operation of R and python]