Windows start command in linux

How to execute Windows commands remotely from Linux machine using rdesktop command?

Is it possible to run Windows commands using rdesktop tool in Linux? I tried with rdesktop -s option:

rdesktop -u user -p 10.0.0.2 -s "cmd.exe" 
rdesktop -u user -p'password' 10.0.0.2 -s "C:\WINDOWS\system32\cmd.exe" 

but there is no difference in the RDP session even if I use -s . I’m trying to get a list of RDP sessions using qwinsta /server in Windows from Linux.

It’s probably because only the default admin can do tasks without being promoted to prpceed. Any other account, even with the correct permissions, would be acting as admin.

3 Answers 3

If you have access to the computer, install an ssh server on it. On Linux you can use for example Overlook-Fing to find the IP of the computer. Then you type ssh username@ipaddress into the Linux shell.

Then type the user’s password and you should have access to the computer’s Windows Command Prompt. You could also use telnet but ssh is encrypted.

I don’t have a solution using rdesktop but I use a program called winexe on Linux to execute remote commands on Windows machines. You can get the application from the following URL or use your distribution’s software repository system to install it.

UPDATE: SSL cert is self signed for the sourceforge link above, so I’m providing another link:

Here’s an example of the usage:

winexe -A credentials.cfg //remotehost "qwinsta /server" 

You will want to create a credentials.cfg file with the login information as so:

username=user password=pass domain=workplace 

Only supply the domain if it applies to you. It’s a best practice to not put your login credentials (especially password) on the command line. Try running cmd.exe using the example above if you want an interactive prompt. Nice thing about this approach is that you can use the output of the remote command in your Linux scripts or grep the output.

Источник

Implementing and Using a Microsoft Windows Like ‘start’ Command in Linux

If you’re used to the convenient ‘start’ command at the command prompt in Microsoft Windows, you’re likely to be a little disappointed not having the same functionality in Linux. But it need not be!

What Is start?

If you have used Microsoft Windows for a long time, you likely have found some shortcuts which simplify your work. One such super-handy shortcut is to use the start command at the Command Prompt in Windows.

Читайте также:  Linux просмотр занятых портов

Start is extremely versatile. You can type start . to open a directory browser window right at the location where you are in the command prompt (the current directory). You can also just type start notepad , and it will open the notepad application for you, and so on. You can even do things like start mypdf.pdf , and it will open your default-type-assigned application for opening PDF files! Handy.

Then you move to Linux and expect the same great functionality to be there. But not so:

The start command by default is not available in Linux

Start is not a default command in Linux. Still, Linux, much more so than Microsoft Windows, allows us to tweak our systems just the way we like them, even to near-infinity. Linux offers control where Microsoft does not. So, let’s implement our own start.

Re-implementing start on Linux!

Re-implementing start on Linux is easier then you think. Here are two methods. The first one is likely to work more universally on various Linux distributions, whereas the second is more Linux Mint and Ubuntu focused.

The first one uses the xdg-open . Two commands are needed to re-implement start :

sudo apt install xdg-utils echo "alias start="xdg-open"" >> ~/.bashrc

Note: if you use Fedora, RedHat, or Centos instead of a Debian-based distribution, you may use sudo yum install xdg-utils instead of the first line.

The first command will install the xdg-utils package, enabling us to use the command xdg-open . It is likely that xdg-utils is already installed on your system, and trying to do so again will not damage the operating system in any way.

The second command adds an alias to our personal Bash startup script (the hidden file ~/.bashrc ) in which xdg-open is called whenever start is executed at the command line. Note one could also type xdg-open , but I much prefer the shorter and more familiar start .

After making these changes, exit your shell and re-open it. You should now be able to use start in – for all intents and purposes – the same manner as you would in Microsoft Windows:

The start command re-implemented in Linux

There may be some minor differences in operation; for example, if you execute a command like start text.txt where such a file exists, a file manager with that file highlighted (requiring an additional double click) may open instead of opening the assigned application.

There are minor differences between xdg-utils and exo-utils (described below) in this way, and it depends on your underlying desktop window manager and it’s file type association settings also.

Test what works best for you, and set correct file type associations in your operating system to maximize the minor differences. You can do so by right-clicking a file and selecting options alike to Open With > Other Application > selecting an application and making it default. There may also be a file type configuration screen available in your Linux Distribution.

Note that the first time you run commands this way you may be presented with a dialog similar to the following:

Читайте также:  Usb to ttl linux

Selecting a preferred file manager application dialog

In it, simply select your favorite file manager. For more information on how to do this and what sort of options are available here, you may like to review our article Swapping File Managers in Mint 20

If somehow you ran into issues, or you are using Linux Mint or Ubuntu and would like to try another possible solution, you can try this alternative solution which uses exo-utils , a package originally attached to the xcfe desktop window manager, but also usable on, or in conjunction with, other windows managers!

For our second solution, two commands are needed to re-implement start :

sudo apt-get install exo-utils echo "alias start="exo-open --launch FileManager"" >> ~/.bashrc

The first command installs the exo-utils , in a similar fashion to our install of xdg-utils . The second command will add the line alias start=»exo-open —launch FileManager» to ~/.bashrc again in a similar fashion as our first solution. The command required here is slightly more complex, but things work in exactly the same way.

