Lecture # 2 Introduction to UNIX (Part 2)

Similar documents
Fall Lecture 5. Operating Systems: Configuration & Use CIS345. The Linux Utilities. Mostafa Z. Ali.

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Unix L555. Dept. of Linguistics, Indiana University Fall Unix. Unix. Directories. Files. Useful Commands. Permissions. tar.

Utilities. September 8, 2015

Introduction: What is Unix?

Getting Started. Logging In and Out. Adapted from Practical Unix and Programming Hunter College

Short Read Sequencing Analysis Workshop

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

Lab 1 Introduction to UNIX and C

Introduction. File System. Note. Achtung!

Unix Introduction to UNIX

Introduction to Linux Environment. Yun-Wen Chen

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX

Introduction to Linux. Roman Cheplyaka

Basic Linux Commands. Srihari Kalgi M.Tech, CSE (KReSIT), IIT Bombay. May 5, 2009

Chapter-3. Introduction to Unix: Fundamental Commands

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction to Linux

UNIX Quick Reference

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Introduction to UNIX Command Line

S E C T I O N O V E R V I E W

Introduction to UNIX I: Command Line 1 / 21

IMPORTANT: Logging Off LOGGING IN

commandname flags arguments

Introduction to UNIX command-line

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Student Remote Login Procedure (see picture below): 1. Start SSH Secure Shell 2. Click the computer icon (4 th on the toolbar) 3.

No Food or Drink in this room. Logon to Windows machine

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

CS4350 Unix Programming. Outline

Introduction to Linux

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

CHE3935. Lecture 1. Introduction to Linux

Introduction to Linux

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

CSC UNIX System, Spring 2015

CSE 391 Lecture 1. introduction to Linux/Unix environment

Getting your department account

1Z Oracle Linux Fundamentals (Oracle Partner Network) Exam Summary Syllabus Questions

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Introduction to Unix: Fundamental Commands

Computer Systems and Architecture

5/20/2007. Touring Essential Programs

Introduction To Linux. Rob Thomas - ACRC

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

An Introduction to Unix Power Tools

Introduction to Linux

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

Introduction to Linux Organizing Files

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Outline. Structure of a UNIX command

FREEENGINEER.ORG. 1 of 6 11/5/15 8:31 PM. Learn UNIX in 10 minutes. Version 1.3. Preface

CSE 391 Lecture 1. introduction to Linux/Unix environment

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Aliases are set manually or in a login script. Aliases that were set manually will be gone the next time you login.

A Brief Introduction to the Linux Shell for Data Science

for more :-

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Unix Handouts. Shantanu N Kulkarni

Mills HPC Tutorial Series. Linux Basics I

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

COWLEY COLLEGE & Area Vocational Technical School

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

M.C.A. (Sem.-lll) (CBCS) Examination November CCA-3003 Operating System and LinuxlUnix programming

CS 460 Linux Tutorial

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Linux Essentials Objectives Topics:

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

Basic Unix and Matlab Logging in from another Unix machine, e.g. ECS lab Dells

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

CS246 Spring14 Programming Paradigm Notes on Linux

Unix Shells and Other Basic Concepts

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Editors in Unix come in two general flavours:

Vi & Shell Scripting

Arkansas High Performance Computing Center at the University of Arkansas

Linux command line basics II: downloading data and controlling files. Yanbin Yin

User Guide Version 2.0

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

CSE 390a Lecture 1. introduction to Linux/Unix environment

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Linux Fundamentals (L-120)

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

CS370 Operating Systems

Introduction to Linux Workshop 1

Computer Systems and Architecture

Introduction to the shell Part II

Self-test Linux/UNIX fundamentals

Linux Systems Administration Getting Started with Linux

Transcription:

CS390 UNIX Programming Spring 2009 Page 1 Lecture # 2 Introduction to UNIX (Part 2) UNIX is case sensitive (lowercase, lowercase, lowercase) Logging in (Terminal Method) Two basic techniques: 1. Network login (using SSH client) 2. Console login login: Password: <enter username> <enter password> <<< some text will appear>>> prompt (often $) When done, you can logout by typing exit at the prompt (or ctrl-d). Logging in (GUI Method) The Linux machines in the UAH labs are running a GUI interface. You might see a list of machines willing to manage your login session. If so, choose the machine you want to login to You should see a login box. login: <enter username> Password: <enter password> Screen should change, and you should be a windowed desktop. You may have to open a terminal window via an icon or menu choice. To logout, right click on desktop, and choose Exit or Logout. Getting help Textbook Internet searches (Google, Yahoo, etc.) Class notes Online manual pages man <command>

CS390 UNIX Programming Spring 2009 Page 2 Example: $ man write The online manual is broken up into several sections: 1. User commands 2. System calls 3. Subroutines 4. Devices 5. File Formats 6. Games 7. Misc 8. System Administration 9. Local 10. New Sometimes a command or topic appears in the manual in multiple sections, and you can include the specific section to view a particular page. $ man 2 write PICO editor $ pico filename Most common editing commands are displayed on screen. VI basics Check terminal type (echo $TERM) $ export TERM=vt100 (for Bourne, Bash, or Korn shell) $ setenv TERM vt100 (for Csh or Tcsh) To start vi : $ vi <filename> Command mode versus input mode (:set showmode) Default mode is command mode on startup

CS390 UNIX Programming Spring 2009 Page 3 <Esc> i h j k l x dw dd u Change to command mode Change to input mode (if in command mode) One character Left One character down One character up One character right Character delete Delete word Delete line Undo ZZ Save and Exit :wq Save and Exit :x Save and Exit :q! Exit without saving

