Skip to content

itzmetanjim/mkcd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mkcd_logo

MKCD - Linux Utilities for Windows

PyPI Downloads PyPI - Downloads Static Badge PyPI - License PyPI - Python Version Static Badge

Have you ever typed ps | grep edge or wget https://example.com or some other command with Linux utilities, only to find out you are in windows and have to use the stupid PowerShell syntax that no one knows about? You may even be tricked into thinking the command exists because of PowerShell aliases that are nonfunctional. That's why MKCD exists. MKCD brings over 100 essential Linux utilities directly to your Windows command line with native executables. No virtual machines, no containers, no hassle.

To install, go to Installation.

Why MKCD? Comparision

Comparing with the alternatives:

  • MSYS2/Git bash You have to use a seperate terminal/shell
  • BusyBox A seperate terminal/shell is recommended, you have to type busybox before your commands. (busybox grep instead of grep)
  • GNU Coreutils Sketchy, hard to install, not many utilities (MKCD has all of them and more), but mainly hard to install.
  • WSL Slow, uses loads of ram + storage, env issues, too many issues to list. But if you need an actual linux environment, this may be a good option (apart from a server)

MKCD actually uses MSYS2 (and as such, Coreutils) as sources for some of the utilities.

Included Utilities

Most Common grep, awk, sed, find, curl,ls,tar,gzip,wget,cat,ps,kill,cp,mv,rm,mkdir,rmdir

Text processing & filtering awk, gawk (another implementation of awk), sed, grep (find a piece of text), rgrep (recursive grep), cut, paste, join, tr, rev, fmt, fold, expand, unexpand, column, comm, csplit, split, shuf, sort, uniq, tsort, seq, head, tail, tac, nl

File & directory operations ls, cp, mv, rm, rmdir, ln, mkdir, mktemp, touch, install, realpath, pathchk, pwd (print working directory), find, locate

Compression & archives tar, gzip, gunzip (compatibility via gzip/uncompress functionality), bzip, bzip2, bunzip (bzip unzip), bunzip2, bzcat, compress, xz, xzcat, unxz, zstd, unzstd, split

Checksums, hashing & encodings cksum, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, base32, base64, numfmt

System, processes & scheduling ps, kill, nohup, timeout, time, sync, nproc, uname, who, users, groups, id, logname, env, printenv

Disk & filesystem info df, du, stat, truncate

Networking & transfers curl, wget, ftp, telnet

Viewing, paging & editors cat, less, more, nano, hexdump, od

Scripting helpers & shell utilities perl, expr, test, xargs, tee, tput, true

Lookup & diagnostics which, whereis, file

Miscellaneous date, cal, paste, comm, pathchk, install, mktemp, tput, tsort

...and more

No learning curve. No compatibility issues. Just the Linux tools you know and love, running natively on Windows.

Installation

Getting started with MKCD is straightforward, but there are a few important steps to follow:

Note: ls, cat, curl, etc are mapped as aliases in PowerShell (which can cause confusion when you type something like ls -la), but they are removed and readded automatically on install/uninstall.

Step 1: Install the Package

pip install mkcd

Step 2: Run the Installer

mkcd-install

If Python scripts are not on PATH, you can run this instead. **However, it's highly recommended to add them to PATH for this. Check How to add Python scripts to PATH.

python -c "import mkcd;mkcd.install()"

Important: You must open a completely new terminal window for the changes to take effect. Simply opening a new tab in Windows Terminal may not work - you need to close and reopen the entire application. If commands still aren't recognized after opening a new terminal, a system restart may be required.

It will ask for permission to launch a UAC window. Type "y", hit enter, then click "Yes" in the window.

Example Output:

