Introduction to Linux Alan Orth April 17, 2010 ILRI, Nairobi.

Slides:



Advertisements
Similar presentations
Introduction to Linux command line for bioinformatics Wenjun Kang, MS Jorge Andrade, PhD 6/28/2013 Bioinformatics Core, Center.
Advertisements

Linux commands exercise 1. What do you need, if you try to these at home? You need to download and install Ubuntu Linux from the Internet – DVD is need.
Linux, it's not Windows A short introduction to the sub-department's computer systems Gareth Thomas.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
UNIX Introduction Peter Wad Sackett. 2DTU Systems Biology, Technical University of Denmark How a computer works ? Who cares ! You just need to use it.
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
CS1020: Intro Workshop. Topics CS1020Intro Workshop Login to UNIX operating system 2. …………………………………… 3. …………………………………… 4. …………………………………… 5. ……………………………………
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
Introduction to UNIX GPS Processing and Analysis with GAMIT/GLOBK/TRACK T. Herring, R. King. M. Floyd – MIT UNAVCO, Boulder - July 8-12, 2013 Directory.
“Final?” Day Unix/Linux April 8, 2014 Dr. Bob Mathis.
Introduction to Linux and Shell Scripting Jacob Chan.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Introduction to UNIX/Linux Exercises Dan Stanzione.
MCB Lecture #3 Sept 2/14 Intro to UNIX terminal.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Welcome to Linux & Shell Scripting Small Group How to learn how to Code Workshop small-group/
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Dedan Githae, BecA-ILRI Hub Introduction to Linux / UNIX OS MARI eBioKit Workshop; Nov , 2014.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
LINUX programming 1. INDEX UNIT-III PPT SLIDES Srl. No. Module as per Session planner Lecture No. PPT Slide No. 1.Problem solving approaches in Unix,Using.
Module 6 – Redirections, Pipes and Power Tools.. STDin 0 STDout 1 STDerr 2 Redirections.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
I/O and Redirection. Standard I/O u Standard Output (stdout) –default place to which programs write u Standard Input (stdin) –default place from which.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Unix Commands PowerPoint Presentation developed for LS 560 Information Technology online class - University of Alabama by Debey Sklenar TENacious Cohort.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
Unix/Linux for beginners:
Linux and Java Basics. What is Linux? Operating system by Linus Torvalds that was a clone of Unix (thus Linux) Free and open source – this is the reason.
Introduction to Programming Using C An Introduction to Operating Systems.
Linux Commands C151 Multi-User Operating Systems.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Learning Unix/Linux Based on slides from: Eric Bishop.
Intro to GNU/Linux See, Stallman? I said GNU. Are you happy now?
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Assignprelim.1 Assignment Preliminaries © 2012 B. Wilkinson/Clayton Ferner. Modification date: Jan 16a, 2014.
Tutorial of Unix Command & shell scriptS 5027
CS1010: Intro Workshop.
Getting started with CentOS Linux
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
C151 Multi-User Operating Systems
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
UNIX Introduction Peter Wad Sackett.
Tutorial of Unix Commands
Tutorial of Unix Command & shell scriptS 5027
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
Chapter Four UNIX File Processing.
Getting started with CentOS Linux
UNIX Introduction Peter Wad Sackett.
Tutorial Unix Command & Makefile CIS 5027
Yung-Hsiang Lu Purdue University
Presentation transcript:

Introduction to Linux Alan Orth April 17, 2010 ILRI, Nairobi

What is Linux?

… An Operating System - (just like Windows and Mac!) - Created in the 1990s by Linus Torvalds - Microsoft DOS was too limiting - UNIX was expensive and restrictive - Linux was born

What is Linux? Examples of Linux Operating Systems, called “distributions”: - Ubuntu (obvious?) - Debian - Fedora - Redhat - CentOS - SuSE Big list at:

Why Linux? - Linux is “free” - Free (money) - Free (freedom... “open source”) - Peer reviewed - … makes Linux a good match for science

Why Linux for Bioinformatics? - Bioinformatics == the application of information technology and computer science to the field of molecular biology - Data sets are getting bigger, we need more processing power power! - … computers with that kind of power use Linux - extremely efficient and stable - excellent in text processing

Get Your Feet Wet Server: hpc.ilri.cgiar.org Username: user1 Password: user1 Use an SSH client like “putty” to connect to our Linux server from Windows: Most research institutions and universities have Linux servers.

Getting Familiar Linux has a graphical environment like Windows, but the real power lies in its command line mode. In Linux, you type commands in the “shell.” After you have entered a command you press Enter to run the command. Familiarize yourself with your environment: whoami – print the name of the current user id – print information about the current user who – print a list of other users who are logged in date – print the current date and time on the server cal – print a calendar for the current month echo – print a text string to the screen

Getting Familiar Linux commands come in various forms. Some are simple, and can be used by themselves: whoami cal Other times you can add “arguments” to change the behavior of the command. Arguments are separated by one or more spaces: cal Other other commands require arguments (they don’t make sense to run by themselves)

Navigating the File System Files and folders are organized in a hierarchical fashion. The top of the hierarchy is called the “root.” Here is the standard directory structure in Linux: / binetchome james alan work pics - the “root” directory is often represented by “/” - “directory” is a fancy word for “folder”

Before we can start solving world hunger, we have to learn how to move around the file system comfortably. Analyze your directory structure using some of the following commands: pwd – print the current “working” directory ls – list the contents of the current directory cd – change to another directory mkdir – create a new directory Navigating the File System

Create some directories and get the hang of moving around them: mkdir one mkdir two mkdir two/three cd one What if you want to move to two now? There is no two in the current directory (verify with ls ). Our directory structure looks like this: Navigating the File System user1 one two three You are here

Navigating the File System If we want to move to the directory two we have to first move back up in the directory hierarchy. Once we move back to user1 we will be able to move into two. cd.. cd two In Linux “..” means “parent directory,” and you see once we move to the parent, we're able to then move to two. Other special directories include “.” (the current directory), and “~” (your home directory).

Commands used for managing files and folders: cp – copy a file mv – move a file (this is how you rename) rm – delete a file file – print the type of file more – read a text file less – read a text file (less is more, but better!) head – print the beginning of a file cat – print a file to the screen Working With Files & Folders

Reference for some basic commands which use or require additional arguments: ls -lh (“long” list of files) ls -la (“long” list of hidden files) ls -lh file (“long” list of file ) mv file file1 (rename file to file1 ) cp file filecopy (copy file to filecopy ) rm file (delete file ) rm -i file (delete file, but ask first) rm -r folder (delete folder )

Copy files from Windows → Linux? Use WinSCP! SCP is the “secure copy” protocol which uses the same username and password you use with Putty. You can also download files from the Internet using the following commands: wget – “web get” utility for HTTP and FTP ftp – “file transfer protocol” links – simple, text-based web browser Working With Files & Folders

Your First File Use the text editor nano to create a new file named “hello”: cd ~ nano hello Type a simple message and then save the file by writing it to the disk: ^O (Control-O) In the world of Linux, the “^” character in key combinations signifies pressing the Control key. Exit the text editor by pressing ^X (Control-X)

Make a copy of your new text file: cp hello hello2 cat hello more hello Press “q” when you're done to quit more. Do you see how the two are different? cat hello hello2 cat simply prints a file to the screen, while more is used to interactively view a text file one page at a time. Programs like more are called “pagers.” Working With Files & Folders

By default, command line programs print to “stdout” (standard out). I/O redirection manipulates the input/output of Linux programs, allowing you to capture it or send it somewhere else. Make a copy of hello (without using cp ): cat hello > hello3 cat hello3 The “>” character performs a “redirect,” taking the output of the cat command and putting it into the file hello3. I/O Redirection

Now try using echo : echo “My name is Alan” > hello3 cat hello3 What happened to hello3 ?... It was overwritten! The “>” operator creates a new file to store the output, but if the file already exists it will be overwritten! Use “>>” to append to a file: echo “Appended” >> hello3 I/O Redirection

Another useful technique is to redirect one program's output into another program's input; this is done using a “pipe.” For example: when a command produces a lot of output, and you want to read the output one page at a time: who | more This is an important technique and will come in handy when you begin using Linux for text processing. I/O Redirection

See how many times a certain user is logged in. grep prints lines which match a given string: who | grep “aorth” | wc -l wc counts words, but can also count lines if you pass it the “-l” argument. You can also do the same thing, using grep 's counting argument: who | grep -c “aorth” Count the number of sequences in a fasta file: grep -c “>” Tutorial.fna Text Processing Basics

sed, the stream editor, can do powerful things with text files. One common example is a search and replace: echo Hello echo Hello | sed 's/Hello/Goodbye/' Delete blank lines from a file using sed : cat myfile | sed “/^$/d” > mynewfile tr can also be used to translate text: echo “HELLO” | tr 'A-Z' 'a-z' More Text Processing

But sed is the king of text substitution; we can use something called “regular expressions” to match complex text patterns and act on them. In this example, nucleotides were to be replaced with integers, A = 1, C = 2, G = 3, T = 4: sed -e 's/\bA\b/1' autosomes.txt | less Here we search for an “A” bordered by a word barrier on both sides (standing alone), and replace it with a “1”. Now add a substitution for the “C”, etc. Eventually you would want to redirect your output to a new file instead of less : sed -e 's/\bA\b/1' -e 's/\bC\b/2' autosomes.txt > autosomes_int.txt

A shell script is a text file with a list of commands inside. Shell scripts are good for automating tasks you use often, or running batch jobs. Enter the following in a new file, script.sh : echo “Date and time is:” date echo “Your current directory is:” pwd Run the script like this: sh script.sh Shell Scripts

A more advanced shell script utilizing a loop: for num in do echo “We are on $num…” done More Shell Scripts

You can always read the manual! To see the “man page” for the ls command: man ls WWWeb resources: LinuxQuestions.org UbuntuForums.org Me: Where to Get Help