Wrapping up

Having start available in Linux, especially when you tend to use the terminal command line a lot, makes the blend between the text-based terminal and the desktop windows manager definitively better.

Once you use the solution for a while, different ways of using it will become more apparent, and your computer use efficiency and operator skills will significantly improve.

bash-g7e49ecd90_1280.png

Linux or Windows for eCommerce?

An operating system is the most important component for eCommerce success. The software manages the system’s memory, hardware, all software,…

Why is the Linux/Unix Terminal Case-Sensitive?

As we navigate the digital world, one of the fundamental principles that we encounter, often without even realizing it, is…

1687764991_sudo-history-01-auth-log-command.png

How to Check Sudo History in Linux

When sharing your computer with others, and you’ve granted them sudo access, it’s prudent to monitor how they’re using it.…

Best Linux Distributions for SMBs and MSPs

Operating systems form the heart of any IT infrastructure. So when it comes to small and medium-sized businesses (SMBs) and…

1687755781_python-swapvalue.png

10 Useful Python One-Liners You Must Know

Although it’s pushed well past the 30-year mark since its release, Python remains one of the most relevant high-level programming…

1687753168_emacs-latex-02-latex-website.jpg

How to Create LaTeX Documents with Emacs

Emacs is often thought of as a programmer’s text editor. It has an extensible programming support as well as the…

1687746901_word-image-19607-1.png

cp command on Linux

Linux, a powerful open-source operating system, is known for its flexibility and control. A key component of Linux’s power lies…

1687745646_Ubuntu-cant-open-terminal-add-to-favorites.jpg

How to Fix Ubuntu Can’t Open the Terminal Issue

You can’t get the terminal in your Ubuntu machine to open. What can you do? While this issue seldom happens,…

Digital Audio Workstations (DAW) for Linux

The music production world is experiencing a massive shift, and with this comes the increased use of Digital Audio Workstations,…

Is Linux Good for Music Production?

Have you ever wondered what kind of operating system music producers prefer? While Mac and Windows have their supporters, Linux…

Читайте также:  Сколько весит арч линукс

Источник

How to use start command in bash on Windows

I want to use Windows’ start command in bash on Ubuntu on Windows (i.e., WSL). However, I couldn’t use it by simply typing start :

nek@NEK:/mnt/c/Users/Nek$ start test.txt Command 'start' is available in '/sbin/start' The command could not be located because '/sbin' is not included in the PATH environment variable. This is most likely caused by the lack of administrative privileges associated with your user account. start: command not found 
C:\Users\Nek>where start INFO: Could not find files for the given pattern(s). 

Environment

  • Windows 10 build 14393.693 (Update: This version is old for executing .exe files on bash. I should update Windows build >= 14951, and then follow the answer.)
  • Bash on Ubuntu on Windows (bash 4.3.11(1)-release x86_64-pc-linux-gnu, Ubuntu 14.04)

3 Answers 3

In other answers, cmd.exe is suggested. However, the Command Prompt does not support UNC paths. The Linux file system in WSL2 is represented as UNC paths in Windows.

In this case, the better alternative is PowerShell. Borrowing from Alex G’s function, it is re-written as:

If you have disabled the addition of Windows PATH by adding [interop] appendWindowsPath = false to /etc/wsl.conf , then use the absolute path gotten by where powershell.exe :

Add this to your .bashrc to make sure you have it in every session.

  • start . — Opens the current directory in Windows File Explorer.
  • start /any/linux/path — Opens the Linux directory as a UNC path.
  • start /mnt/c/any/windows/path — Opens the Windows folder as a regular path.
  • start — Forces the PowerShell command to prompt you for a path. Type one in, such as . or a Windows/UNC path (Linux paths won’t work here) or press Ctrl-C to cancel.
    • Perhaps the function can be enhanced to take care of this edge case. I leave that to you as an exercise.

    Is start a builtin command?

    Internal commands

    The Windows CMD shell CMD.exe contains a number of ‘internal’ commands, additional ‘external’ commands are also supplied as separate executable files. External commands are generally stored in the C:\WINDOWS\System32 folder, this folder is part of the system PATH .

    This arrangement means that both internal and external commands are always available no matter what your current directory happens to be.

    ASSOC, BREAK, CALL ,CD/CHDIR, CLS, COLOR, COPY, DATE, DEL, DIR, DPATH, ECHO, ENDLOCAL, ERASE, EXIT, FOR, FTYPE, GOTO, IF, KEYS, MD/MKDIR, MKLINK (vista and above), MOVE, PATH, PAUSE, POPD, PROMPT, PUSHD, REM, REN/RENAME, RD/RMDIR, SET, SETLOCAL, SHIFT, START, TIME, TITLE, TYPE, VER, VERIFY, VOL

    Can we use start in bash?

    Yes. Start a command shell and run the start command.

    If this doesn’t work specify the full path as follows:

    /mnt/c/Windows/system32/cmd.exe /c start "" test.txt 

    Further Reading

    • An A-Z Index of the Windows CMD command line — An excellent reference for all things Windows cmd line related.
    • cmd — Start a new CMD shell and (optionally) run a command/executable program.
    • start — Start a program, command or batch script (opens in a new window).

    Источник

Оцените статью
Adblock
detector