Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch users in Cygwin?

Tags:

cygwin

I am trying to switch users in Cygwin using Cygwin's login command. It throws an error saying:

/bin/bash: No such file or directory. Operation not permitted.

I am new to Cygwin. How I can switch between users?

like image 340
user2495173 Avatar asked Aug 27 '13 21:08

user2495173


1 Answers

I don't know why login doesn't work. But I have an easy workaround for this, running cygwin as the desired user, you can use RUNAS or automatize something using PSEXEC.

RUNAS:

runas /user:HOSTNAME\<user> D:\cygwin-64\Cygwin.bat

PSEXEC:

psexec \\HOSTNAME -u DOMAIN\<user> -p <password> D:\cygwin-64\Cygwin.bat

You even can pass commands/run scripts silently to Cygwin like this:

psexec -accepteula \\HOSTNAME -u DOMAIN\<user> -p <password> D:/cygwin-64/bin/run.exe /usr/bin/bash -lic \"/home/username/file.sh\"

Although the question is quite old maybe someone else is looking for this. I've documented this and other options here.

like image 177
Miguel Ortiz Avatar answered Oct 10 '22 07:10

Miguel Ortiz