Unix Lab Fall 2016. Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.

Slides:



Advertisements
Similar presentations
Linux commands exercise 1. What do you need, if you try to these at home? You need to download and install Ubuntu Linux from the Internet – DVD is need.
Advertisements

Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
1 Introduction to UNIX Ke Liu
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Git/Unix Lab March Version Control ●Keep track of changes to a project ●Serves as a backup ●Revert to previous version ●Work on the same files concurrently.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Chapter 5 Accessing Files and Directories. How Directories Get Created OS installation: usr, dev, etc, export, kernel and others places to store installation.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
Introduction to UNIX GPS Processing and Analysis with GAMIT/GLOBK/TRACK T. Herring, R. King. M. Floyd – MIT UNAVCO, Boulder - July 8-12, 2013 Directory.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  Currently there.
Linux Commands LINUX COMMANDS.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Learning basic Unix command IT 325 operating system.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
2 Manual & Filestore. Introduction Using the manual The UNIX filestore File permissions.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Unix Basics Chapter 4.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
The UNIX development environment CS 400/600 – Data Structures.
Interacting with a UNIX computer: Navigating through the directory tree.
Carnegie Mellon Linux Boot Camp Jenna MacCarley, Peter Pearson, Shashank Goyal 9/19/2015.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
CS252: Systems Programming Ninghui Li Slides by Prof. Gustavo Rodriguez-Rivera Topic 7: Unix Tools and Shell Scripts.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Basic Unix Commands & GCC Saurav Karmakar Spring 2007.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Learning basic Unix command It 325 operating system.
Introduction to Linux Workshop February 15, 2016.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
+ Introduction to Unix Joey Azofeifa Dowell Lab Short Read Class Day 2 (Slides inspired by David Knox)
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
The Command Prompt Commands are the way to “do things” in Unix
Useful Linux Commands.
Eric Shook Department of Geography Kent State University
Shell Script Assignment 1.
Introduction to UNIX.
Using Linux Commands Lab 3.
Introduction to Computer Organization & Systems
Lab 00 Discussion Linux Basics
Andy Wang Object Oriented Programming in C++ COP 3330
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Linux Commands LINUX COMMANDS.
Presentation transcript:

Unix Lab Fall 2016

Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive s.

Bash ●Bash Unix shell is the default shell on Linux and Mac OS X. There are many (many, many) commands. Here we will present the most common/useful.

The File System ●Every file and directory has a path! ●Path: Where the file or directory is located in the file system. ●Unix paths are delimited by forward slashes “ / ” e.g. /home/username/cs3410/pa1

Special Directories Root Directory The Top-Most dir! “ / ” Home Directory Current User’s dir! “ ~ ” Current Directory The dir you’re in! “. ” Parent Directory The dir above! “.. ”

Special Directories ●Absolute paths ●start with “ / ”, i.e the root directory ●Relative paths ●start from your current directory

File System Commands ● cd : Change Directory ● pwd : Print Working Directory ● ls : List Directory contents ● mkdir : Make Directory ●When you log in to VM you are in your Home Directory! ●You can always access it using “ ~ ”

File System Commands $ pwd /home/username $ ls dir1file1 dir2file2 $ mkdir mydir $ ls dir1mydirfile1 dir2file1 $ cd.. $ pwd /home $ cd ~/mydir $ pwd /home/username/mydir $ cd /home $ pwd /home

Create & Delete Commands ● mkdir : Make Directory ● touch : Create an empty file ● rm : Remove the file ● rm –r : Remove dir and files in it recursively ●WARNING: There is no Trash in the Unix File System. If you delete a file or directory, it is gone forever!

$ pwd /home/username $ ls dir1mydirfile2 dir2file1 $ touch myfile $ ls dir1mydirfile2 dir2file1myfile $ rm myfile $ ls dir1mydirfile2 dir2file1 $ rm –r mydir $ ls dir1file1 dir2file2 Create & Delete Commands

Command Options ● rm –r -r makes the rm command run recursively! -r is an option that changes the command! How to know the command options and how to use them?

The most helpful command ● man o Opens the manual page for the command cmd o Man page includes: Usage, Description, Explanation ●If the man page is confusing, you can always try googling the problem!

Command History ●All commands you run are saved! $ history ●Cycle through previous commands with the arrow keys ●Very helpful when executing a small set of commands frequently (e.g. “nano arraylist.c” “gcc arraylist.c”)

Tab completion ●Pressing the tab key will automatically complete whatever you are typing ●If there is more than one thing you could be typing (so tab completion will not work), press tab twice to see the list of possibilities

Redirection $ command > file Send the output of the command to that file. o Creates the file if it does not exist. $ ls ~ > homefiles.txt Writes list of files under Home Directory to homefiles.txt

Redirection $ command > file o Will overwrite the contents of file $ command >> file o Will append the output of command to file

Shell scripting ●You can write programs to do all the things you want in the Unix shell! ●A Shell script is a bunch of commands saved in one executable file. Uses extension.sh

Count files in Directory #!/bin/bash COUNTER=0 for i in $( ls ); do COUNTER=$[$COUNTER+1]; done echo $COUNTER Use bash interpreter Initialize Counter Count Print

Shell scripting ●The Shell file has to be executable! ●Write script, name filename.sh ●Make it executable and execute! ● $ chmod +x filename.sh o will make file executable ● $./filename.sh o execute that file o requires “.” to be used explicitly! (You should google why!)