SEEM3460 Tutorial Unix Introduction Xinshi Lin & Zihao Fu 2018.09.

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

1 Introduction to UNIX Ke Liu
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.
Dayu Zhang 9/8/2014 Lab02. Example of Commands pwd --- show your current directory This is home of venus, not your home directory Tilde: means you are.
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.
1 SEEM3460 Tutorial Access to Unix Workstations in SE.
“Linux at the Command Line” Don Johnson of BU IS&T.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  Currently there.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Unix Basics Chapter 4.
Cmsc 312 Operating Systems. UNIX? DOS – PC? VAX/VMS - mainframe Unix – PC, workstation, mainframe 1970 bell Lab For computer scientist? Why popular? Free.
CENT 305 Information Systems Security Linux Introduction.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
LINUX Tuesday, 5 July :00 pm. Remote Login l Use Secure Shell (ssh) l Machine name/IP address E.g. ssh hydra.sma.nus.edu.sg Or ssh
CS240 Computer Science II Introduction the Unix File System and File Related Utilities Based on “UNIX for Programmers and Users” by G.Class and K. Ables.
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Usage of Workstation Lecturer: Yu-Hao( 陳郁豪 ) Date:
ENEE150 – 0202 ANDREW GOFFIN Introduction to ENEE150.
Getting started: Basics Outline: I.Connecting to cluster: ssh II.Connecting outside UCF firewall: VPN client III.Introduction to Linux IV.Intoduction to.
Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.
Basic Unix Commands CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
Introduction to Programming Using C An Introduction to Operating Systems.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
Unix Servers Used in This Class  Two Unix servers set up in CS department will be used for some programming projects  Machine name: eustis.eecs.ucf.edu.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
Dr. Sajib Datta Jan 16,  The website is up.  Course lectures will be uploaded there ◦ Check regularly for assignments and update.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Review Why do we use protection levels? Why do we use constructors?
By Jonathan Rinfret UNIX/LINUX By Jonathan Rinfret
Introduction to Unix for FreeSurfer Users
Precept I : Lab Environment, Unix, Bash, Emacs
GRID COMPUTING.
ENEE150 Discussion 01 Section 0101 Adam Wang.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
SEEM3460 Tutorial Unix Introduction.
Tutorial of Unix Command & shell scriptS 5027
CS1010: Intro Workshop.
Getting started with CentOS Linux
Chapter 11 Command-Line Master Class
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Web Programming Essentials:
UNIX The Basics Source:
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
The Linux Operating System
Assignment Preliminaries
Tutorial of Unix Command & shell scriptS 5027
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Intro to UNIX System and Homework 1
C Programming Lecture Series
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
Introduction Paul Flynn
Getting started with CentOS Linux
Andy Wang Object Oriented Programming in C++ COP 3330
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Command line.
Presentation transcript:

SEEM3460 Tutorial Unix Introduction Xinshi Lin & Zihao Fu 2018.09

Introduction Unix-like system is everywhere OS X for MacBook/iMac etc Linux Android for smartphones Google Chrome OS for Chromebook Web servers OS X for MacBook/iMac etc iOS for iPhone/iPad etc

Unix Shell Shell: a program that acts as a middleman between you and the UNIX OS Terms similar to shell: Terminal / virtual terminal Console A shell allows users to Run programs Manage I/O of processes easily A Unix shell interprets a programming language (sometimes called the shell script)

SSH and X Window System SSH (Secure Shell) X Window System to connect to remote machines and execute commands remotely Windows does not support SSH natively, so we need third-party tools like Putty X Window System commonly used in Unix-like systems to provide GUI environment To run GUI program remotely, you need to provide a local X Server We use Xming to start a X Server on Windows

Required Software (Windows) SSH client (required) PuTTY (FREE) (download putty.exe and plink.exe) SSH Communications Security X server (optional, but needed for GUI) Xming (FREE) (download Xming in “Public Domain Releases”) X-Win32 https://www.starnet.com/xwin32/

Required Software (OS X) SSH client No need, OS X have native support Open Terminal and type ssh [your UNIX name]@[your host name] ssh –X [your UNIX name]@[your host name] with GUI support X server XQuartz http://xquartz.macosforge.org/

Available Servers We provides three servers for this class: linux03.se.cuhk.edu.hk linux04.se.cuhk.edu.hk linux05.se.cuhk.edu.hk Inside SE intranet, you may omit “.se.cuhk.edu.hk” part To connect these servers outside CUHK, you need to connect the CUHK VPN https://www.cuhk.edu.hk/itsc/network/vpn/vpn.html

Using Putty (without GUI support) run putty.exe [Session]: Host Name: (e.g.) linux03.se.cuhk.edu.hk Save for later use Double click the saved session name to start SSH you will get: To close SSH connection, type exit and enter.

Using Putty (with GUI support) If you need to run GUI programs like Nautilus, you need to start a local X Server, e.g. Xming. run Xming.exe run putty.exe [Connection]-[SSH]-[X11]: Enable X11 forwarding [Session]: Host Name: (e.g.) linux03 Save for later use Double click the saved session name to start SSH you will get:

Practice Login to linux01~03 using putty with or without GUI support Q: Why we still see “black window” instead of the “GUI” when we login with Xming and Putty?

Practice Login to linux01~03 using putty with or without GUI support Q: Why we still see “black window” instead of the “GUI” when we login with Xming and Putty? A: 1. you need to run a GUI program (e.g. ‘gedit’). 2. The sever needs to install GUI-support suite. Currently only linux01 and linux02 support GUI.

Utilities Unix utilities are the basic programs supporting the user to control the system Examples: date: shows the system date man -s 1 ls: shows help on ls from the built-in manual section 1 pwd: prints the working directory echo: prints a message

A shell command ls -lp ~ ls: program name “ls” is the utility to list files -lp: options/switches, starting with a hyphen “l” means list in long format “p” means putting a slash after directory names ~: remaining parameters actual meaning depends on the program used for ls, the remaining parameters are the files or directories to be listed “~” means the home directory of the current user

Unix file system in brief A hierarchy of directories To locate a file in the system, a pathname is needed Command: pwd print your current working directory Pathnames Absolute pathnames Starting from the root (with a beginning “/”) Relative pathnames Starting from the current working directory

Directory: ls, cd, mkdir, rmdir List files in a directory or fits the pattern ls <directories/filename patterns> Change working directory cd <aDirName> Creating (making) a directory mkdir <newDirName>

File Operations View the content of a file cat <file paths> less <file paths> head <file path> tail <file path>

cp, rm, mv Copying a file Remove a file Moving (renaming) a file cp <oldFileName> <newFileName> Remove a file rm <FileName> Remove a non-empty directory rm –r <DirName> Remove a whole directory without prompt rm –rf <DirName> Moving (renaming) a file mv <aFileName> <aDirectoryName> mv <oldFileName> <newFileName>

Editing a file nano emacs vi/vim (vim stands for Vi Improved) Advantage: simple, easy to learn and use Disadvantage: no GUI emacs Adv: has GUI, easy for beginners Dis: relatively slow vi/vim (vim stands for Vi Improved) Adv: fast for advance users Dis: text-version is quite difficult to learn GUI version: gvim, rgvim To learn, type “vimtutor” in console Check their “man” page for detail usages

Practice Use vim/nano/pico to create/edit/save a file and exit Tips: for vim, press ‘i’ to insert mode, otherwise you cannot modify the file. To create or edit a file, type ‘vim filename’ to run vim. For example, ‘vim hello.c’ To exit, first press’ ESC’, then type ‘:q’ to exit if you do not modify anything ‘:q!’ to exit forcedly regardless of any modification ‘:wq’ to save and exit for nano or pico, to create or edit a file, type ‘nano/pico filename’ to run. (e.g. ‘nano hello.c’) Press ‘Ctrl+o’ to save, ‘Ctrl+x’ to exit. Find more tips below the screen. ‘^’ means ‘Ctrl’ under linux command line.

Compiling C programs in Unix Compiler: cc – the native C compiler under Unix gcc – C compiler under GNU project Usage is the same, gcc is more popular To compile a C source code file, say example.c, type in: gcc example.c The output of both compilers (i.e. the executable) would be “a.out” by default To override the default executable name, use “-o” flag gcc example.c –o example You can name the executable as .exe or .bin file to remind yourself the nature of the file One more tip, use “-Wall” to get some warning messages Warning message usually indicate hidden bugs Try to understand the error messages and warning messages. For other flags, “man cc” or “man gcc”

Practices Get familiar with file/directory-related commands Create a seem3460 folder in your home directory In the tutorial-01 folder, create a hello.c file with the following content, compile with gcc and run the compiled program: #include <stdio.h> int main() { printf(“Hello World\n”); } Create the reverse.c program, compile and run. See page 6 in Lecture Notes “Compilation and Linking under Unix”. Copy and Paste may produce strange characters in your editor, so try to type the code by yourself.

reverse.c #include <stdio.h> #include <string.h> void reverse (char before[], char after[]); int main() { char str[100]; /* buffer to hold reversed string */ reverse("cat",str); /* reverse the string "cat" */ printf ("reverse(\"cat\") = %s\n", str); reverse("noon",str); printf ("reverse(\"noon\") = %s\n", str); } void reverse (char before[], char after[]) { int i,j,len; len = strlen(before); i=0; for (j=len-1; j>=0; j--) { after[i] = before[j]; i++; after[len] = ‘\0’;