CS390 UNIX Programming Spring 2009 Page 4 Command review File manipulation commands 1. ls directory listing ls [-l] [-s] [-a] [dir or file names ] -l long listing -s include file sizes -a all files Display a listing of files in the current directory $ ls file1 file2 homework3.txt Display a listing of files in the /tmp directory $ ls /tmp homework4.txt file8.txt Display a long listing of the current directory $ ls l [rjohnson@lancelot testdir]$ ls -ls total 4 0 -rw-r--r-- 1 rjohnson rjohnson 0 Dec 5 14:53 file1 0 -rw-r--r-- 1 rjohnson rjohnson 0 Dec 5 14:53 file2 0 -rw-r--r-- 1 rjohnson rjohnson 0 Dec 5 14:53 file3 0 lrwxrwxrwx 1 rjohnson rjohnson 5 Dec 5 14:53 link1 -> file1 4 drwxrwxr-x 2 rjohnson rjohnson 4096 Dec 5 14:53 tmpdir [rjohnson@lancelot testdir]$ 2. cat and more displaying the contents of a file cat display contents of a file to screen more does the same except the output is presented one page at a time cat <filename> (i.e. $ cat test1.txt) more <filename> (i.e. $ more test2.txt) 3. cp copying files cp <original file> <new file> Example: $ cp file1 file2

CS390 UNIX Programming Spring 2009 Page 5 4. mv rename files mv <original filename> <new filename> $ ls file1 file2 file3 $ mv file1 file1.txt $ ls file1.txt file2 file3 5. rm remove files rm <option> <file> -f force -i interactive (ask before removing) -r recursive $ rm homework4 6. grep searching files grep <string> <filename> This is line1. This is line2 for cs390. This is line3. homework1.txt $ grep cs390 homework1.txt This is line2 for cs390. 7. head and tail - display the top or bottom section of a file. head <line count> <filename> tail <line count> <filename> Display the top 10 lines of text from the file testing $ head testing Display the last 2 line of text from the file testing $ tail 2 testing

CS390 UNIX Programming Spring 2009 Page 6 8. sort sort the contents of a file sort <options> <filename> Sort the file test.txt based on the entire line $ sort test.txt Sort numerically $ sort n test.txt Sort by the 3 rd field, and then by the 2 nd field $ sort k3n,3 k2b,2 test.txt 9. uniq display the unique lines of a file uniq <filename> Note: The file must be sorted first to work properly. $ uniq testing.txt This same functionality is available as an option on sort (-u) $ sort u file1.txt 10. diff - display differences between 2 files diff <file1> <file2> Shows three things: 1. lines in file1 not in file2 (denoted with d ) 2. lines in file2 not in file1 (denoted with a ) 3. lines that are different in file1 and file2 (denoted with c ) $ diff homework1.txt homework2.txt 11. file display file type information file <filename> $ file file1.dat file1: data

CS390 UNIX Programming Spring 2009 Page 7 Other utilities 1. echo display a string echo <string> $ echo this is a test Used in shell script programming much like printf in C. 2. date display the date and time $ date Mon Jan 12 08:05:03 CST 2004 $ date + %m-%d-%y 01-12-2004 Note: See man page for full listing of the formatting commands 3. script record a shell session script <filename> Record the current session into a file called session.txt $ script session.txt Script started, file is session.txt $ ls file1 file3 file4 $ exit Script done, file is session.txt $ 4. gzip compress files gzip [-d] <filename> Compress a file called letter $ ls l -rw-rw-r-- 1 alex speedy 584000 Jul 31 06:07 letter $ gzip letter $ ls l -rw-rw-r-- 1 alex speedy 2030 Jul 31 06:07 letter.gz Uncompress this file $ gzip d letter.gz

CS390 UNIX Programming Spring 2009 Page 8 5. tar pack or unpack file tar [c t x] [v] [f] <archive file> <file list > Create a tar file containing file g, b, and d $ tar cvf file.tar g b d List the contents of the tar file file.tar $ tar tvf file.tar Extract the files from the tar file file.tar $ tar xvf file.tar 6. which and whereis locating commands which <filename> whereis <filename> $ which tar /bin/tar $ whereis tar tar: /bin/tar /usr/include/tar.h /usr/share/man/man1/tar.1.gz User information commands 1. who list users on the system $ who root console Mar 27 05:00 alex pts/4 Mar 27 12:23 alex pts/5 Mar 27 12:33 jenny pts/7 Mar 26 08:45 2. finger list users on the system finger [user] $ finger Login Name Tty Idle Login Time Office root root 1 1:35 May 24 08:38 alex Alex Watson /0 Jun 7 12:46 (:0) jenny Jenny Chen /2 2:24 Jun 2 05:33 (bravo.tcorp.com) $ finger alex <<< information about user alex >>>

CS390 UNIX Programming Spring 2009 Page 9 3. w list users on the system $ w 8:20 a.m. up 4 days, 2:28, 3 users, load average: 0.04, 0.04, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT alex pts/4 :0 5:55 a.m. 13:45 0.15s 0.07s w scott pts/12 bravo 7:17 p.m. 1.00s 0.14s run_bdgt User communication commands 1. write send a message to another user write <user> [terminal] $ write alex Hi Alex, are you thre? 2. talk 2 way communication with another user $ talk jenny 3. mesg denies or accepts messages $ mesg n Email 1. pine or elm menu driven mail utilities 2. mail read or send email $ mail richj@hiwaay.net This is a test email.. Special Characters & ; *? ` [ ] ( ) $ < > { } ^ # / \ %! ~ + Quoting Special Characters You backslash (\) to escape special characters