Windows 10: How do I run a root/admin script at WSL2 shell startup?

Discus and support How do I run a root/admin script at WSL2 shell startup? in Windows 10 Software and Apps to solve the problem; So, on Linux I would put a script in /etc/profile.d, make it owned by root root:root and make it executable. I did all that in my WSL2 Windows 11 shell... Discussion in 'Windows 10 Software and Apps' started by Jeffrey L Cooke, Nov 3, 2022.

  1. How do I run a root/admin script at WSL2 shell startup?


    So, on Linux I would put a script in /etc/profile.d, make it owned by root root:root and make it executable. I did all that in my WSL2 Windows 11 shell and I get this:hwclock: Cannot access the Hardware Clock via any known method. hwclock: Use the --verbose option to see the details of our search for an access method.So, how do I run something as root on WSL2 startup?Have made WSL2 Settings to:- Run the Ubuntu profile as Default- Run the Default profile as Administrator- Run the Ubuntu profile as AdministratorStill broken. The command in the shell script is simply: "/usr/sbin/hwclock -s"--Th

    :)
     
    Jeffrey L Cooke, Nov 3, 2022
    #1

  2. How do I run a root/admin script at WSL2 shell startup?

    So, on Linux I would put a script in /etc/profile.d, make it owned by root (root:root) and make it executable. I did all that in my WSL2 Windows 11 shell and I get this:

    hwclock: Cannot access the Hardware Clock via any known method.

    hwclock: Use the --verbose option to see the details of our search for an access method.

    So, how do I run something as root on WSL2 startup?

    Have made WSL2 Settings to:

    - Run the Ubuntu profile as Default

    - Run the Default profile as Administrator

    - Run the Ubuntu profile as Administrator

    Still broken. The command in the shell script is simply: "/usr/sbin/hwclock -s"

    --Thanks in Advance,

    Jeffrey Cooke
     
    Jeffrey L Cooke, Nov 4, 2022
    #2
  3. How do I run a root/admin script at WSL2 shell startup?

    Hi, I'm Robinson, and I’m happy to help you today.

    You can execute a command as a root when starting the WSL by creating/editing the /etc/wsl.conf (via sudo) with the following:

    [boot]

    command="string of the command that you would like to run"

    You can see more information at these links.

    https://learn.microsoft.com/en-us/windows/wsl/w...

    https://askubuntu.com/questions/1355633/how-to-...

    Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products).
     
    RobinsonSilvestre, Nov 4, 2022
    #3
  4. How do I run a root/admin script at WSL2 shell startup?

    How do I disable root login in WSL2? "wsl -d ubuntu -u root" from Terminal will login to root shell without requiring passwd.

    Is the following behavior correct and expected?

    With WSL2 (Ubuntu 18.4, Windows 10 2004 19041.207), from a non-admin Windows Terminal, I can execute "wsl -d ubuntu -u root" and login to a root shell, without requiring a password (even if a root password is set).

    I just installed the distro. It created a sudo user as described in the manual. If I login with "Ubuntu.exe" it will default to the sudo user and require the configured password.

    From the root shell I "passwd". Exit. Try again "wsl -d ubuntu -u root", and it bypasses any password protection again. Even though it should be set.

    I've been googling this without any definite answers.
     
    diegoag666, Nov 4, 2022
    #4
Thema:

How do I run a root/admin script at WSL2 shell startup?

Loading...
  1. How do I run a root/admin script at WSL2 shell startup? - Similar Threads - run root admin

  2. Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...

    in Windows 10 Network and Sharing
    Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...: Windows 10Hello Is it possible to write a script for either a .bat file, or a CMD shell or Power Shell script, to automate running a single small .exe Snap2HTML.exe over and over again while stating the program parameters. I wish to use a small program called Snap2html...
  3. Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...

    in Windows 10 Gaming
    Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...: Windows 10Hello Is it possible to write a script for either a .bat file, or a CMD shell or Power Shell script, to automate running a single small .exe Snap2HTML.exe over and over again while stating the program parameters. I wish to use a small program called Snap2html...
  4. Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...

    in Windows 10 Software and Apps
    Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...: Windows 10Hello Is it possible to write a script for either a .bat file, or a CMD shell or Power Shell script, to automate running a single small .exe Snap2HTML.exe over and over again while stating the program parameters. I wish to use a small program called Snap2html...
  5. How do I run this python script?

    in Windows 10 Gaming
    How do I run this python script?: https://pypi.org/project/autoeq/How do I run it? Also, what can I do to make sure that my laptop can run the script? Do i need to install any additional things or verify anything?Thanks if you can guide me....
  6. How do I run this python script?

    in Windows 10 Customization
    How do I run this python script?: https://pypi.org/project/autoeq/How do I run it? Also, what can I do to make sure that my laptop can run the script? Do i need to install any additional things or verify anything?Thanks if you can guide me....
  7. Unknown Power shell script running

    in Windows 10 Gaming
    Unknown Power shell script running: Hi,I usually get a brief pop-up for a script that runs at random times as far as I can gather. Its only for a split second, but its a nuisance if I am gaming as my controller is just disabled until I swap out and back to the game window again.I can see that there are several...
  8. Unknown Power shell script running

    in Windows 10 Software and Apps
    Unknown Power shell script running: Hi,I usually get a brief pop-up for a script that runs at random times as far as I can gather. Its only for a split second, but its a nuisance if I am gaming as my controller is just disabled until I swap out and back to the game window again.I can see that there are several...
  9. How do I run a root/admin script at WSL2 shell startup?

    in Windows 10 Gaming
    How do I run a root/admin script at WSL2 shell startup?: So, on Linux I would put a script in /etc/profile.d, make it owned by root root:root and make it executable. I did all that in my WSL2 Windows 11 shell and I get this:hwclock: Cannot access the Hardware Clock via any known method. hwclock: Use the --verbose option to see the...
  10. How to run .sh or Shell Script file in Windows 10

    in Windows 10 News
    How to run .sh or Shell Script file in Windows 10: [ATTACH] [ATTACH]Shell Scripts or .SH files are like batch files of Windows which can be executed in Linux or Unix. It is possible to run .sh or Shell Script file in Windows 10 using Windows Subsystem for Linux. In this post, [...] This post How to run .sh or Shell Script...