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

Similar documents
Perl and R Scripting for Biologists

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Chapter-3. Introduction to Unix: Fundamental Commands

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

The Online Unix Manual

Linux & Shell Programming 2014

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Introduction to Linux

Computer Systems and Architecture

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Linux at the Command Line Don Johnson of BU IS&T

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

Introduction to Linux

Introduction to Linux

Practical Session 0 Introduction to Linux

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 UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Lab Working with Linux Command Line

Introduction: What is Unix?

CISC 220 fall 2011, set 1: Linux basics

Introduction to Unix: Fundamental Commands

Linux Shell Script. J. K. Mandal

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

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

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

Introduction to Linux

Linux Kung Fu. Stephen James UBNetDef, Spring 2017

GNU/Linux Course Lesson 1. Puria Nafisi

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Introduction to Linux

Introduction to Linux Environment. Yun-Wen Chen

Computer Architecture Lab 1 (Starting with Linux)

Introduction to Linux. Fundamentals of Computer Science

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Week 5 Lesson 5 02/28/18

Introduction To Linux. Rob Thomas - ACRC

Operating Systems. Copyleft 2005, Binnur Kurt

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

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

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Introduction of Linux

Computer Systems and Architecture

Scripting Languages Course 1. Diana Trandabăț

CENG393 Computer Networks Labwork 1

Introduction. What is Linux? What is the difference between a client and a server?

Linux Essentials Objectives Topics:

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

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]

CSCI 2132 Software Development. Lecture 4: Files and Directories

CS4350 Unix Programming. Outline

System Programming. Introduction to Unix

EKT332 COMPUTER NETWORK

EECS2301. Lab 1 Winter 2016

UNIX Quick Reference

Network Monitoring & Management. A few Linux basics

AN INTRODUCTION TO UNIX

5/8/2012. Creating and Changing Directories Chapter 7

The Unix Shell & Shell Scripts

UNIX Essentials Featuring Solaris 10 Op System

Introduction to the UNIX command line

A Brief Introduction to the Linux Shell for Data Science

Getting your department account

IMPORTANT: Logging Off LOGGING IN

Common UNIX Utilities Alphabetical List

LING 408/508: Computational Techniques for Linguists. Lecture 5

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

CS370 Operating Systems

Outline. Structure of a UNIX command

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

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

Introduction to Linux

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

CS246 Spring14 Programming Paradigm Notes on Linux

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

Week 2. Exp 2 (a) (b): Introduction to LINUX OS, Installation of LINUX OS, Basic DOS commands

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Mills HPC Tutorial Series. Linux Basics I

INSE Lab 1 Introduction to UNIX Fall 2017

2) clear :- It clears the terminal screen. Syntax :- clear

Multiple Choice - 58 Questions - 10 of 15%

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

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Commands are in black

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Unix Workshop Aug 2014

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

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Introduction to Linux Workshop 1

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Linux for Beginners. Windows users should download putty or bitvise:

Introduction of Linux. Huang Cheng-Chao Dept. of Comput. Sci. & Tech. East China Normal University

Unix Introduction to UNIX

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Lecture # 2 Introduction to UNIX (Part 2)

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

Overview of Unix / Linux operating systems

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

LOG ON TO LINUX AND LOG OFF

Transcription:

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

Contents 1. Background on Linux 2. Starting / Finishing 3. Typing Linux Commands 4. Commands to Use Right Away 5. Linux help continued 2

Contents 6. The File System 7. Working with Directories 8. Working with Files 9. Communicating with People 3

1. Background on Linux 1.1. What is Linux? 1.2. History 1.3. Why use Linux? 4

1.1. What is Linux? Linux [ˈlɪnəks] : a Unix-like computer operating system but free and open-source. The Linux Operating System (OS) is a large program (mostly coded in C) that turns the computer into a useable machine. It provides a number of facilities: management of hardware resources directory and file system loading / execution / suspension of programs 5

1969 1971 1977 1980 s 1990 s 1993 2003 2004 1.2. Brief History Unix development started First UNIX published at Bell Labs Berkeley UNIX (BSD) TCP/IP MIT X-Windows The Web, Linux Kernel (1991, by Linus Torvalds) Debian Linux Fedora Linux Ubuntu Linux, CentOS Linux https://upload.wikimedia.org/wikipedia/commons/7/77/unix_history-simple.svg 6

1.3. Why Use Linux? multi-tasking / multi-user lots of free software networking capability graphical (optional) easy to program stable portable (PCs, mainframes, super-computers) continued 7

