User Tools

Site Tools


cluster-linux

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cluster-linux [2024/05/26 10:59] gabrielecluster-linux [2024/05/26 11:17] (current) gabriele
Line 7: Line 7:
   - Common Commands   - Common Commands
   - Text editing in command line   - Text editing in command line
 +  - Displaying images in command line
 +  - Displaying images from command line (using X11 forwarding)
 +  - Displaying NIFTI images in command line
 +  - X11 Forwarding
  
  
Line 139: Line 143:
  
 ===== 4. Displaying images in command line ===== ===== 4. Displaying images in command line =====
-The easiest way to display images is to use niicat (see [[https://github.com/MIC-DKFZ/niicat?tab=readme-ov-file|here]]). For that, you would not need an X11 forwarding connection (see X11 forwarding), as it prints the image in your terminal using libsixel. niicat can display niftii, png, jpg, or similar images. Importantly, though, to display images with niicat, you need to work on a terminal that supports sixel (see here).+The easiest way to display images is to use ''niicat'' (see [[https://github.com/MIC-DKFZ/niicat?tab=readme-ov-file|here]]). For that, you would not need an X11 forwarding connection (see X11 forwarding below), as it prints the image in your terminal using [[https://github.com/saitoha/libsixel|libsixel]]''niicat'' can display niftii, png, jpg, or similar images. Importantly, though, to display images with ''niicat'', you need to work on a terminal that supports sixel (see [[https://github.com/saitoha/libsixel#terminal-requirements|here]]).
  
-For macOS, you could use iTerm2. Once installed, open iTerm2 and establish an ssh connection to the remote desktop (see Cluster access). For example: +For macOS, you could use [[https://iterm2.com/index.html|iTerm2]]. Once installed, open iTerm2 and establish an ssh connection to the remote desktop (see [[cluster-access|Cluster access]]). For example: 
  
-ssh gbellucci@psychp01.rhul.ac.uk+  ssh gbellucci@psychp01.rhul.ac.uk
  
-Now, suppose that you have a NIFTI image named anatomical_brain.nii in the folder fmri_results in your home home/gbellucci. You can open the image like that:+Now, suppose that you have a NIFTI image named ''anatomical_brain.nii'' in the folder ''fmri_results'' in your home ''/home/gbellucci''. You can open the image like that:
  
-niicat -lb /home/gbellucci/fmri_results/anatomical_brain.nii+  niicat -lb /home/gbellucci/fmri_results/anatomical_brain.nii
  
-The -lb option tells niicat to use libsixel-bin to display the image in your terminal.+The ''-lb'' option tells ''niicat'' to use libsixel-bin to display the image in your terminal.
  
  
-Displaying images from command line +===== 5. Displaying images from command line (using X11 forwarding) =====
 Another option to open an image saved on a remote server is to establish an X11 forwarding connection to the server and use an image viewer. For that, you need to: Another option to open an image saved on a remote server is to establish an X11 forwarding connection to the server and use an image viewer. For that, you need to:
-1. Ensure you have X11 installed on your local machine (XQuartz on macOS, typically installed X server on Linux). +  - Ensure you have X11 installed on your local machine (XQuartz on macOS, typically installed X server on Linux). 
-2. Enable X11 forwarding when connecting via SSH.+  Enable X11 forwarding when connecting via SSH. 
 For example, first make sure XQuartz is currently running on your machine. Before connecting to the remote server, you can start XQuartz on your local machine by typing the following in a terminal window: For example, first make sure XQuartz is currently running on your machine. Before connecting to the remote server, you can start XQuartz on your local machine by typing the following in a terminal window:
  
-open -a XQuartz+  open -a XQuartz
  
-You then would need to establish a X11 forwarding connection like that (see Cluster access for more information):+You then would need to establish a X11 forwarding connection like that (see [[cluster-access|Cluster access]] for more information):
  
-ssh -X username@remote_server+  ssh -X username@remote_server
  
-For example, suppose your username is gbellucci” and the remote server is psychp01.rhul.ac.uk, you would need to type:+For example, suppose your username is ''gbellucci'' and the remote server is ''psychp01.rhul.ac.uk'', you would need to type:
  
-ssh -X gbellucci@psychp01.rhul.ac.uk+  ssh -X gbellucci@psychp01.rhul.ac.uk
  
-You will be prompted to enter a password. Afterwards, suppose that you have a beautiful image named my_beautiful_result_image.jpg in the folder results in your home home/gbellucci. You can open your image by using fim like that:+You will be prompted to enter a password. Afterwards, suppose that you have a beautiful image named ''my_beautiful_result_image.jpg'' in the folder results in your home ''/home/gbellucci''. You can open your image by using ''fim'' like that:
  
-fim /home/gbellucci/results/my_beautiful_result_image.jpg+  fim /home/gbellucci/results/my_beautiful_result_image.jpg
  
-You can also open your image by using Eye of GNOME, which tend to display images with higher resolution:+You can also open your image by using ''Eye of GNOME'', which tends to display images with higher resolution:
  
-eog /home/gbellucci/results/my_beautiful_result_image.jpg+  eog /home/gbellucci/results/my_beautiful_result_image.jpg
  
  
-Displaying NIFTI images in command line+===== 6. Displaying NIFTI images in command line ===== 
 +To quickly preview neuroimaging images in NIFTI format on the terminal, you can use ''niicat'' (see [[https://github.com/MIC-DKFZ/niicat?tab=readme-ov-file|here]]). For that, you would not need an X11 forwarding connection, as it prints the image in your terminal using [[https://github.com/saitoha/libsixel|libsixel]]. ''niicat'' can display niftii, png, jpg, or similar images. Importantly, though, to display images with ''niicat'', you need to work on a terminal that supports sixel (see [[https://github.com/saitoha/libsixel#terminal-requirements|here]]).
  
-To quickly preview neuroimaging images in NIFTI format on the terminal, you can use niicat (see here)For thatyou would not even need an -X connection, as it prints the image in your terminal using libsixel. niicat can also display png, jpg or similar images. Importantly, though, to display images with niicat, you need to work on a terminal that supports sixel (see here).+For macOS, you could use [[https://iterm2.com/index.html|iTerm2]]. Once installedopen iTerm2 and establish an ssh connection to the remote desktop (see [[cluster-access|Cluster access]]). For example: 
  
-For macOS, you could use iTerm2. Once installed, open iTerm2 and establish an ssh connection to the remote desktopFor example: +  ssh gbellucci@psychp01.rhul.ac.uk
  
-ssh gbellucci@psychp01.rhul.ac.uk+Now, suppose that you have a NIFTI image named ''anatomical_brain.nii'' in the folder ''fmri_results'' in your home ''/home/gbellucci''You can open the image like that:
  
-Now, suppose that you have a NIFTI image named anatomical_brain.nii in the folder fmri_results in your home home/gbellucci. You can open the image like that:+  niicat -lb /home/gbellucci/fmri_results/anatomical_brain.nii
  
-niicat -lb /home/gbellucci/fmri_results/anatomical_brain.nii+The ''-lb'' option tells ''niicat'' to use libsixel-bin to display the image in your terminal.
  
-The -lb option tells niicat to use libsixel-bin to display the image. 
- 
-X11 Forwarding 
  
 +===== 7. X11 Forwarding =====
 X11 forwarding is a feature that allows you to run graphical applications installed on a remote server and display them on your local machine as if they were running locally. The “X11” part refers to the X Window System (version 11), which is a protocol and system for managing graphical displays on UNIX and UNIX-like operating systems. X11 forwarding is a feature that allows you to run graphical applications installed on a remote server and display them on your local machine as if they were running locally. The “X11” part refers to the X Window System (version 11), which is a protocol and system for managing graphical displays on UNIX and UNIX-like operating systems.
  
 This is how it works: This is how it works:
  
-1. Local X Server: Your local machine runs an X server. This is a software component responsible for managing the display and input devices (like keyboard and mouse) for graphical applications.+  - //Local X Server//: Your local machine runs an X server. This is a software component responsible for managing the display and input devices (like keyboard and mouse) for graphical applications
 +  - //Remote Application//: The remote machine runs the graphical application. Instead of displaying the graphical output on the remote machine’s screen, it sends this output to your local X server. 
 +  - //SSH Tunnel//: The graphical output is sent securely over the network using SSH (Secure Shell, see [[cluster-access|Cluster access]]). SSH creates a tunnel between your local machine and the remote server, carrying the X11 protocol data.
  
-2. Remote Application: The remote machine runs the graphical application. Instead of displaying the graphical output on the remote machine’s screen, it sends this output to your local X server.+X11 forwarding is primarily designed for UNIX-like operating systems, such as Linux and BSDHowever, it can also be used on macOS and Windows with some additional setup.
  
-3. SSH Tunnel: The graphical output is sent securely over the network using SSH (Secure Shell, see here). SSH creates a tunnel between your local machine and the remote server, carrying the X11 protocol data.+==== Setting up X11 Forwarding in macOS/Linux ==== 
 +=== Installation ===
  
-X11 forwarding is primarily designed for UNIX-like operating systems, such as Linux and BSD. However, it can also be used on macOS and Windows with some additional setup: 
- 
-Setting up X11 Forwarding in macOS/Linux 
-Installation 
 Linux distributions typically have X11 forwarding support built-in. Linux distributions typically have X11 forwarding support built-in.
 +macOS uses XQuartz, an implementation of the X server for macOS. You need to install and run XQuartz to use X11 forwarding. You can easily install XQuartz via the Terminal using [[https://brew.sh/|Homebrew]]. In a Terminal window, just type:
  
-macOS uses XQuartz, an implementation of the X server for macOS. You need to install and run XQuartz to use X11 forwarding. You can easily install XQuartz via the Terminal using Homebrew. In a Terminal window, just type: +  brew install --cask xquartz
- +
-brew install --cask xquartz+
  
-Setup+=== Setup ===
 The setup of X11 Forwarding is pretty easy in macOS/Linux. The setup of X11 Forwarding is pretty easy in macOS/Linux.
  
-1. Ensure your local machine has an X server running (like XQuartz on macOS). +  - Ensure your local machine has an X server running (like XQuartz on macOS). 
-2. Connect to the remote server with the -X or -Y option:+  Connect to the remote server with the -X or -Y option:
  
 First make sure an X server is currently running on your machine. For instance, if you are working on macOS and use XQuartz, before connecting to the remote server, you can start XQuartz on your local machine by typing the following in a terminal window: First make sure an X server is currently running on your machine. For instance, if you are working on macOS and use XQuartz, before connecting to the remote server, you can start XQuartz on your local machine by typing the following in a terminal window:
  
-open -a XQuartz+  open -a XQuartz
  
-You then would need to establish a X11 forwarding connection like that (see Cluster access for more information):+You then would need to establish a X11 forwarding connection like that (see [[cluster-access|Cluster access]] for more information):
  
-ssh -X username@remote_server+  ssh -X username@remote_server
  
-For example, suppose your username is gbellucci” and the remote server is psychp01.rhul.ac.uk, you would need to type:+For example, suppose your username is ''gbellucci'' and the remote server is ''psychp01.rhul.ac.uk'', you would need to type:
  
-ssh -X gbellucci@psychp01.rhul.ac.uk+  ssh -X gbellucci@psychp01.rhul.ac.uk
  
 For trusted X11 forwarding, you can use the -Y option like that: For trusted X11 forwarding, you can use the -Y option like that:
  
-ssh -Y gbellucci@psychp01.rhul.ac.uk+  ssh -Y gbellucci@psychp01.rhul.ac.uk
  
 Both -X and -Y options allow you to run graphical applications from a remote server and display them on your local machine, but there are important differences in terms of security and functionality. The -X option or untrusted X11 Forwarding is the more secure option because it restricts the level of access that the remote application has to your local X server. Specifically, it limits the remote application’s ability to interact with other X11 clients and monitor or modify your local desktop environment. Even if more secure, with the -X option you might experience restrictions on some functionalities of the remote graphical applications. You can employ the -X option for general use, especially when you are unsure about the security of the remote applications you are running. It helps to prevent potential security risks from untrusted remote applications. Both -X and -Y options allow you to run graphical applications from a remote server and display them on your local machine, but there are important differences in terms of security and functionality. The -X option or untrusted X11 Forwarding is the more secure option because it restricts the level of access that the remote application has to your local X server. Specifically, it limits the remote application’s ability to interact with other X11 clients and monitor or modify your local desktop environment. Even if more secure, with the -X option you might experience restrictions on some functionalities of the remote graphical applications. You can employ the -X option for general use, especially when you are unsure about the security of the remote applications you are running. It helps to prevent potential security risks from untrusted remote applications.
Line 240: Line 241:
 On the contrary, the -Y option enables trusted X11 forwarding, allowing the remote application to have full access to your local X server. It can interact with other X11 clients and modify your local desktop environment, just like a local application. This implies that the -Y option will give you full functionality for remote graphical applications, but it also removes the restrictions imposed by the -X option, which means that applications that need more direct access to the X server will work correctly. You can use the -Y option if you need full functionality from the remote graphical applications and you trust the remote server and the applications you are running. Since it allows more access, it should only be used in secure, trusted environments. On the contrary, the -Y option enables trusted X11 forwarding, allowing the remote application to have full access to your local X server. It can interact with other X11 clients and modify your local desktop environment, just like a local application. This implies that the -Y option will give you full functionality for remote graphical applications, but it also removes the restrictions imposed by the -X option, which means that applications that need more direct access to the X server will work correctly. You can use the -Y option if you need full functionality from the remote graphical applications and you trust the remote server and the applications you are running. Since it allows more access, it should only be used in secure, trusted environments.
  
-Setting up X11 Forwarding in Windows +==== Setting up X11 Forwarding in Windows ==== 
-Windows does not natively support X11 forwarding because it does not use the X Window System. However, you can use third-party software like Xming, VcXsrv, or MobaXterm to run an X server on Windows. Combine these with an SSH client like PuTTY or use the built-in SSH in Windows 10 (using the Windows Subsystem for Linux, WSL). See here for more information.+Windows does not natively support X11 forwarding because it does not use the X Window System. However, you can use third-party software like Xming, VcXsrv, or MobaXterm to run an X server on Windows. Combine these with an SSH client like PuTTY or use the built-in SSH in Windows 10 (using the Windows Subsystem for Linux, WSL). See [[https://kb.iu.edu/d/bdnt|here]] for more information.
  
  
cluster-linux.1716721153.txt.gz · Last modified: 2024/05/26 10:59 by gabriele

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki