Introduction to Linux Organizing Files

Similar documents
Computer Systems and Architecture

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

Computer Systems and Architecture

Introduction to UNIX Shell Exercises

Linux Command Line Interface. December 27, 2017

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

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

Introduction to Linux

Lab 2: Linux/Unix shell

Mills HPC Tutorial Series. Linux Basics I

UNIX Quick Reference

Perl and R Scripting for Biologists

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

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

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

Command-line interpreters

Introduction to UNIX command-line

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

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

System Administration

Introduction to Unix: Fundamental Commands

Chap2: Operating-System Structures

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

Unix basics exercise MBV-INFX410

Basic Shell Commands

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

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

5/20/2007. Touring Essential Programs

Introduction to UNIX command-line II

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

Linux Command Line Primer. By: Scott Marshall

Introduction to the Linux Command Line January Presentation Topics

Introduction: What is Unix?

Recap From Last Time:

Unix Tools / Command Line

BGGN 213 Working with UNIX Barry Grant

Chapter-3. Introduction to Unix: Fundamental Commands

CSC UNIX System, Spring 2015

Introduction To. Barry Grant

Research. We make it happen. Unix Basics. User Support Group help-line: personal:

Introduction To Linux. Rob Thomas - ACRC

Introduction to Linux Workshop 1

IMPORTANT: Logging Off LOGGING IN

Computer Architecture Lab 1 (Starting with Linux)

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

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

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

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

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

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

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

Introduction to UNIX/Linux

Lab #1 Installing a System Due Friday, September 6, 2002

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

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

Chapter 1 - Introduction. September 8, 2016

CSCI 2132 Software Development. Lecture 5: File Permissions

Introduction to Linux

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

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Unix Basics. Systems Programming Concepts

Introduction to Linux

Working with Basic Linux. Daniel Balagué

Week 2 Lecture 3. Unix

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

Getting Started With UNIX Lab Exercises

Using Linux as a Virtual Machine

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

EECS2301. Lab 1 Winter 2016

Utilities. September 8, 2015

Introduction to UNIX Command Line

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Introduction to the shell Part II

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

Lecture # 2 Introduction to UNIX (Part 2)

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

Cloud Computing and Unix: An Introduction. Dr. Sophie Shaw University of Aberdeen, UK

Cloud Computing and Unix: An Introduction. Dr. Sophie Shaw University of Aberdeen, UK

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


Working With Unix. Scott A. Handley* September 15, *Adapted from UNIX introduction material created by Dr. Julian Catchen

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

CSE 390a Lecture 2. Exploring Shell Commands, Streams, and Redirection

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

Unix Introduction. Part 3

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


Introduction to the Linux for HPC. Basic Linux for Beginner HPC Users

UNIX and Linux Essentials Student Guide

Recitation #1 Boot Camp. August 30th, 2016

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

An Introduction to Unix Power Tools

A Brief Introduction to Unix

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

Linux Essentials Objectives Topics:

CS Fundamentals of Programming II Fall Very Basic UNIX

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

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

Transcription:

Introduction to Linux Organizing Files Computational Science and Engineering North Carolina A&T State University Instructor: Dr. K. M. Flurchick Email: kmflurch@ncat.edu

Arranging, Organizing, Packing 2

Command: sort Sort the lines contained in a file or a group of files, alphabetically, and write the solution to standard output. Very useful when combined with other commands (see pipes and redirections). Format: sort <filenames> Options: -r or --reverse -n or --numeric-sort -k or --key <pos1> [,<pos2>] 3

Command: tar tape archive This name is a misnomer and dates back to when it was used for tapes. Now tar is commonly used to collect together sets of files and directory trees into a single file, which is usually called a tar file and by convention ends with the extension.tar. This archive, or tar file, (or tar ball) is a file that contains other files plus information about them, such as their filename, owner, timestamps, and access permissions. This allows collections of files to be moved around, shared, or transported easily by simply manipulating the single tar file. 4

Options for tar Format: tar <operation> [options] <file(s)> Typical operations: (note, no dash(-) required) c - create x extract t list Options: -v - verbose -z - filter through gzip -f <thisfile> use file thisfile 5

Example: tar Create an archive by tarring up everything in the myproject mydata and mysrc directories: tar cvf myproject.tar myproject mydata mysrc Note: it is usually much better to use relative directory paths so that there are no issues when untarring the archive. List contents of a tar archive: tar tvf myproject.tar Extract all the data from the archive: tar xvf myproject.tar To unzip and untar in one step (note: by convention these files usually have the extension.tar.gz or more commonly,.tgz): tar xzf ncardata.tgz 6

Command: zip and unzip zip and unzip are common utilities for compressing and decompressing files. Format: zip <filename.zip> <list of files to add> filename.zip is the archive file name. <list of files to add> is the list of all the files you want to add to the zip. unzip <filename.zip> To restore use unzip <filename.zip> To list the files in the archive use -t option 7

Command: compress and gzip compress and gzip (gnu zip) are utilities for compressing and decompressing files (which may be or may not be archive files). Format: compress <filename> filename is replaced with compressed filename.z To restore use uncompress <filename.z> gzip <filename> filename is replaced with compressed filename.gz To restore use gunzip or gzip -d 8

Exercise 4 1. Use tar to create the archive files.tar of the scratch directory. 2. Generate a long listing of the directory. (Note the size of the archive file). 3. Compress the file files.tar. 4. Generate a long listing of the directory. (Note the size of the compressed archive file). 9

Pipes and Redirection 10

Redirection Output from programs are: usually written to the screen, referred to as standard output (stdout). Input for programs are: usually comes from the keyboard. If no file arguments are given, referred to as standard input (stdin). Error messages from processes go to another output channel: usually written to the screen, referred to as standard error (stderr). 11

Redirection and Pipes You begin to experience the power of Linux when you combine simple commands together to perform complex tasks. Most (all?) Linux commands can be piped together. Use a - as the value for an argument to mean read this from standard input. 12

Redirection and Pipes > >> < redirects stdout, appends stdout, redirects stdin, Redirecting stderr varies by the shell, use & in tcsh/csh use 2> in bash/ksh/sh pipes (connects) stdout of one command to stdin of another command. 13

Jobs and Processes 14

Command: ps process status This is a snapshot of current processes, and in particular, displays the process id (pid). Options vary somewhat with Linux flavors and you can customize the output, if desired. Examples: show all processes owned by userid. ps u <userid> show every process in long format ps -elf Find all processes of a particular kind labeled by <string>. ps elf grep <string> 15

Command: kill,pkill,ctrl-c Terminate a process. You can only terminate processes you own, unless, of course, you are root. ctrl-c To terminate a process running that hasn t ended. kill <pid> kill processes with the TERM signal. kill -9 <pid> kill processes with the KILL signal -9 (stronger form). pkill <name> looks up process based on name or other attribute (not in all versions of Linux). 16

Command: bg, fg, ctrl-z, & To run a job in the background, just end the command with an &. This allows the job to run and the shell will return control to the user (recall Linux is innately multiprocess). mylongrunningjob & If a job is already running and you want to interrupt it and put it in the background use ^z (ctrl-z) and bg. To return a job to the foreground, use fg. 17

Command: jobs jobs shows all processes running in the background. Use fg %n to move job n to the foreground, if required. fg by itself will foreground the default job. kill %n will kill job n Example: % jobs [1] + Running OracleCalendar/bin/ocal [2] - Running emacs [3] Running mulberry 18

Environment Variables Environment variables are used (sometimes required) by many applications. Environment variables can be modified by you. Environment variables customize the runtime behavior for applications (including the shell). You can save environment variables in a special file called a resource file. 19

1. In your current shell, type env. Try to interpret the results. Try env sort Exercise 5 2.Use setenv to set an environment variable TEST to the value /usr/share. Confirm this using env. 3.Type bash to change your shell. 4.Use alias to create a simple shortcut, alias more to the letter m. 20

Tips and Tricks 21

Command: history tcsh shell Issued as a command, this displays the history of commands used in the particular shell, as a list. In the tcsh shell, set the variables: history number of events saved within a session, savehist number of events saved between sessions.!string will repeat command beginning with string. Use the ^p, ^n keys to page through history or use the up/down arrow keys. You can interactively edit the command line to modify the previous command as needed. Use the left/right arrows, crtl-e end of line, ctrl-a to get to the beginning of the line. 22

Command: history - bash shell Issued as a command, this shows the history of commands, used in the particular shell, as a list. In the bash shell, set the variables: HISTSIZE number of events saved within a session, Histfilesize number of events saved between sessions. The rest works much like it does in the tcsh, except it does not have the searching using the meta keys. Caveat: I m not a bash user so maybe there are redeeming features to it. 23

File Completion To avoid typing mistakes, use file completion. The <tab> character will complete the entry, up to the next non-unique point. tcsh: ^d shows you all possible completions. set autolist which will show you possible completions automatically. You can put this variable in your.cshrc resource file. bash: A second <tab> shows all possible completions. 24

Command: alias This will allow you to create shortcuts for commonly used commands. alias, by itself, will display all the currently (i.e. in the shell you are in) defined aliases. You can pass arguments to alias. Examples: alias ls ls CFA alias lm ls lt \!* more alias h history 25

Good (lots) Linux: The Good, The Bad, and The Ugly Powerful, efficient, secure, stable, widespread, free, developerfriendly, fast, extensible, customizable. Bad (depends on the user) UI needs work, poor plug-n-play support, help may be hard to find (if no one you know uses it). Ugly (rarely) Sometimes arcane syntax. 26

man pages Linux Commands Summary Working with files and directories pwd, cd, ls, mkdir, rmdir, cp, mv, rm, cat, more, less, grep Wildcards *,?, [] Permissions chmod, chgrp Finding stuff find, which, whereis, locate Packing and Unpacking stuff tar, gzip, gunzip, compress, uncompress 27

Linux Commands Summary Cont'd Pipes and redirection >, >>, <, Jobs and processes ps, kill, pkill, ctrl-c (^c), bg, ctrl-z (^z), &, fg, jobs Quick and Easy: shortcuts and tricks of the trade file completion, history, alias 28

Linux is an oral tradition. For More Information man pages, man pages, man pages info command We used some material from: http://www.doc.ic.ac.uk/~wjk/unixintro/index.html 29

Resources Google: http://www.google.com/linux GNU: http://www.gnu.org/ Linux documentation project: http://tldp.org/ O'Reilly: http://www.ora.com/ Red Hat's documentation: http://www.redhat.com/docs/ UNIX: http://www.bell-labs.com/history/unix/moreinfo.html Your distribution's man pages and assorted documentation. 30