Switching From Windows Command Prompt to Linux Terminal: 7 Things to Know


Linux shells might appear similar to the Command Prompt, but if you’re coming from the Windows command line, there’s a lot to discover about them.

1

Linux Has Multiple Shells

Output of cat /etc/sheels, showing multiple sheels installed on a Linux system.

One difference from the Windows Command Prompt in Linux is that you can choose between multiple shells. While it’s been possible to do so on Windows going back to the MS-DOS days, the ability to switch shells on Linux is much more prominent.

While Bash is the most popular default shell for Linux distributions, there are other shells you can use, such as tcsh, zsh, and fish, among others. They all have their own features. Many of them can emulate the Bourne shell for compatibility with shell scripts needed for administrative tasks. You can choose a different shell with the chsh command.

2

Path Delimiters Are Different

If you look at pathnames in Windows and Linux, you notice that the delimiters are different. In Windows, paths are separated by “\” (backslash) characters, while in Linux and other Unix-like systems, they’re separated by a “https://www.howtogeek.com/” (forward slash or just “slash”) character. This is mostly for historical reasons.

If you’re used to Windows, this might trip you up. Linux commands are also case-sensitive, meaning that lower and upper case characters have different meanings.

3

Linux Shells Are Actively Developed

While Microsoft has largely deprecated the old command prompt in favor of PowerShell, Linux shells are still actively developed. It’s the reason that you can choose from so many shells on Linux today.

The command line isn’t some historical relic but an important piece of software used daily by power users, administrators, and developers. Bugs are being uncovered and fixed, and new features are being added constantly.

4

You Can Run PowerShell From Linux and Linux Shells on Windows

You don’t just have to run PowerShell on Windows or Linux shells on Linux. You can run one from the other.

Powershell directory listing on Linux with dir command.

Microsoft maintains a version of PowerShell for Linux, and you can install it as a shell on most major Linux distros. You can install it using Microsoft’s package repositories for your distribution.

You can also run Linux shells on Windows. The easiest way to do so is to install Windows Subsystem for Linux and then install a Linux distro. As mentioned earlier, most distros use Bash by default but you can change the shell to whatever you want.

You can even install the Linux version of PowerShell on Windows if you want to make things even weirder. So you can run the Linux version of Powershell on Linux on Windows.

With WSL, you can explore Linux from Windows and combine the two.

5

Linux Shells Have Job Control

Placing a sleep process in the background using job control in the Linux shell.

One thing that separates Linux shells from the Command Prompt is that they were built for multitasking from the get-go. The result of this is that modern shells have a feature called job control that lets you put a task in the background while you run other commands.

You can start a command in the background by appending the line on the shell with an & (ampersand) character. For example,

        
some_long_operation &

The shell will run that command in the background and return a job number in square brackets. You can use this to tell the shell what to do with the job.

To bring the back into the foreground, you can use the fg command. By default, fg will bring back the job you just put in the background, but if you have multiple jobs you’ll need to specify a job number prefixed by a % (percent sign). For example, to foreground job 1, type:

        
fg %1

To put a currently running job in the background press Ctrl+Z, then type “bg” at the shell.

6

Linux Has Both Builtin and External Commands

Output of the linnux which command on "ls."

The job control commands I showed you were built in to most modern shells. They’re called “builtins” for this reason. They should work in Bash and zsh.

The reason that shell developers create builtin commands is that it’s often faster to run them than external commands since the shell is already in memory and doesn’t have to be loaded in. Some of the builtin commands are duplicated in conventional Linux programs, and it can be easy to confuse the two. The best option is to read your shell’s documentation and learn what builtin commands it has.

You can also often run a command called which that tells you what kind of command it is. For example, for bg:

        
which bg

The shell will report that it’s a builtin command. In zsh, which is also a builtin command:

        
which which

7

You Have a Choice in Scripting Languages

If you ever had to automate something in Command Prompt, you may have written a batch file, or a .bat from the file extension.

You can also automate tasks with shell scripts. Linux shells are powerful and have many full-blown programming features, such as arrays and hashes/associative arrays. And if you need more capability, you can learn scripting languages like Perl or Python. There will be a lot to keep you busy as you explore the Linux command line, no matter what language you use.



Source link

Previous articleEnter the Trusted Reviews Best in Show MWC 2025 Awards now
Next articleIf BTC Continues to Follow the 2017 Cycle, It Can Cross $1M by Year-End: Van Straten