SOLVED

PowerShell cannot copy files on Linux platform

Occasional Contributor

When I try the following code

Copy-Item /etc/sudoers ./sudoers

Suddenly, an error is reported as follows

fsq2018_0-1651220405574.png

How can I solve it?How can PowerShell obtain root permission under Linux platform?

5 Replies
You can run PowerShell on Linux in 'Run as Administrator' mode by running sudo pwsh, that way you can copy the file
Did this work out for you?

@Harm_Veenstra It works out as shown in the follwing figure.

Snipaste_2022-05-03_10-44-32.png

But it reopens a 'pwsh' process to run commands.

How to run commands without restarting a 'pwsh' shell process.

best response confirmed by fsq2018 (Occasional Contributor)
Solution
You can start your initial pwsh sessions running it sudo pwsh. This is the same on Windows if you want to do admin things, you have to run PowerShell as Administrator (Right-Click, Run as Administrator)