phyver / GameShell

a game to learn (or teach) how to use standard commands in a Unix shell
GNU General Public License v3.0
2.17k stars 138 forks source link

run as a root #90

Closed arthur1573 closed 2 years ago

arthur1573 commented 2 years ago

Good game, well done.

I used windows subsystem for linux to play this game

These commands worked for me

phyver commented 2 years ago

I've never used WSL, so I might be wrong, but you should be able to download and run GameShell as a normal user. Are you sure you tried running the first command (wget ...) from a directory to which you had read/write access?

Also, you should be able to run GameShell as root: it should give you an error message.

Can you run the following from WSL and give me the result?

 $ sudo id -u
 $ sudo whoami
arthur1573 commented 2 years ago

Please do not say you might wrong, because I am the noob one , you are the author one.

I tried to run GameShell as a normal user, and the first command (wget ...) did not work. Just like the pictures showed below. 220602

Actually, I do not know how to check a normal user's read/write access right now. By the way, I know how to check a file's access by your taught way.

Furthermore, I reckon you say: I should NOT run as a root. So, I will try to run as a normal user next time.

Of cause I will show your the result: Screenshot 2022-06-02 004417

one more thing, here is the way how I run WSL if you are interested: // open Command Prompt(Admin), run cmd, and auto install ubuntu 2004.2022.1.0 wsl --install

phyver commented 2 years ago

The problem seems to be that you are trying to to download the file into a directory where you don't have write permissions. (cannot write to 'gameshell.sh'). The (Success) is quite misleading!

Once you've downloaded gameshell.sh as root, you need to be root to run it. But GameShell should complain:

 $ sudo bash ./gameshell.sh
 Error: you shouldn't run Gameshell as root!

Doesn't that happen with you? (I fixed a minor thing there. It shouldn't make any difference, but who knows?)

I don't know how home directories are dealt with in WSL, but what happens if you run cd (without argument) before trying to download GameShell with wget ...? Or if you run cd /tmp to run GameShell from the /tmp directory?

arthur1573 commented 2 years ago

Yes, this is correct I do not have write permission when I mkdir a new folder.

I followed your advice that trying cd /tmp before download GameShell, it works: Screenshot 2022-06-02 104335 Screenshot 2022-06-02 103755

And the GameShell does complain: Screenshot 2022-06-02 104546

Furthermore, I go old version GameShell, and figure out the game was not on the same page we are reading. I used this command: wget https://github.com/phyver/GameShell/releases/download/v0.3.1/gameshell.sh but your README file recommenced this command: wget https://github.com/phyver/GameShell/releases/download/latest/gameshell.sh

The old version(v0.3.1), first command, it does support root user to run it: Screenshot 2022-06-02 110310

But this is not a big deal, right? Since now, I can run the GameShell as a normal user.

Thank you for your wise comments. I will soon close this pull request.