Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Shell Equivalent in Different Operating Systems

Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives.

Fish Shell is preferred to Bash/Zsh. The following content is for Bash/Zsh only.

It suggested that you use IPython shell instead of Bash/Zsh shells. Please refer to IPython Is the Best Shell for detailed discussions. If you have to use shell commands, it is suggested that you use Linux commands when possible as Linux command are more universal and useful. You can achieve this by using WSL 2 on Windows and by using Docker or virtual machine on macOS.

OSCommand
Set PATHLinux/Unixexport PATH=/new/path:$PATH
Windows PowerShell$env:Path += ";.\swigwin-4.0.1";
Get location
of a command
Linux/Unixwhich command_name
Windows PowerShellGet-command command_name
Windows CMD[1]where command_name
Add user
to a group
Linuxsudo gpasswd -a user_name group_name
macOSsudo dseditgroup -o edit -a $username_to_add -t user admin
WindowsNA
Compress/Decompress ArchivesLinux/UnixCompress and Decompressing Archives in Linux
Windows PowerShellExpand-Archive .\swigwin-4.0.1.zip .;
Download a fileLinux/Unixcurl -sSL http://file.example.com -o output
wget http://file.example.com -O output
Windows PowerShell(New-Object System.Net.WebClient).DownloadFile("http://prdownloads.sourceforge.net/swig/swigwin-4.0.1.zip","swigwin-4.0.1.zip");
Watch a commandLinux/Unixwatch command_to_watch
WindowsWatch for changes with PowerShell
Manage partitions of a diskLinuxfdisk
macOSfdisk [2]
Windowsfdisk (via WSL 2 or virtual machine)

[1] Windows CMD command might not work well in Windows PowerShell. For example, the where command sometimes works but sometimes doesn’t work in a PowerShell. Since PowerShell becomes more popular than Windows CMD, Get-command is recommended over where.

[2] The macOS version of fdisk does not function similar to the Linux version of fdisk. It is not as intuitive and easy to use as the Linux version. It is suggested that you use the Linux version of fdisk instead.