DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Shell (e.g. Bash) users before coming to Windows Terminal - which shell do you use?

Do you use PowerShell or cmd.exe? Or something else, like Git-bash or WSL?

How do you learn commands? PS and cmd.exe have different commands.

Some of commands I need are

  • which => Get-Command
  • head (I don't need cat) => gc log.txt | select -first 5

Top comments (7)

ducaale profile image
Mohamed Dahir

If you have wsl1/wsl2 installed, any commands from wsl can be used in Windows land if you prefix it with wsl e.g wsl touch file.txt.

patarapolw profile image
Pacharapol Withayasakpunt • Edited

Thanks. I totally forgot that I can do that, no matter cmd.exe or PowerShell.

wsl which python # /mnt/c/Users/Pacharapol W/.pyenv/pyenv-win/shims/python
Enter fullscreen mode Exit fullscreen mode

Surprisingly, this points to the correct answer.

Not to mention that these are useful

wsl du -sh *
wsl head bigfile.csv
Enter fullscreen mode Exit fullscreen mode

Though, I personally don't get the purpose of wsl touch new.txt. I know it creates or modifies timestamp, but why?

ducaale profile image
Mohamed Dahir • Edited

I only have used the touch command to create new files. I am not sure either what is the purpose of modifying file timestamps.

shadowtime2000 profile image

I use cmd.exe and occasionally Git-bash when it is required for a projects build setup or something. I rarely use commands other than mkdir and cd because I mainly just use Yarn or NPM CLI commands along with code .

ahferroin7 profile image
Austin S. Hemmelgarn

For stuff that actually has to be run on Windows, PowerShell. It has default aliases that make it easier to adapt to from POSIX sh, and it’s far more capable than CMD even if you do have to quote things more.

In all other cases, I just boot into Linux when I need a shell environment for something...