Installing mkcd utilities...
Found 61 executables and 20 DLL files
Checking for conflicting PowerShell aliases...
Found 9 conflicting aliases
Conflicting PowerShell aliases detected:
  cat -> Get-Content
  cp -> Copy-Item
  ls -> Get-ChildItem
  mv -> Move-Item
  pwd -> Get-Location
  rm -> Remove-Item
  rmdir -> Remove-Item
  sort -> Sort-Object
  tee -> Tee-Object
Removing 9 conflicting PowerShell aliases...
Updated PowerShell profile: C:\Users\hp\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
  Removed alias: cat -> Get-Content
  Removed alias: cp -> Copy-Item
  Removed alias: ls -> Get-ChildItem
  Removed alias: mv -> Move-Item
  Removed alias: pwd -> Get-Location
  Removed alias: rm -> Remove-Item
  Removed alias: rmdir -> Remove-Item
  Removed alias: sort -> Sort-Object
  Removed alias: tee -> Tee-Object
System PATH modification requires admin privileges.
System PATH modification requires administrator privileges.
This will spawn a new elevated command prompt window.
Would you like to request admin privileges? (Y/n): Y
Requesting administrator privileges...
Please click 'Yes' in the UAC dialog that appears.
Admin privileges granted. Operation running in elevated window...
Please check the elevated command window for results.
System PATH modification attempted in elevated window.
Falling back to user PATH for current session...
NOTE: To add manually, type in PowerShell: $env:Path += ';D:\SYSPY\Lib\site-packages\mkcd\_bin\windows_x86_64'
or in CMD: setx PATH "%PATH%;D:\SYSPY\Lib\site-packages\mkcd\_bin\windows_x86_64"
Successfully added to user PATH: D:\SYSPY\Lib\site-packages\mkcd\_bin\windows_x86_64
Note: You may need to restart your shell for changes to take effect. In tabbed terminal emulators like Windows Terminal, you will have to open and close the entire app, not just the tab.
Installation complete! Linux utilities are now available in your shell.
Available commands: ls, cat, grep, sed, gawk, tar, gzip, and many more.
Try running: ls --help

Troubleshooting

Commands Not Found After Installation

  • Make sure you opened a completely new terminal (not just a new tab)
  • Try restarting your computer
  • Check if the installation succeeded by running mkcd-install again. Or, type mkcd-uninstall to uninstall then reinstall using the install command.
  • Add Python scripts to PATH

ls and grep not being colorized or not working

This may be because your python scripts are not in PATH. To add them to PATH, check the section below.

How to add Python scripts to PATH

First type this in PowerShell/CMD to find your Python installation:

python -c "import sys; print(sys.executable)"

Your output should be like this: C:\Python39\python.exe, ending in python.exe. Remove the python.exe part, and add Scripts\ to the end. In this example, it would be C:\Python39\Scripts\. Copy this new scripts path.

Search for Edit the system environment variables in your search bar, hit Enter, then click Environment Variables. In both the "User variables" and "System variables", find where the variable name is Path, then click "Edit" > "New", then paste your copied path. Move it up, anywhere above the listing that contains "windows_x86-64" or similar. Click "Ok" > "Ok".

You can also run the following command in PowerShell:

$env:Path += ';' + "<your script path>"

No matter which method you choose, make sure to restart your terminal for the changes to take effect.

Uninstalling

To remove MKCD utilities from your PATH:

mkcd-uninstall

Some utilities like ls and grep may stay. This is because they are linked as a script for colorization. Running the previous command will not delete the binaries from your computer.

You will need admin privileges.

To completely remove the package:

pip uninstall mkcd

Requirements

  • Windows 10 or later
  • Python 3.9 or higher
  • Administrator privileges (for installation only)

License

MKCD is released under the MIT License. See the LICENSE file for details.

The MSYS2 project, which provides some of the underlying tools, is licensed under the GNU General Public License v3.0 (GPL-3.0). MKCD does not include any GPL-licensed code; it uses the MSYS2 environment to compile and run the utilities.

About

Get all linux utilities like grep,head,tail,etc in Powershell and CMD directly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages