Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Similar documents
Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Unix: Fundamental Commands

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

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

Introduction to Linux

Introduction to Linux

Introduction to Supercomputing

Introduction to Linux Workshop 1

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]

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

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

Introduction: What is Unix?

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Introduction to Linux

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

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

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

Practical Session 0 Introduction to Linux

Shell Programming Systems Skills in C and Unix

Lab 2: Linux/Unix shell

CISC 220 fall 2011, set 1: Linux basics

Week 2 Lecture 3. Unix

Introduction to Linux Organizing Files

CS246 Spring14 Programming Paradigm Notes on Linux

5/20/2007. Touring Essential Programs

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

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

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

Files

Mills HPC Tutorial Series. Linux Basics I

Introduction to Unix and Linux. Workshop 1: Directories and Files

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

CSC UNIX System, Spring 2015

A Brief Introduction to the Linux Shell for Data Science

Introduction to Linux Basics

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

Introduction to Linux

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

CS 25200: Systems Programming. Lecture 11: *nix Commands and Shell Internals

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.

Lab Week02 - Part I. Shell Commands. Professional Training Academy Linux Series

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

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

CSCI 2132 Software Development. Lecture 4: Files and Directories

Useful Unix Commands Cheat Sheet

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

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

Introduction to Linux

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

Unix basics exercise MBV-INFX410

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

Outline. Structure of a UNIX command

Linux Shell Script. J. K. Mandal

Command-line interpreters

Unix Tools / Command Line

COMS 6100 Class Notes 3

The Unix Shell & Shell Scripts

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

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

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

Introduction to Linux. Fundamentals of Computer Science

CSE 15L Winter Midterm :) Review

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

CS Fundamentals of Programming II Fall Very Basic UNIX

CS370 Operating Systems

Linux Command Line Interface. December 27, 2017

Exercise 1: Basic Tools

Introduction to Linux

Welcome to Linux. Lecture 1.1

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

Basic Survival UNIX.

Introduction to the UNIX command line

Introduction to the Linux Command Line

Scripting Languages Course 1. Diana Trandabăț

Introduction to UNIX command-line II

Lec 1 add-on: Linux Intro

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

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

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

Perl and R Scripting for Biologists

Introduction to the shell Part II

EE516: Embedded Software Project 1. Setting Up Environment for Projects

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

UNIX File Hierarchy: Structure and Commands

Assignment clarifications

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

EECS2301. Lab 1 Winter 2016

Introduction To. Barry Grant

CS4350 Unix Programming. Outline

Chapter 9. Shell and Kernel

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

Introduction to Linux

Basic Linux (Bash) Commands

Introduction to Linux

Computer Systems and Architecture

CENG 334 Computer Networks. Laboratory I Linux Tutorial

CST Algonquin College 2

UNIX Quick Reference

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Transcription:

310/1779-4 Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006) Linux Refresher (1) Razaq Babalola IJADUOLA These lecture notes are intended only for distribution to participants

Linux Refresher Fourth Workshop on Distributed Laboratory Instrumentation Systems (Trieste - Italy) Razaq Ij aduola 30 October to 24 November 2006

Introduction Linux is a 'UNIX'-like operating system It was launched in 1991 by Linus Torvalds, a Finnish student. Hundreds of people contributed to it and thousands tested and reported bugs. It is therefore extremely stable. Millions of people, institutes and firms are using it now. It is distributed under the 'GNU General License' and it is practically cost-free. You can download it at no cost at all.

At the risk of boring those who know Linux already, I will present some of its features and show you a few commands which hopefully will turn out to be useful in your work during the next weeks (and later!). Practically all present day operating systems are sort of descendants of UNIX: even MSDOS and Windows have taken features of it. Linux is the interface between the hardware of the machine and programs running on it. A program requests services from the system via a system call.

