Opening multiple terminal with remote access - linux

I am using remotely logged in to my work server through SSH. I have to work on terminal and it will be helpful if I can pull up multiple terminal to access multiple directories and files. How can I do that? I am a beginner. So, any help will be greatly appreciated.

screen is a great tool for this.
screen -m
will open a daemonized screen window and you can detach it to return to your primary shell with
Ctrl+A , then press D
To resume the screen use
screen -r
You can create multiple screens with names and resume them individually. Checkout the manpages for more info

You can use "screen" on you server to open more shell session in a "dedicated" environment so you can even disconnect from the server without loosing your shells (in case of idle, for example).
see http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/

Related

Pyautogui on RDP

I am using pyautogui in Windows 10 with Python 3, in a virtual machine accessed by remote desktop.
Unfortunately, the program stops execution when I close remote connection, giving "OSError: screen grab failed".
I've searched for a solution online, but the only workaround that I've found is from this link
Use a remote desktop client that allows you to keep outputting the display, even if you minimise the window/close your PC. I used terminals (https://terminals.codeplex.com/ - not affiliated with them at all just recommending as it solved this issue for me).You can set this up to persist the display, and your code should then run fine.
The problem is that I can't find a setting for persisting display. I've also found this:
pyautogui._pyautogui_x11._display = Xlib.display.Display(
os.environ['DISPLAY']
)
... but it doesn't seems to work either (gives me errors...).
Do you have some workaround to do the trick?
Based on an answer from here:
when you disconnect from RDP, Windows lock the computer and does not render the screen any more so any automation apps which needs GUI fails to work.
To disconnect from RDP without losing the screen you can disconnect using following commands as administrator (its better to make a bat file and run that file as administrator when you need to disconnect from RDP):
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console )
I have resolved using TightVNC instead of remote desktop and detaching mouse cursor.

Screen process hangs in cygwin

I'm trying to run screen (version 4.0) in the latest version of Cygwin under 64-bit Windows Ultimate, and it doesn't want to work. I launch a new screen session using "screen -d -m -S screen1". When I connect to it using something like "screen -A -d -r screen1" the process hangs. When I list screens with "screen -list" it reports the screen as "possibly Dead".
Any idea how to get screen working in my environment?
I just ran the same commands you did, and had similar problems. But I use screen under 64-bit Windows 7 all the time.
I just use screen to start a screen session, and screen -dr to reattach to the same session later. (I've actually been using screen -U and screen -drU, but I just realized that with defutf8 on in my $HOME/.screenrc, the -U isn't necessary.)
I haven't figured out why your approach doesn't work.
I am also currently trying to get screen work on a cygwin installation on a windows server 2008 installation.
it works in principle, so I can reuse sessions, but its quite buggy:
1.) only sessions started through an rdp session (on the windows desktop) are able to access mounted network shares, sessions started through ssh can only access "c". (okey not really a screen bug, more cygwin in general)
2.) detach doesn't work through ssh. strg+a+d just freezes the terminal, by using these keys in that sequence: [strg+z, bg, %, strg+c] I can get back into the screen session I've last visited.
3.) this leads to the funny state that I can have the same screen session attached multiple times, and see the input and output on all instances

VNC on CentOS 5.5 + Gnome

I have successfully started a vncserver and can connect to it through the browser via 111.111.111.111:5081.
It looks like it's working because I do see the Gnome cursor (X).
However, apart from the cursor I just have a black screen. No taskbar or anything. Right click provides nothing either.
Does anyone have any idea what I need to do to get the full desktop ? I have created a new user and wondered if there is any settings that need changing.
Thanks in advance,
Alex
Your VNC server is running, but there is nothing running in it. No window manager, no desktop environment (GNOME), nothing. The cursor you are seeing is a Xserver cursor, not a GNOME cursor.
That probably means you ran the VNC server directly without using some of the friendly wrapper scripts such as vncserver. For example, if you have tightvnc installed and you run Xtightvnc directly, that's what you'll get.
For example, I usually start a VNC session (or port 5901) like this:
vncserver -geometry 1024x768 :1
Alternately, you can use x11vnc to serve your existing X desktop (instead of starting a new one in the background).

