How is Ubuntu’s terminal different from Windows’ cmd.exe?
Does Ubuntu’s standard terminal have the same functions as Windows’ cmd.exe , or does it do different tasks? By that, I mean e.g. whether I can move files or unmount USB devices in both? I know they have different syntaxes. Would you open Ubuntu’s terminal for the same things you would open cmd.exe on Windows or are there common different use cases?
So you ask for a manual to Windows cmd? It is off topic here, isn’t it? I guess you know that you can move files and mount devices in linux 😉
As shown by that last erroneous statement, Ask Ubuntu is not the place for information about command interpreters in Windows. You’d be best off sticking to asking about Ubuntu here.
No, you do not. A question about Terminal does not read «I’m asking if cmd does . » or «would you open cmd for . » or «if you were on Windows . «.
Good question and on-topic IMHO and excellent answer. Both upvoted! I don’t understand the downvotes: OP is just asking about similarities/differences between OSes.
2 Answers 2
cmd.exe is a shell. Bash is a shell. They both interpret and run command-line input in similar (ish) ways, both allow you to run things, and both can interpret scripts based on their relative syntaxes, but those syntaxes is fairly different.
PowerShell is another terminal interpreter from Microsoft. It’s a lot more like Bash in terms of native capability albeit with an even wilder syntax.
In general, Windows’ emphasis has been on providing graphical access to things. A lot of functionality isn’t natively exposed by command line commands. What is has was mostly copied over from MSDOS so everyday things like moving files around is simple enough, but unmounting can take extra applications. I suspect you can do anything with enough searching and installing.
In other words, if I found primed nuclear device and the only interface to diffuse it was a cmd.exe command line, we’d probably all die. I’d take my chances with tar .
Okay, thanks. I wondered if the powers of Terminal were more than that or Cmd. How would you suggest I improve the question?
It’s not clear what you expect the answer to be. I know that sounds silly but do you mean explictly «Can cmd run the same commands as Bash?» or do you mean (as I’ve answered) a more vague «Can you do everything in cmd you can in Bash?» Either way, I’m not entirely sold on the utility of such a question. What are you trying to do?
Bash Guide for Beginners and Advanced Bash-Scripting Guide might be something to look into — at least the latter is very thorough (I have not peeked into the first). You find them here. My opinion/experience: bash is a lot more than cmd.exe — in the state they are «delivered». Install cygwin (www.cygwin.com) on a Windows machine to get a very good bash.
It should also be noted, that neither Bash nor cmd.exe are actually able to perform low-level system tasks like volume (un-)mounting. They can only take commands with the effect to start (arbitrary) external programs, which in turn may be able to perform such tasks.
cmd and terminal are similar in giving a user a text based interface (obviously) and access to certain lower-level utilities for troubleshooting or configuring the systems.
For instance, in my university every time a computer does not seem to allow a user to log in, what does the admin do? Open cmd , and ping the host. That would be the same with terminal.
How would you kill a process that is taking too much memory? In terminal pkill firefox , and in cmd taskkill firefox.exe .
The shell scripting on linux is similar to batch scripting on windows. Here’s grep equivalent on windows. There used to be a command-line text editor running under cmd.exe , called edit but it has been discontinued since windows 7 64 bit version.
So in that respect , yes, you would open cmd and terminal for the same purposes.
The difference however, is that the linux terminal can take on many more tasks, and it’s much more flexible. Even moderate level users can do some simple things in terminal whereas cmd.exe on Windows is more of an admin exclusivity.
linuxwave
To run windows cmd from linux box, there is one tool you could use, which is winexe. You can download the installer from here . There are 2 ways to install this tool:
- Download from here
- Unpack the bz2 file: # bunzip2 winexe-static-081123.bz2
- Change mod to allow execute: # chmod +x winexe-static-081123
- Make soft link in your /usr/local/bin: # ln -s winexe-static-081123 /usr/local/bin/winexe
- Install necessary packages (gcc, svn, *-devel. )
- Get sources from here
- Unpack the source file: # tar -xvjf winexe-source-081123.tar.bz2
- Compile according to README file:
- cd to unpacked tar.bz2 sources
- ./autogen.sh
- ./configure
- make proto bin/winexe
install -s wmi/Samba/source/bin/winexe /usr/local/bin/winexe
where -U for username, -W for workgroup, -n for target machine netbios name, 10.0.0.61 is the ip address of the target machine and cmd.exe is to start windows command prompt.
20 comments:
thanks, aku dah lupe ape name alternative software ntuk psexec ni.
Hi. are you know a new version for winexe? I use Archlinux and now winexe is broken for update on libc6 . i tried compile and nothing
Thanks for the write-up. Works like a charm 🙂
When I compiled the source, I had to change the last command to
sudo install -s bin/winexe /usr/local/bin/winexe
Thought it would be nice to mention it on the off chance it might be useful to someone in the near to medium-distant future.
winexe —interactive 0 —user ditron%ditron // ‘cmd /C dir c:\’
I receive the message:
ERROR: Cannot open control pipe — NT_STATUS_ACCESS_DENIEDThe source machine is a Centos5 pc.
The target machine is a Windows XP Home SP3 pc.When I give the command to another pc, with Windows XP Professional all it’s ok.
Try checking the windows machine’s firewall. Sometimes firewall is blocking the way 🙂
I’ve tried to deactivate the Firewall, but with no success.
In linuxforum people told me that the problem it’s windows xp home that does not allow remote assistance.Yup, maybe it was because of windows version. Microsoft did locked some of the features in their home edition operating systems 🙂
[winexe/winexe.c:120:on_ctrl_pipe_error()] ERROR: Failed to install service winexesvc — NT_STATUS_ACCESS_DENIED
I am using winexe from ubuntu 12.04
and using command to connect to remote windows 7 having admin$ share enabled.winexe -U Pranav -W WORKGROUP -n Pranav-PC//192.168.0.103 «cmd.exe»
and its showing me usage info of winexe command as :-
winexe version 1.00
This program may be freely redistributed under the terms of the GNU GPLv3
Usage: winexe [-?] [-?] [-?] [-?NP] [-?NPV] [-?|—help] [—usage] [-d|—debuglevel DEBUGLEVEL]
[—debug-stderr] [-s|—configfile CONFIGFILE] [—option=name=value]
[-l|—log-basename LOGFILEBASE] [—leak-report] [—leak-report-full]
[-R|—name-resolve NAME-RESOLVE-ORDER]
[-O|—socket-options SOCKETOPTIONS] [-n|—netbiosname NETBIOSNAME]
[-S|—signing on|off|required] [-W|—workgroup WORKGROUP]
[—realm=REALM] [-i|—scope SCOPE] [-m|—maxprotocol MAXPROTOCOL]
[-U|—user [DOMAIN/]USERNAME[%PASSWORD]] [-N|—no-pass]
[—password=STRING] [-A|—authentication-file FILE] [-P|—machine-pass]
[—simple-bind-dn=STRING] [-k|—kerberos STRING] [-V|—version]
[—uninstall] [—reinstall] [—system]
[—runas=[DOMAIN\]USERNAME%PASSWORD] [—runas-file=FILE]
[—interactive=0|1] [—ostype=0|1|2] //host commandwhat should I use as command to get winexe working. That means I should get access to remote windows prompt.
Try:
winexe -U Pranav -W WORKGROUP -n Pranav-PC //192.168.0.103 «cmd.exe»What linux distro are u using? For commonly used distro:
redhat/centos/fedora: yum install
debian/ubuntu: apt-get installhow do you concatenate the output to a log file i tried the -l option with no luck
how do i output to a log file i tried the -l option with no luck
Hello, I still find installation instruction for all linux system but. in windows what I need to install (I mean the «telnet» server side application)
thanksHello,
I still found installation instruction for linux and OSx client, but. in windows where I find the «telnet server» winexe installation files?
I mean, there’s something to install on windows system that listen to the client requests.
Thank for any reply and for sharing this interesting solution.Windows CMD for Linux?
You can download Wine (https://www.winehq.org/) and use the Windows command line tool there that the Wine team has created. However, you will have to go digging through the .wine directory a bit, naturally, to find and execute it as it’s in $HOME/.wine/drive_c/Windows/System32/cmd.exe if memory serves.
Solution 2
You can type «wine cmd» (without quotations) in the terminal and it will use DOS commands and have DOS backslashes with Z as root. If you have Wine, of course.
Related videos on Youtube
Ivan Santiago
Software Engineer. Over 20 years experience in user-support and programming. Working full-time as Software Engineer for Daisy Digital. Research assistant / librarian for, and contributor to, the History of Programming Languages (HOPL).
Updated on September 18, 2022
Comments
Let us assume that I am not in my right mind, as no one who has used a good shell like bash , fish or oh (or any of the other shells listed here) would want this. Nevertheless, seeing as one can have bash on Windows, has anyone tried to create CMD.EXE for Linux? If so, where can I get it from, and if not, why hasn’t anyone done this? I’m asking here because Google searches make assumptions about what I’m asking (probably because no one in their right mind would ask in the first place.)
What can cmd.exe do what Linux command line can not? Well, it can run .cmd scripts for one. That can be useful if you have a lot of scripts that you don’t want to rewrite.
Well, arguments are completely different between cmd.exe and Unix shells. For starters, DOS/Windows uses «/» instead of «-» to introduce options.
Alternatives to cmd.exe for Windows Subsystem for Linux
I started using Linux Subsystem for Windows, and it is Rad! But, it is running in a terminal which behaves like cmd.exe (yuk!). This carries with it everything I hate aobut cmd. e.g., copy & paste, window sizing, etc. I don’t know how in 2018, Microsoft has allowed this to still exist. Here are some alternatives: Alternative Windows shells, besides CMD.EXE? How do I run Ubuntu, Linux Subsystem for Windows in an alternative command prompt?
WSL processes use a Windows console (i.e. conhost.exe), which is only related to the CMD shell in that CMD also (usually) runs attached to a Windows console, as does every other console program (e.g. powershell.exe, cscript.exe, python.exe, etc). If you’re using WSL, then you must be using Windows 10, which has significantly improved the way the console works with window resizing (including text reflowing and fullscreen support) and clipboard access, assuming it’s configured for this in the console window properties and/or default properties.
CMD is shell and ConHost is console which are different than terminals. WSL has no relation with CMD. If you want posix like environment then use cygwin/mintty in wsltty. If you want in depth of WSL check out my repo WslReverse.
@eryksun, in powershell, I can use ctrl-c, ctrl-v. How do I get that functionality in ubuntu-wsl? It is maddening to have to right-click-title-bar > edit > copy.
This issue was addressed already with a new option that allows the console to consume Ctrl+Shift+C/V for copy and paste, even when the console is doing a low-level read. If you’re using an older version of Windows 10, I suggest enabling quick-edit mode, which lets the console consume mouse events for text selection and right-click paste. Note that these are optional console modes since they can interfere with applications that need unfiltered keyboard and mouse input.
Watch out with quick-edit mode enabled. It’s easy to accidentally select text. The console blocks some operations, such as writing to the screen, while there’s an active selection, so a single-threaded console application will block until the selection is cleared.