Course Preparation: Difference between revisions

From Unix
Jump to navigation Jump to search
(Created page with "__NOTOC__ Before starting this course, you will '''have''' to be able to start a terminal in a '''Unix''' environment, and to '''edit''' files in the same environment with a text editor. If you don't know what a text editor is, no worries, we're doing a whole section on it. Basically it's exactly what it sounds like, a program that can edit text and you've probably already heard about Notepad which is a text editor. There are a lot of text editors and you only really nee...")
 
Line 26: Line 26:
One good tool is MobaXterm, which can be downloaded from:<br>
One good tool is MobaXterm, which can be downloaded from:<br>
[http://mobaxterm.mobatek.net/download-home-edition.html here at Mobatek].<br>
[http://mobaxterm.mobatek.net/download-home-edition.html here at Mobatek].<br>
Here's a ready-to-use collection for you (right click and 'Save as'):  
Here's a ready-to-use but outdated collection for you (right click and 'Save as'):  
[http://teaching.bioinformatics.dtu.dk/material/36610/MobaXterm/MobaXterm_Setup_8.2.msi MobaXterm installer] or
[https://teaching.healthtech.dtu.dk/material/unix/MobaXterm/MobaXterm_Setup_8.2.msi MobaXterm installer] or
[http://teaching.bioinformatics.dtu.dk/material/36610/MobaXterm/MobaXterm_v8.2.zip MobaXterm portable],
[https://teaching.healthtech.dtu.dk/material/unix/MobaXterm/MobaXterm_v8.2.zip MobaXterm portable],
[http://teaching.bioinformatics.dtu.dk/material/36610/MobaXterm/NEdit.mxt3 NEdit].
[https://teaching.healthtech.dtu.dk/material/unix/MobaXterm/NEdit.mxt3 NEdit].
<br>
<br>
You can also take a look at [http://teaching.bioinformatics.dtu.dk/material/36610/MobaXterm the entire collection].  
You can also take a look at [https://teaching.healthtech.dtu.dk/material/unix/MobaXterm the entire collection].  


Install MobaXterm - it will put itself in the windows
Install MobaXterm - it will put itself in the windows
Line 43: Line 43:


Once you've found MobaXterm, run it and a Unix terminal should appear. The first time MobaXterm starts takes a while - get coffee - be patient.<br>
Once you've found MobaXterm, run it and a Unix terminal should appear. The first time MobaXterm starts takes a while - get coffee - be patient.<br>
If MobaXterm doesn't run properly - it is likely NOT an installation problem and re-installing won't help. Instead, delete the "MobaXterm" folder in your standard "Documents" folder. This is where files and settings are stored.
If MobaXterm doesn't run properly - it is likely NOT an installation problem and re-installing won't help. Instead, delete the "MobaXterm" folder in your standard "Documents" folder. This is where files and settings are stored. Part of the problem can be that you are using OneDrive, and therefore your installation really takes place in the cloud, and so would your use of MobaXterm - this a dead end - install it elsewere on your system on your local harddisk.


Here is a short guide for how to download MobaXterm [http://teaching.bioinformatics.dtu.dk/material/36610/MobaXterm/MobaXterm-instruction.mp4 instruction video] for
Here is a short guide for how to download MobaXterm [https://teaching.healthtech.dtu.dk/material/unix/MobaXterm/MobaXterm-instruction.mp4 instruction video] for
installing and using MobaXterm made by Daniel Edward Perez from Michigan State University.
installing and using MobaXterm made by Daniel Edward Perez from Michigan State University.


Line 52: Line 52:
You can also start a new unnamed file by typing,
You can also start a new unnamed file by typing,
  Prompt$ '''edit -f'''
  Prompt$ '''edit -f'''
The default version of Mobaxterm also has '''Vim editor''' installed, which we'll be using in this course.  
The default version of Mobaxterm also has '''Vim editor''' installed, which we'll be using in this course.


=== Ubuntu Windows Subsystem Linux (WSL); Downloadable from the Windows App store ===   
=== Ubuntu Windows Subsystem Linux (WSL); Downloadable from the Windows App store ===   

Revision as of 12:44, 20 March 2024

Before starting this course, you will have to be able to start a terminal in a Unix environment, and to edit files in the same environment with a text editor. If you don't know what a text editor is, no worries, we're doing a whole section on it. Basically it's exactly what it sounds like, a program that can edit text and you've probably already heard about Notepad which is a text editor. There are a lot of text editors and you only really need to know 2 or 3. In this course, we'll be focusing on the vim editor which can be a bit tricky, if you're used to using your cursor as it almost only uses the keyboard for navigation.

Below, we explain how you start Unix terminal on various Operation Systems (OS). Anything mentioned here is free software, but some can be upgraded (for money) to more functionality, but it is not necessary.

Linux

You are already set and ready for the course. You should be able to find the terminal; Term, Xterm, Console, as this is a basic integrated part of linux. There are many text editors you can use; gedit, jedit, nedit, emacs, vim and a dozen more.

Mac

A Mac has a BSD Unix underneath all the fancy graphics, which means that you're mostly ready for the course once you figure out how to use it. Simply locate the program called 'Terminal', which will set you up with a Unix terminal. For the most part, you should be able to utilize the same commands as in a proper linux environment, but there are some exceptions. For instance, when we reach the section 'File compression and advanced packaging tools', the command apt(short for 'Advanced package manager') is not supported on the Mac OS and you have to download and install the package manager Homebrew. There are other subtle differences when using the Unix terminal on a Mac OS throughout this course. So if you get tired of this and want the real linux experience, you can install what's called virtualbox, that allows you to run a Linux OS, by following the instructions in this link Installing a Virtualbox on Mac.

There are several nice text editors for Macs; Komodo, TextWrangler, Sublime Text 2, jedit, gedit, etc. Some videos have been prepared for you, demonstrating what to do.
Mette Beck shows how to open a terminal and install and use Komodo text editor.
Edita Karosiene shows how to install/use X11 and connect to a remote server with SSH.
Finally a link to other resources about Unix on Mac.

Windows

Windows doesn't have any pre-installed tools for creating Unix environments, but there exist some downloadable tools for this. We'll go through 2 ways for which the Unix OS can be imitated in a windows environment; MobaXterm and Ubuntu Windows subsystem for Linux (WSL).

Mobaxterm

One good tool is MobaXterm, which can be downloaded from:
here at Mobatek.
Here's a ready-to-use but outdated collection for you (right click and 'Save as'): MobaXterm installer or MobaXterm portable, NEdit.
You can also take a look at the entire collection.

Install MobaXterm - it will put itself in the windows program folder. This location differs depending on the version of windows you have, but it is "findable". Some places would be: Computer -> C: -> Programs -> Mobatek -> MobaXterm Home Edition. Instead of Programs it could be; Programmer, Programs (x86) or other. The point of knowing this location is that you should drag and drop (move) the plugins you downloaded to this folder from your download folder. That act will make the plugin available. Windows will ask if you want to do this - yes, you do. Windows Firewall will block some features of MobaXterm and ask if they should be allowed. Just block - it does not matter for what we do.

Once you've found MobaXterm, run it and a Unix terminal should appear. The first time MobaXterm starts takes a while - get coffee - be patient.
If MobaXterm doesn't run properly - it is likely NOT an installation problem and re-installing won't help. Instead, delete the "MobaXterm" folder in your standard "Documents" folder. This is where files and settings are stored. Part of the problem can be that you are using OneDrive, and therefore your installation really takes place in the cloud, and so would your use of MobaXterm - this a dead end - install it elsewere on your system on your local harddisk.

Here is a short guide for how to download MobaXterm instruction video for installing and using MobaXterm made by Daniel Edward Perez from Michigan State University.

MobaXterm has a built-in text editor that is quite fine, called MobaTextEditor. You can edit an existing file by typing,

Prompt$ edit <myfilename.py>

You can also start a new unnamed file by typing,

Prompt$ edit -f

The default version of Mobaxterm also has Vim editor installed, which we'll be using in this course.

Ubuntu Windows Subsystem Linux (WSL); Downloadable from the Windows App store

Figure 0.1 Ubuntu installation screen: Here we show the different steps in the initialization of the Ubuntu WSL. You won't be able to see the characters as you, but you can type the password again if you reenter the password wrong.

Ubuntu is the Unix OS that is used for Linux computers and there are ways for which it can be mimicked on a Windows OS. It's recommended that you at some point switch from using Mobaxterm to the Ubuntu WLS. The link below is a good guide for installing it, and if you're interested it also offers a good explanation as to how it's integrated into the Windows OS.
Link to guide on downloading Ubuntu

The above guide is quite clear on how to install it, but a few things might cause trouble. On the screen to the right, I've shown how my screen looked when I installed it. Once you've successfully downloaded Ubuntu, you'll be prompted to enter a username and password. This can be whatever you like and they don't need to be identical to your Microsoft account. You might, however, have a little trouble if your username isn't in accordance with your NAME_REGEX_file. Simply put, the NAME_REGEX_file is a configuration file for adding/deleting users and it has criteria for which characters should be allowed. If this problem occurs you can just choose another username, or if you really want that username you can try using the command --force-badname <username>.

Also just so you know, when you're entering your password you won't see dots appearing for every character.

If you got through the installation part, we now have to setup a link between the WLS and the folder that will contain the files you work with. In order to do this, we're gonna use some of the commands and terminology that you'll be learning in the first section. So if this is confusing, you might be better off by downloading Mobaxterm, doing section 1 and then coming back to this part.

First make sure that you're in the Linux subsystem home/user directory by typing in the Unix command, cd. You can check your current location by typing pwd. Next, we need to create a workfolder in your desktop. You can either do this as you normally would or you can use the command mkdir -p filepath/workfolder as shown in figure 0.2. We create what's called a symbolic link by using the command ln -s <filepath> <symbolic link name>.

Figure 0.2 Creating workfolder and symbolic link: The command ls is a command that shows the files and directories in the current working directory.

Super condensed info: In order to make X11 (graphical interface) work on remote systems, use the editor pico to add below 2 lines in to the .bashrc file in your home dir.

export DISPLAY=localhost:0.0
export LANG=en_US-UTF-8

Install the X-server Xming on your Windows and run it.

Ubuntu with VirtualBox

Your third option is to install a virtual box from where you run a Linux OS. How to do this? Do a search on google for "installing ubuntu on virtualbox" or follow the guide in this video youtube video demonstrating the procedure. If you succeed, you have full immersion in the Unix environment and two computers running on the same machine simultaneously (max coolness factor), and if you fail you have not lost anything not even disk space if you clean up after yourself. However, you are on your own for the entire process. A link and guide for downloading a Virtualbox is given in below section 'Extra material, methods and ideas'.

Extra material, methods and ideas

The text below is not necessary to read, but can perhaps help you on other occasions.

LiveCD

A liveCD is a CD/DVD that contains a complete bootable linux environment. The environment is able to access your harddisk, so whatever you do can be saved. This is a superior way of learning linux at the cost of one CD. You get everything without installing anything at all. There are several versions with different capabilities, but which one is best is hard to say.
Download Knoppix
Download SuSE liveCD
Download Quantian scroll down.

WinSCP

WinSCP is a wonderful tool if you just need to transfer files back and forth between computers. It may be a little hard/diffucult to configure so it is really easy to use, but fortunately you don't have to do so. It will still work well, but you might miss out on the fancy stuff. If you need to update a file on the remote machine, then transfer (copy) the file to your desktop, make your changes, transfer the file back and finally delete your local copy. Even if it looks like you can just doubleclick on the file, and it might even succeed, then it is bad practice. WinSCP can be downloaded at http://winscp.net.

CyberDuck

CyberDuck is a general file transfer/remote file access tool for Mac. It does what WinSCP (above) does and more. THE tool for Mac. CyberDuck can be downloaded at http://cyberduck.ch/.

VirtualBox

VirtualBox from Oracle is a wonderful tool. It installs a package that will allow you to run one or more virtual machines on your computer. On these virtual machines you can install any OS you want, see Linux or Windows. Examples: You have a Mac, you want to run Windows - use VirtualBox and you can run Windows in a Mac application window. You run Windows, but would like to run linux for some specific purpose - same answer. If you don't need your virtual machine (VM) anymore - throw it away and release the disk space for some other purpose. A virtual machine does not need much disk space (5-10 GB), since it can access the disk on the native machine. You can simply share files between your host machine and virtual machine. You can even copy/paste between them, once you have installed the VBoxGuest additions. There is approximately a 10% performance loss when running virtual, but it is worth it for the ease of use. There are other free virtualizing softwares, like VMware Player (one of the first softwares on that market and still very strong), but VirtualBox has proved itself to be small package that is very easy to use and install.
Download VirtualBox for Windows, Mac and Linux versions.
Installation: Do a standard install. There will be several warnings from Windows about using drivers that has not gone through a Microsoft approval step - these can safely (and must) be ignored - just click Continue. When creating a new virtual machine, you must first decide what to install as a guest OS. The recommended choice is 32 bit Ubuntu linux. In any case you should probably go for 32 bit OSes. Secondly, you must decide how large a disk you should use - the default 8 GB is fine. You must also decide how much memory you should allocate to the VM; if you only have 2 GB RAM on your "real" machine, then allocate 768 MB, if you have more real RAM then allocate 1024-1536 MB. Before you launch your new WM, you must insert the installation image for the OS (Ubuntu) you downloaded into the VM's CD-rom drive. This is done under 'Storage' for the VM - it can be a bit tricky to find the small icon for the CD-drive, but when the standard "choose file" menu opens, then you hit it right. After installation of your virtual OS, you must also install the 'Guest additions'. These can be found under 'Devices' when your guest OS is running. It will give you much better screen control (resizing), faster screen updates, the ability to cut/paste text and share folders between your host OS and guest OS.