Language: EN

usar-comandos-de-linux-en-windows

Using Linux Commands in Windows

If you are regular users or system administrators of Linux, you will surely be used to using the terminal and you will know a good number of commands by heart (and if not, you should).

However, no matter how much you are fans of Linux, it must be assumed that sooner or later, either in your work or personal life, you will have to deal with a Windows system. And it must be said that in Windows, just like in Linux, the most efficient way to perform certain actions is still to use the command prompt.

If you are very used to Linux commands and occasionally use the Windows command prompt, you will find the change to be a cumbersome process. On the one hand, you will tend to mix commands, and on the other hand, you will miss some console editing features or Unix utilities that have no equivalent in Windows.

In this post, we will look at various methods to customize the Windows command prompt so that its use is more similar to that of Unix, making its occasional use more enjoyable, while maintaining access to all the power of our system.

Define aliases for commands

The first option we have to customize the Windows command prompt is to set aliases for the most commonly used commands so that we can call them by the same name as their Linux counterparts.

Here is a list of command aliases. To install them, simply open a new console in Windows and paste the following text.

echo dir %1 > %systemroot%\system32\ls.bat
echo notepad %1 > %systemroot%\system32\nano.bat
echo del %1 > %systemroot%\system32\rm.bat
echo move %1 > %systemroot%\system32\mv.bat
echo copy %1 > %systemroot%\system32\cp.bat
echo cls %1 > %systemroot%\system32\clear.bat

You can define your own command aliases, both to make them similar to Linux, and to quickly access the ones you use most often. If you want to delete an alias, simply delete the corresponding bat file from the System32 folder.

Use Powershell

Another option to make our experience in Windows more similar to that of Linux is to use Powershell. Powershell is an object-oriented interpreter that aims to emulate the functionality of the Perl language. It is the successor of the command prompt and, as such, is much more powerful than the traditional command prompt.

PowerShell is built into Windows Vista, 7, and 8 so there is no need to download or install additional software. It is also available in Windows XP, but it is not integrated, so it has to be downloaded for free from Microsoft’s own website.

Third-party solutions

The last option we propose is to use third-party applications that try to make the experience of the Windows command prompt more similar to that of Linux.

There are many similar developments, but from here we propose the following.

Clink adds some of the editing features of the Linux terminal to the Windows command prompt. Among them, it adds improvements in line editing, intelligent command completion, command aliases, better use of the clipboard, undo (Control+Z), and many other features.

It is available at this link.

Cygwin

Cygwin is more than a simple terminal replacement, it is an attempt to integrate Windows and Unix applications. Its installation is really simple and, as a basic functionality, it provides a terminal almost identical to that of Unix, with the same commands and editing capabilities.

It is available at this link.

GNU Utilities For Win32

Finally, if all we want is to have the same commands and utilities as in Unix, without worrying about editing improvements, we can install the GNU Utilities for Windows. These utilities are a collection of common Unix commands ported to Windows. Unlike Cygwin, which runs in an emulation layer, these utilities are executables programmed for Win32 and designed to have the same functionality as their Unix counterparts.

It is available at this link.

Conclusion

Although less well-known than in Linux, the truth is that if you want to make the most of a Windows system, you will have to use the command prompt.

If you are used to the Linux terminal, we have presented various options to customize the prompt and make it more similar to a Unix terminal. There are other third-party applications left out (such as Console2, ConEmu), but their possibilities are similar to those presented.

Personally, my favorite option and my advice is to always use Powershell, which has much superior functionality compared to other consoles, and the command names are similar to Unix. Additionally, we can always define aliases for the remaining commands or for those that we use frequently.

With these two tools (Powershell and customized aliases), you will have a powerful, personalized, and fast-to-use tool, which will allow you to become true experts or system administrators of Windows.