free! (Ubuntu, CentOS, FreeBSD) open source popular not tied to one company active community lots of documents 8

2. Starting / Finishing 2.1. Your Account 2.2. Login to your Account 2.3. Password Tips 2.4. Logout from your Account 9

2.1. Your Account Each user has their own space, called their account. Type your login ID and password to enter your account. Only if the login ID and password match will you be let in. 10

2.2. Login to your Account login: ad Password: You type your ID and RETURN. You type your password and RETURN. It does not appear. $ The Linux prompt (or similar). You can now enter commands. Access denied Password: Login ID and password not match 11

2.3. Password Tips NEVER tell anyone your password. Don t write it down. A good password is: 8 (or more) characters long uses a mix of uppercase and lowercase letters, numbers, and symbols (e.g. #, %). You can change your password with the passwd command (see later). 12

2.4. Logout from your Account logout or ^D or exit Press CONTROL and D together 13

3. Typing Linux Commands 3.1. The Shell 3.2. Typing Commands 3.3. Control Characters 3.4. Changing your Password 14

3.1. The Shell The Linux user interface is called the shell. The shell does 4 jobs repeatedly: display prompt read command the shell execute command process command 15

Shell Control 16

3.2. Typing Commands Try these: date cal 3 1997 who ls ifconfig man cal clear Press enter for next line; Press spacebar for next page; ^C or q to stop 17

3.3. Control Characters Erasing characters Backspace ^H delete last character delete last character (press CONTROL and H together). ^W ^U delete last word delete the line 18

Very useful control characters ^C terminate command ^S ^Q suspend output resume output 19

3.4. Changing your Password The command is: passwd It will ask you for the new password twice. 21

4. Command to Use Right Away 4.1. Date Commands 4.2. You and the System 4.3. Calculators 22

4.1. Date Commands date Gives time and date cal Calendar cal cal 1997 cal 3 cal 7 1962 cal 9 1752 Not a mistake. Why? 23

4.2. You and the System uptime Machine s up time hostname Name of the machine whoami Your account name 24

4.3. Calculators xcalc Requires x11-apps (sudo apt-get install x11-apps) expr e bc expr 3 + 5 + 7 Simple arithmetic Programmable Calculator 25

Using bc bc 3 + 5 + 7 15 Output ^D bc -l scale=3 150/60 l(30) ^D Use Maths library Set display to 3 dp natural log function 26

bc obase=2 ibase=16 FFC1 ^D Output base Input base 27

5. Linux Help 5.1. On-line Help 5.2. Linux Reference 28

5.1. On-line Help man Manual pages man cal man man apropos topic Lists commands related to topic apropos game Same as man -k apropos help 29

man -k topic Same as apropos whatis cmd whatis find One-line description where cmd which cmd Location of command Location 30

locate cmd locate game List files with cmd in their name (or path) Output of these commands can be very long. See one screenful at a time with: more locate game more apropos print more Press enter/spacebar to go on; ^C/q to stop. 31

5.2. Linux Reference Linux Documentation Project Guides, include: Introduction to Linux GNU/Linux Command-Line Tools Summary The Linux System Administrators' Guide Advanced Bash-Scripting Guide Bash Guide for Beginners The Linux Programmer's Guide ( website: http://tldp.org/guides.html) Linux Network Administrators Guide website: http://www.faqs.org/docs/linux_network Beej's Guide to Network Programming website: http://beej.us/guide/bgnet 32

6. The Linux File System 6.1. An upside-down Tree 6.2. Some System Directories 6.3. Where do you login? 6.4. Pathnames 6.5. Commands and Pathnames 33

6.1. An upside-down Tree A simplified Linux directory/file system: / etc... date... bin cal home dev... tmp... ad....... student exam.txt work hobby.c... proj1... 34

6.2. Some System Directories / /bin root directory commands /etc /dev system data files (e.g. /etc/passwd) files representing I/O devices 35

6.3. Where do you login? Your home directory, which is named after your login ID. pwd showing current directory / student s home dir. home student hobby.c proj1... 36

root Account root: super user, who has the full rights to all resources prompt: # home directory: /root changing to root account: $sudo -i add a new user account: #adduser account-name switching among terminals: Windows: ALT+F1, ALT+F2, Macos: option+command+f1, option+command+f2, try command who and whoami

6.4. Pathnames A pathname is a sequence of directory names (separated by / s) which identifies the location of a directory. There are two sorts of pathnames absolute pathnames relative pathname 38

Absolute Pathnames The sequence of directory names between the top of the tree (the root) and the directory of interest. For example: /bin /etc/terminfo /home/ad /home/student/proj1 39

Relative Pathnames The sequence of directory names below the directory where you are now to the directory of interest. If you are interested in the directory proj1: proj1 student/proj1 if you are in student if you are in home home student hobby.c proj1... 40

6.5. Commands and Pathnames Commands often use pathnames. For example: cat /etc/passwd List the password file 41

7. Working with Directories 7.1. Moving between Directories 7.2. Special Directory Names 7.3. Investigate the System 7.4. Making / Deleting / Renaming Directories 42

7.1. Moving between Directories student s home directory: home student hobby.c proj1... proj2... 43

If you are in directory student how do you move to directory proj1? cd proj1 You are now in proj1. This is called the current working directory. 44

pwd Print name of current working directory Move back to directory student (the parent directory): cd.. 45

When in proj1, move to proj2 with one command: cd../proj2../proj2 is a relative pathname 46

7.2. Special Directory Names /... ~ ~user The root directory The current working directory The parent directory (of your current directory) Your home directory Home directory of user 47

Examples cd / cd ~ Change to root directory Change to home directory cd (Special case; means cd ~) cd ~ad cd../.. Change to ad s home dir. Go up two levels. 48

7.3. Investigate the System Use cd cat file ls cd /etc cat passwd ls ls /etc ls -F a.tcl* List file Directory listing List current dir. List /etc -F option shows types ns-allinone-2.29/ 49

7.4. Making / Deleting / Renaming Directories Usually, you can only create directories (or delete or rename them) in your home directory or directories below it. mkdir rmdir mv Make a directory Delete a directory Rename a directory 50

Create a lab directory in your home directory: cd ~ mkdir lab Create two directories inside the lab directory: cd lab mkdir week1 mkdir week2 51

Delete the week1 directory: rmdir week1 Change the name of week2 to all-weeks mv week2 all-weeks 52

8. Working with Files 8.1. Creating a Text File 8.2. Listing Files 8.3. Filename Conventions 8.4. Other Basic Commands 8.5. Printing 8.6. I/O Redirection 53

A quick way: cat > file 8.1. Creating a Text File This will feed the text you type at the keyboard into file until you type ^D (CONTROL and a D together). A more powerful way is to use vi, a full screen editor (see later). 54

8.2. Listing Files cat file cat hobby.c cat /etc/passwd List the file more file List the file a screen at a time. Type spacebar to go on; ^C to stop 55

less file head file tail file Like more but more powerful List the first few lines List the last few lines 56

8.3. Filename Conventions Many files have a name and an extension: file.c file.cpp file.txt A C program A C++ program A text file However, you can call a file anything. It doesn t have to have an extension. 57

8.4. Other Basic Commands cp file1 file2 mv file1 file2 Copy file1, making file2 Rename file1 as file2 rm file rm -i file Delete file check first 58

wc file grep string file e.g., grep abc test Counts the lines, words, characters in file Search file for string 59

List lines containing Andrew in /etc/passwd grep Andrew /etc/passwd Lines containing printf( in hobby.c grep printf( hobby.c Lines starting with loca in /usr/dict/words grep ^loca /usr/dict/words 60

8.5. Printing lpr file lpq lprm job-number Print file List the print queue. Each print job has a number. Remove that print job 61

You may have to name the printer with the -P option: lpr -Plj5 hobby.c lpq and lprm understand the -P option 62

8.6. I/O Redirection Most commands output to the screen ls Output can be redirected to a file with > : ls > dir.txt cal 1997 > year1997 Output can be appended to a file with >> cal 1997 > years cal 1998 >> years 63

Concatenate two files: cat f1 f2 > fs Input redirection (less common) uses < wc < years Combine input and output redirection: wc < years > year-counts 64

9. Communicating with People 9.1. Information on Others 9.2. Fingering People 9.3. Talking 65

9.1. Information on Others users who ps Who else is logged on? Information on current users What are people doing? 66

w w -sh What are people doing? A shorter report Examine password info: more /etc/passwd grep s38 /etc/passwd 67

9.2. Fingering People finger finger -l Info. on current users Longer information finger user finger ad Information on user (need not be logged in) 68

finger @machine-name User info. for that machine finger @catsix finger @ratree.psu.ac.th ping machine-name ping catsix (^C to stop) Is machine alive (on)? 69

Your Finger Information chfn Change your finger entry finger also prints the contents of the.plan and.project files in your home directory. List. files with: ls -a 70

9.3. Talking talk user talk ad Talk to user (on any machine) talk bill-gates@ratree.psu.ac.th Get out by typing ^C 71