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

Similar documents
Introduction: What is Unix?

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Mills HPC Tutorial Series. Linux Basics I

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

A Brief Introduction to Unix

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Introduction to Linux

CSCI 2132 Software Development. Lecture 4: Files and Directories

UNIX Essentials Featuring Solaris 10 Op System

Working with Basic Linux. Daniel Balagué

Linux Bootcamp Fall 2015

Perl and R Scripting for Biologists

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

Session 1: Accessing MUGrid and Command Line Basics

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction of Linux

Lab 2: Linux/Unix shell

Laboratory 1 Semester 1 11/12

Introduction to the Linux Command Line

Practical Session 0 Introduction to Linux

Introduction to the UNIX command line

CS CS Tutorial 2 2 Winter 2018

CISC 220 fall 2011, set 1: Linux basics

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.

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

Scripting Languages Course 1. Diana Trandabăț

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

Chapter 4. Unix Tutorial. Unix Shell

Linux Command Line Primer. By: Scott Marshall

Introduction to Linux

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

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

Command Line Interface The basics

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

The Unix Shell & Shell Scripts

Chapter-3. Introduction to Unix: Fundamental Commands

Unix Tutorial Haverford Astronomy 2014/2015

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

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Introduction to Linux

Lab 1 Introduction to UNIX and C

Lab Working with Linux Command Line

The Directory Structure

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

Short Read Sequencing Analysis Workshop

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

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

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Unix Basics. Systems Programming Concepts

Introduction to Linux Workshop 1

Week 2 Lecture 3. Unix

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

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

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

Computer Systems and Architecture

Linux Tutorial. Ken-ichi Nomura. 3 rd Magics Materials Software Workshop. Gaithersburg Marriott Washingtonian Center November 11-13, 2018

This is Lab Worksheet 3 - not an Assignment

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

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

Introduction To. Barry Grant

Introduction to Linux for BlueBEAR. January

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

INSE Lab 1 Introduction to UNIX Fall 2017

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Linux & Shell Programming 2014

Introduction to Unix: Fundamental Commands

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

Linux Shell Script. J. K. Mandal

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

UNIX Tutorial Two

Getting Started With UNIX Lab Exercises

Part 1: Basic Commands/U3li3es

A Brief Introduction to the Linux Shell for Data Science

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Files and Directories

CHAPTER 1 UNIX FOR NONPROGRAMMERS

COSC UNIX. Textbook. Grading Scheme

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

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

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

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

CSE 391 Lecture 1. introduction to Linux/Unix environment

Helpful Tips for Labs. CS140, Spring 2015

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

CSCI 2132 Software Development. Lecture 5: File Permissions

Using the Unix system. UNIX Introduction

Recap From Last Time: Setup Checklist BGGN 213. Todays Menu. Introduction to UNIX.

CENG393 Computer Networks Labwork 1

Linux Command Line Interface. December 27, 2017

A Hands-On Tutorial: RNA Sequencing Using High-Performance Computing

The Unix Shell. Pipes and Filters

Unix Tools / Command Line

Computer Systems and Architecture

Introduction to UNIX. Introduction EECS l UNIX is an operating system (OS). l Our goals:

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

commandname flags arguments

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

Transcription:

Unix/Linux Basics 1

Some basics to remember Everything is case sensitive Eg., you can have two different files of the same name but different case in the same folder Console-driven (same as terminal ) Each console runs a shell program, which is basically a process. Each shell has a prompt and you can provide commands to run on that prompt. Eg., $ ls would list the current folder contents (where $ is the prompt automatically displayed by shell.) shell is the equivalent of the explorer in Windows Use forward slash / to separate directory hierarchies Eg., the command $ ls ~/subfoldera/file1.c lists 2

Directory Structure In Unix, the directory structure is a tree, with a root (denoted by / ). The default folder that shows up when you open a new terminal is your home directory, which is also aliased by the symbol ~ cd ~ will take you to home directory from wherever you are currently. Note that if you just type in just cd without any arguments the effect is same as cd ~ cd.. will take the console to the parent directory cd. has no effect as. represents current folder You can specify a folder s path in two different ways: absolute and relative relative to the current folder: eg., cd A/B/C/ will be change the present working directory to a subfolder named A under., and then from it will jump two more subfolders to B and C similarly absolute path is the path relative to the root. Eg., cd /usr/bin will change to the usr/bin folder under the root pwd will always show the absolute path of the current folder Both relative and absolute paths can be interchangeably used, but absolute paths are generally preferred over relative within source codes so that one can run the program from anywhere 3

Basic commands ls man mkdir cd cd ~ cd. cd.. pwd Directory listing Manual for any system command Eg., man ls will show the help on the ls command and all its options Make a new directory Change directory to a target folder Eg., cd subf would change the shell to a folder by name subf under the current working folder Change to home directory Change to current directory (does nothing) Change to parent directory Displays full path of the current/present working directory 4

Basic commands echo hello there echo hello there > a cp a b mv a b Prints hello there to standard output (stdout) Prints hello there to a new text file called a in the current working folder Copies file a into b (overwrites b if it already exists!) Renames file a into b (overwrites b if it already exists!) clear cat a more a less a head lines=10 a tail lines=10 a Clear screen Prints out the contents of the text file by name a Prints out the contents of the file a but screen by screen Same as the more command except that you can scroll up too Prints the first 10 number of lines of file a Similar to head but prints the last 10 lines of the file 5

Basic commands grep hello a wc a cat a > b Find and report all lines containing the pattern hello in text file a Report word, character and line counts of file a Prints contents of file a and redirects the standard output to a file b. (Overwrite hazard) cat a >> b chmod ps top Same as cat a > b except that if b already exists before this command is run, then the contents of a are appended to b This is called pipe command. Eg., $ cat a grep hello would pass the standard output of the cat a command into the input of the grep command Access permission to files and directories (do a man chmod for more information) Lists all processes running on the current shell (do man ps to learn about more ps options) Lists all the currently running processes on the system with all their details such as memory, CPU usages, etc. Very useful command. 6

Basic commands script This will record all that is output on the console into a text file called typescript until you type exit command Eg., $ script $ ls a.txt b.txt c.txt $cp a.txt b.txt $exit The above sequence of commands records all the console stdouts onto the file typescript. So you can test that by $ cat typescript 7

Basic commands rm rm i rmdir rm r This is the command to remove files. Interactive option. You will be asked for a confirmation before the remove happens. This is the safest option that will prevent you from deleting a file by mistake. You can make this the default setting for rm so that you don t have to type -i option everytime. This can be done by typing the command export rm=rm i. After you run this command all rm will internally call rm i. But all this will hold good only for the current working terminal session. If you open a new terminal or logoff & login again, you will have to type the export command again. This can be avoided by directly including the export command line in the.profile or.bashrc files in your home directory. (see man pages on rm) This is deleting an empty folder. This is for deleting a folder and recursively all its contents 8

Lots of online tutorials.. http://www.ee.surrey.ac.uk/teaching/unix/ 9

Compiling & Running C++ Code A sample test code has been provided on this website: http://www.eecs.wsu.edu/~ananth/cpts223 /Codes/Test/ Follow the instructions in the readme file to successfully compile and test the C++ code 10

Editor options There are two popular editors for editing source code vim Emacs Links to a couple of online tutorials are on WebCT 11

More Exercises Open 2 new files using the editor of your choice (vim, emacs), and write your own TestPrinter.cc and Printer.cc code. The idea is to get to used to source-coding using these editors. Also experiment with the script command and redirect commands Peruse through man pages of each command listed in the previous slides Understand relative vs. absolute path Get familiar with as many commands and their options as possible 12