Such a system call could request to read a given sector from disk, or to allocate a block of memory, or to send out a character on the serial port, etc. A user, sitting in front of his terminal, interacts with the system via a command interpreter or shell. The shell translates from some 'jargon' which is not too difficult to understand into sequences of mysterious system calls. There are a number of shells in circulation ('sh', 'ash', 'ksh', 'csh', 'tosh 1, etc.). You are supposed to use bash, the 'Bourne Again Shell'.

Features of Linux Here are some of the features of Linux: r Files are stored in a hierarchical tree structure of directories and subdirectories (/ = top level). Shorthand for directories:. stands for 'present directory'.. stand for 'parent directory' ~ stands for user's home directory. Preference files (hidden files) starts with ".".bashrc,.mozilla/ r Files have access permissions (drwxr-xr-x). file type I owner I group I others (everyone else)

Features of Linux r Files are a collection of bytes. No distinction between file types. r Filenames are not limited to eight characters, there no suffixes. r Linux is a multi-tasking, multi-user, time-sharing system. r Programs of a user are protected against incursions by other users. r Memory can be allocated dynamically. r You must also strongly resist pushing 'reset' or -hitting 'Ctrl-Alt-Delete'.

Linux, with the help of the 'shell 1 is very flexible: Most commands have (lots of) options. You may change the name of the commands, or define (a set of) standard options for each of them: aliases. Examples: alias ts "cd /usr/local/micros/m6809/src/tests" alias cp "cp -p" You can also access files with a sort of 'pseudonym', using 'symbolic links'. In-s targetname linkname Command 'completion': You type: less longf tab' (longf, followed by a 'tab') and the shell translates into: less longfilename.longpostfix if that is an unambiguous, existing filename.

r User environment - a collection of specially named variables that have specific values. They are called environment variables: to view the environment use: env or printenv (depending on the type of shell) EX=/usr/local/micros/m6809/bin r If you now type: $EX/ccO9 -v -o myprog myprog.c the shell will launch execution of: /usr/local/micros/m6809/bin/cc09 -v -o myprog myprog.c Use the echo command to list specific environment variable: ' echo $HOME or echo $EX

An important environment variable is PATH. PATH contains the list of directories where shell will look for the executable specified (by you) on the command line. You can set the PATH: PATH=$PATH:/home/razaq/workarea "Getting help You can get help on practically all commands from the man pages (manual pages). man command It is wise to invoke xman & after logging in. Other way to find help is to use -t for the command option.

Using the commands r You must get accustomed to command names: r 'passwd' for changing the password 'cp' for copy, 'rm' for del, -'Is' for directory list. 'mv' for moving or renaming a file 'mkdir 1 for creating a directory 'chmod' for changing the permission on a file or dir. r 'less' or 'more' or 'cat' for listing the contents of a file r 'ps' for reporting a snapshot of the current processes r 'pwd' for showing the current location or current working directory

When you have logged in, you will find yourself working in your home directory. When login for the first time, you may want to change your password using passwd. You will be asked for your current password and a new one. The contents of the any directory can be listed: Is You move to another directory with: cd dir-path, where 'dir-path' is either a full or a relative pathname.

r If I am in /home/razaq and I want to /home/jim/1 do: cd /home/jim/ or cd../jim/ cd $EX takes me straight to: /usr/local/micros/m6809/bin :o to If you are lost and don't know where you are, usin, pwd will show your current location, creating a new directory: mkdir newdirname

moving a file from one directory to another: mv source existing_dir. can also use mv to rename a file or directory mv source newname To delete a directory: rmdir dir_to_delete To delete a file(s) or directory: rm filename THINK TWICE BEFORE USING rm and rmdir!!!! You can change the permission mode for file and dir. chmod [ugoa] [+-=] [rwx] 1 To display information about the active processes one can use ps: ps [options]

Pipes: command 1 I command2 means: Output from 'command 1' is fed into 'command2' as its input, 'command 1' and 'command2' are so-called filters. Normally when shell launches a command, it waits for its completion. Appending an '&' to a command changes this behaviour: the shell takes back control immediately after having launched the command. Consecutive commands: ; separates two commands; they will be executed one after the other.

Redirection: - > file Output destined for the screen (stdout) is written to 'file'. The file is overwritten.» file As above, but output is appended to existing file. 2> file and 2» file: same as above, but now concerning error output (stderr). < file Input is taken from 'file', instead of keyboard (stdin).

"Grouping commands: (comml ; comm2) any comml and then comm2 will be executed before 'any' thing following after the ')' will be done So, the following is perfectly legitimate (and even very useful!): dump /usr/local f -1 (cd /mnt/usr/local; restore f -)

Shell scripts: You may collect a series of shell commands into a file After having set the execute permission for this file, you can execute its contents with a single command: the name of the shell script. The first executable line in the script must be: #!/bin/sh or #!/bin/bash or similar.

Utility Programs There are a number of utility programs you should be aware of. They can be very useful and you may find yourself using them repeatedly when you are developing software. The programs we want to talk about very briefly are: cat, more, less, whereis, find, grep, tar, and sed.

We will also dwell on: make, gcc, gdb, to conclude with the development cycle: > edit > compile > debug -->

cat, more or less cat filename lists a text file to your screen, you can read the last few lines. more filename does the same, but shows one screenful at a time. (SPC) scrolls one entire page, (RET) one line. less filename does it better: you can go back also, one screenful at a time, typing a' '. cat filel file2 filen > newfile concatenates the files and writes result to newfile. You may also try head and tail.

whereis, find whereis name-of-executable will show where the executable file is stored. find is of much more substance. It will find files of a given name, date, or length or older than date, longer than length, etc. What is more, once a satisfactory file is found, you can make 'find' to do something with it.

whereis, find cont. One can explain 'find' for hours. For now, four "simple" examples: find /usr/bin -name unzip find. -cmin -60 find.. -size +11 Ok find.. -size +110k -printf "\t %s \t %p \ri find.. -size +110k -exec tar zcvf {};

whereis, find cont Reading the 10 or so man pages is a MUST, if you wish to make reasonable use of 'find'.

'tar' stands for 'tape archiving' which was the original aim of this useful program. It is now often used to make a nice compressed package of a (large) number of files: tar zcvf parcel.tar.gz filel file2... filen or tar zcvf parcel2.tgz./* The latter will create (option 'c') verbosely (V) a compressed ('z') tar' file ( ') parcel2.tgz from all files in the current directory. Once created, you can inspect the contents: tar ztvf parcel2.tgz I less

tar continue... You can unpack your 'parcel2.tgz' with tar zxvf parcel2.tgz

'sed' is a "stream editor" or "filter". It works on the contents of an entire file to delete, insert, append lines or replace a string and more. It works non-interactively For this reason you will see sometimes in a Makefile things looking like: itmp="echo $$itmp I sed 's;\.\./;;'"

sed continue... More down-to-earth use are: sed -e 'l,10d' sample.txt -e option to sed tells it to use the next item as command. d command tells sed to delete lines 1 through 10 of the input stream sample.txt.

sed cont... sed s/jim/pablo/g infile > outfile; s means substitute Jim with Pablo. Note that you can use 'sed' in pipes: cat infile I sed -e s/jim/pablo/g >outfile

'grep' is a most useful program: grep -n string *.c *.h will print for you all lines in all '.c' and '.h' files in the current directory where the string has been found, preceded by the filename and the linenumber. Is -1 I grep Vps will show all your '.ps' files and only those

grep continue... Similarly for creation dates: Is -1 I grep May or even: Is -1 I grep \.ps I grep -v May The '-v' option will show all lines that do NOT contain the strins.