====== Linux survival guide ====== ===== Why Linux? ===== Most of the software used for processing and analysing neuroimaging data runs under the Linux operating system (OS). There are good reasons for this - Linux is fast and powerful (all of the 500 fastest supercomputers in the world run Linux and most CGI effects in films are made on Linux computers), widely used (major online providers like Amazon and Google run Linux and 96% of the top 1 million most visited websites are run by Linux, as are 85% of smartphones - Android being a derivative of Linux) and highly customisable. It's also free and open source, making it eminently compatible with Open Science. However, Linux can seem an unfamiliar environment for individuals used to working on Windows or Mac. Below are some tips to quickly master essential Linux skills necessary for running most neuroimaging software. ===== Linux basics ===== Linux was initially created as a hobby project by the Finnish software engineer Linus Torvalds in 1991. The name Linux is a portmanteau of his first name and Unix, the OS from which Linux is derived (in fact, Linux is a version of Unix). **Very important note:** Linux is pronounced as in Finnish Swedish (Linus Torvalds being part of the Swedish-speaking minority in Finland), with a long i as in "bee" and long u as in "book": lee-nooks, not line-axe: https://upload.wikimedia.org/wikipedia/commons/0/03/Linus-linux.ogg Unlike Windows or MacOS, there are many varieties of Linux, so-called distributions, which all share the same fundamental architecture and "kernel" (the program that actually runs the OS), but differ in their look and feel, the software included, and ease of use. The reason Linux is so widely used is in part due to the ease of modifying Linux to create a distribution suitable for a particular application (e.g., small and lightweight for low-power computing devices, fast and working in real time for time critical applications such as rocket launches or [[https://github.com/readme/featured/nasa-ingenuity-helicopter|flying helicopters on Mars]], or with lots of bells and whistles to make them user friendly for desktop use). The most common distributions, such as Ubuntu and Debian, are geared towards user-friendliness and will look fairly familiar to users of Windows and Macs used to a "point-and-click" interface, while the more specialised ones often make do without any graphical user interface at all, instead using a terminal window only (more on that below). ===== Logging in to a remote Linux server ===== ***//SSH//** SSH stands for Secure Shell. It is a command-line protocol which provides strong password authentication and public key authentication, as well as encrypted data communications between two computers connecting over an open network, such as the internet. To be able to connect to the server //psycomp.rhul.ac.uk// over SSH, open the command-line terminal and use the following command: ssh[user_ID]@psycomp.rhul.ac.uk ***//RDP//** RDP stands for Remote Desktop Protocol. The //psycomp.rhul.ac.uk// can be accessed for GUI (Graphical User Interface) tools on the cluster. This node is provided with high-performance graphics drivers for this. This //psycomp.rhul.ac.uk// can be accessed directly while operating from a local PC on campus and for off-campus access is granted only through VPN (details of VPN access is provided [[https://intranet.royalholloway.ac.uk/students/help-support/it-services/access-off-campus/vpn/vpn.aspx|here]]). After connecting to the VPN use the Remote Desktop Connection software (Windows RDP / Ubuntu Remmina) and connect to the //psycomp// Server( server address: //psycomp.rhul.ac.uk// ). Use the [user_ID] and password and domain as cc to log on to the server. ***//VNCViewer//** Open the VNCViewer app and enter //psycomp.rhul.ac.uk//:[VNC_session_number] in the VNC server dropdown box. The [VNC_session_number] is an unique session code that you should have received from the IT team (If you haven't been provided one, please email the psychology IT Team [[Can.Keles@rhul.ac.uk]]). After clicking Connect enter your VNC password and log-on to the cluster. ===== The Linux desktop ===== There are a variety of desktops available on Linux distributions but most common distributions (such as Ubuntu or Debian) have a desktop that looks fairly familiar to a Windows or Mac user - there will be a menu bar at the top or the bottom of the screen which you can use to launch different programs, and a desktop with some folders in it that you can click on to open and navigate through the file system. For our purposes we will focus upon the Plasma KDE desktop. ===== The Linux terminal ===== ***//The shell//** The shell is a program that takes commands from the keyboard and gives them to the operating system to perform. Earlier it was the only user interface available on a Unix-like system such as Linux. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell. On most Linux systems a program called **bash** (which stands for Bourne Again SHell, an enhanced version of the original Unix shell program, **sh**, written by Steve Bourne) acts as the shell program. Besides bash, there are other shell programs available for Linux systems. These include: ksh, tcsh and zsh. On the psycomp server, we will use **bash** commands. ***//Terminal Emulator//** In order to run **bash** commands, a particular tool called //Terminal Emulator// is used. On a Linux and Mac-OS systems a widely used Terminal Emulator program is called **Terminal**. Psycomp server also has **Terminal** program that can be accessed under the Applications tab. ***//Command-line completion//** *Writing a shell script *Navigating the file system ===== Essential commands ===== **//Finding where you are //** pwd After logging in the psycomp server either through the command line interface or through GUI, it will be important to know which location you areon the computer. **//List files://** ls **//Change directory://** cd **//Rename or move files: //** mv **//Create files and directories: //** touch, mkdir **//Delete files and directories: //**rm, rmdir **//Find files and directories: //**find **//Check CPU usage: //**top, ps **//Text editing: //**pluma, kate, nano **//PDF viewer: //**atril **//Desktop applications: //**LibreOffice, Firefox **//Common neuroimaging applications://** FSL, Matlab, AFNI **//copying files and directories: //** cp, scp **// Getting help: //** man ===== The Linux file system ===== **// The home directory: //**/home/myusername **// The root directory: //**/ **//System directories: //**/usr, /bin, /etc, /lib, /media **//Mounting external file systems//** **//File permissions //** **// Recursive commands //**