How do I logout from a computer using shell?

How can I log out of my computer using shell such the log-in window appears again?
I need this functionality in one my Linux script.
Update:
I want to replicate the code working behind the Logout button of my Ubuntu.
Desktop Enviroment being used: GNOME
I think this does the job:
gnome-session-save --logout
Also, take a look at the --help output, maybe you want to use the --force-logout option.
Usage:
gnome-session-save [OPTION...]
Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options
Application Options:
--logout Log out
--force-logout Log out, ignoring any existing inhibitors
--logout-dialog Show logout dialog
--shutdown-dialog Show shutdown dialog
--gui Use dialog boxes for errors
--display=DISPLAY X display to use
Your question is a bit vague. Are you trying to log out of a graphical session of a desktop environment (such as KDE/Gnome), as if the user clicked on "log off"?
Then you need to find out if/how the desktop environment supports scripting to log out. On KDE for example you can use kquitapp.
Try restarting the display manager using one of the following, depending one which one you're using. You'll obviously have to have the proper permissions.
/etc/init.d/xdm restart
/etc/init.d/kdm restart
/etc/init.d/gdm restart
It's a bit of a hack, but the way that screen's power detach does this is to determine its parent pid and send it a SIGHUP. (Clarification: This closes only the shell, so only works if you're running from a console - not a graphical login - so may not be what you're looking for.)
Type in terminal
gnome-session-quit
or
pkill -kill -u {Username}

ssh and window ids

I have a project to do in school which is baffeling me... I am SSHing into a Solaris computer in the computer lab from my own Debian box via
ssh -Y name#***.cs.<school>
I can get in just fine, and the X11 seems to be working also. However, this peticular project requires us to find the window id of a netscape window via xwininfo and use this information in the following command
netscape -id 0xa00029 -remote 'openFile(/path/to/html/file)'
Now, if this netscape is the only window I have open (other than xterm), the preceding command works just fine. However, if I have any other iceweasel windows open (regardless of the order in which I opened netscape/iceweasel) the command will forward to my iceweasel despite the facts that I'm running the command in my SSH session and the two windows have very different window ids.
All of this eventually has to go into a C program, but I can't even get it to work reliably manually!
Any ideas?
P.S. I just saw this that may help. When I SSHed via Cygwin/X using the same command, I get this error
Warning: No xauth data; using fake authentication data for X11 forwarding.
Not sure if this is important as I can still use X11 (aparently) perfectly.
Thanks.
P.P.S the -id switch is documented in the netscape man pages:
-id window-id
Identifies an X window to receive -remote commands. If
you do not specify a window, the first window found is
used.
When you use ssh -Y, you're requesting that remote clients be forwarded to your local X server, with full permissions. The Netscape/Mozilla/Firefox/Iceweasel/Etc. remote protocol runs through the X server, so it'll be forwarded too.
http://www.mozilla.org/unix/remote.html documents the protocol, and mentions nothing about -id. Nor does a very quick look at the source (e.g., http://mxr.mozilla.org/seamonkey/source/widget/src/xremoteclient/XRemoteClient.cpp#202) look promising for there being an -id option.
I sat down to an actual machine to perform the same tests, and they all fail there too... I would open 2 netscape windows and try to direct the command to one at a time. The most recently opened one would work properly, but any command directed to the other one would be forwarded to the same window, so at this point I am convinced that the problem lies in the command being not properly implemented and/or everything on that system being really, really old.
if I have any other iceweasel windows
open (regardless of the order in which
I opened netscape/iceweasel) the
command will forward to my iceweasel
despite the facts that I'm running the
command in my SSH session and the two
windows have very different window ids
Iceweasel is coded that way. It tries to have only a single process run for all open windows for that user.
Use the -no-remote command line option to avoid it. See http://kb.mozillazine.org/Command_line_arguments

Resources