You can connect form an Ubuntu 22.04 host as:When in but be aware of: Raspberry Pi Pico W freezes a few seconds after after screen disconnects from UART.
screen /dev/ttyACM0 115200screen, you can Ctrl + C to kill main.py, and then execution stops and you are left in a Python shell. From there:- Ctrl + D: reboots
 - Ctrl + A K: kills the GNU screen window. Execution continues normally
 
Other options:
- ampy 
runcommand, which solves How to run a MicroPython script from a file on the Raspberry Pi Pico W from the command line? 
Ciro Santilli