Research Computing and Cyberinfrastructure Team

Total Page:16

File Type:pdf, Size:1020Kb

Research Computing and Cyberinfrastructure Team Research Computing and CyberInfrastructure team ! Working with the Linux Shell on the CWRU HPC 31 January 2019 7 February 2019 ! Presenter Emily Dragowsky KSL Data Center RCCI Team: Roger Bielefeld, Mike Warfe, Hadrian Djohari! Brian Christian, Emily Dragowsky, Jeremy Fondran, Cal Frye,! Sanjaya Gajurel, Matt Garvey, Theresa Griegger, Cindy Martin, ! Sean Maxwell, Jeno Mozes, Nasir Yilmaz, Lee Zickel Preface: Prepare your environment • User account ! # .bashrc ## cli essentials ! if [ -t 1 ] then bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' bind '"\eOA": history-search-backward' bind '"\eOB": history-search-forward' fi ! This is too useful to pass up! Working with Linux • Preamble • Intro Session Linux Review: Finding our way • Files & Directories: Sample work flow • Shell Commands • Pipes & Redirection • Scripting Foundations • Shell & environment variables • Control Structures • Regular expressions & text manipulation • Recap & Look Ahead Rider Cluster Components ! rider.case.edu ondemand.case.edu University Firewall ! Admin Head Nodes SLURM Science Nodes Master DMZ Resource ! Data Manager Transfer Disk Storage Nodes Batch nodes GPU nodes SMP nodes Running a job: where is it? slide from Hadrian Djohari Storing Data on the HPC table from Nasir Yilmaz How data moves across campus • Buildings on campus are each assigned to a zone. Data connections go from every building to the distribution switch at the center of the zone and from there to the data centers at Kelvin Smith Library and Crawford Hall. slide from Cindy Martin Questions about HPC context? ! slide from Cindy Martin Sample Work Flow • Move Data to the Cluster • Review the “SLURM” script • Resource allocation directives • Data management • Submit the script to the Scheduler • Monitor the job • View details with scheduler tools • Review the data locations • Assess Resource Usage Sample Work Flow • Working in a collective space • /home/<caseid> : be aware of other users in your group(s) • /scratch/pbsjobs/job.<jobid>.hpc : short-term storage for jobs • Preparing scripts is fundamental skill • aids in documentation and reproducibility • scripts for job submission • scripts to manage and evaluate data • Disk usage & Quota management very important Commands in the Shell • Familiar Commands • the necessary: ls, cd, cp, mv, rm. • the useful: pwd, sort, unique, cut, date, [which] • the powerful: find, grep, sed, awk • “Built-In” Shell Commands alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, true, type, typeset, ulimit, umask, unalias, unset, wait Commands beyond the shell • File Content • cat — bring file contents to standard output • less — text buffer viewer (page forward/backward, search) • head/tail — bring ‘head’ or ‘tail’ of a file to stdout • wc — print the number of words or lines in a text buffer • HPC Utilities • quotachk (-grp/ -prj) — check disk usage for account, group or project • remaining — determine time remaining until maintenance shutdown • si — cluster status script Running Commands • Command Line: standard input & output streams • input: 0 < [filename] • stout: 1 >, >> [filename] • sterr: 2 >, >> [filename] ; 2>&1 redirect stderr to stdout Standard monitor Output files Standard Input keyboard & program mouse ls, grep, awk, sed monitors Standard files Error Denotes mem use Redirection Examples - I • Apply Redirection to animals.txt $ cat animals.txt • Comma-separated alphanumeric strings 2012-11-05,deer • 3 i/o streams: input, output & error 2012-11-05,rabbit 2012-11-05,raccoon • Redirection standard input to a file(s) 2012-11-06,rabbit 2012-11-06,deer • Redirect output & error 2012-11-06,fox ➡ a file 2012-11-07,rabbit 2012-11-07,bear ➡ Act upon file contents, redirect to another stream (file or command) ➡ to the same stream (e.g. 2>&1) Redirection Examples - II • Select lines with head, tail • 2012-11-05,deer Replace content using > 2012-11-05,rabbit ➡ head -n 3 animals.txt > anHead.txt 2012-11-05,raccoon ➡ head -n 2 animals.txt > anHead.txt 2012-11-05,deer 2012-11-05,rabbit ! • Append content using >> 2012-11-07,rabbit ➡ 2012-11-07,bear 2012-11-07,rabbit tail -n 2 animals.txt > anTail.txt 2012-11-07,bear ➡ 2012-11-06,fox tail -n 3 animals.txt >> anTail.txt 2012-11-07,rabbit 2012-11-07,bear Redirection Examples - III • Input Redirection < • yachats:data-shell drago$ wc -l animals.txt • 8 animals.txt • yachats:data-shell drago$ wc -l < animals.txt • 8 ! • ‘as if’ command line input • [jump to command line] Pipes • Pipes: Workflows using input/output redirection • command sequences to refine programatic output Standard Standard • monitor Output Standard Output • files Input program program keyboard & ls, grep, awk, ls, grep, awk, mouse sed sed • monitors Standard Standard • files Error Error Read file Denotes mem use Pipe (Text) Buffers Standard Standard Output Input program program ls, grep, awk, ls, grep, awk, sed sed Denotes Standard mem use Error • A text file is stored on disk • A text buffer is defined in memory • Piping command input/output improves efficiency • Standard buffer size may be modified to “tune” process Working with Pipes • Pipes: Workflows using input/output redirection • command sequences to refine programatic output • symbol ‘|’ designates a pipe be applied to cmd output • cmd1 | cmd2 • cat animals.txt | sort -k1,12 # field 1,12th character • cat animals.txt | sort -t , -k2 -k1 # set delimiter ‘,’; primary key, field 2; secondary key, field 1 • cat sunspot.txt | awk ‘NR > 3 {print}' | sort -t ' ' -k4n -k3n | less # numeric sort on each key • cat animals.txt | cut -d ‘,’ -f 2 • cat animals.txt | cut -d ‘,’ -f 2 | sort • cat animals.txt | cut -d ‘,’ -f 2 | sort | uniq -c Working with Pipes - II • cat sunspot.txt: (* Month: 1749 01 *) 58 (* Month: 1749 02 *) 63 ! (* Month: 1749 03 *) 70 (* Month: 1749 04 *) 56 (* Month: 1749 05 *) 85 ! (* Month: 1749 06 *) 84 (* Month: 1749 07 *) 95 ! (* Month: 1749 08 *) 66 (* Month: 1749 09 *) 76 ! (* Month: 1749 10 *) 76 • cat sunspot.txt | awk ‘NR > 3 {print}' | sort -t ' ' -k4n -k3n | less # numeric sort on each key Numeric Sort Alphabetic Sort (applies to complete line) (* Month: 1749 01 *) 58 (* Month: 1754 01 *) 0 (* Month: 1750 01 *) 73 (* Month: 1808 01 *) 0 (* Month: 1751 01 *) 70 (* Month: 1810 01 *) 0 (* Month: 1752 01 *) 35 (* Month: 1811 01 *) 0 (* Month: 1753 01 *) 44 (* Month: 1813 01 *) 0 (* Month: 1754 01 *) 0 (* Month: 1822 01 *) 0 (* Month: 1755 01 *) 10 (* Month: 1823 01 *) 0 (* Month: 1756 01 *) 13 (* Month: 1867 01 *) 0 (* Month: 1757 01 *) 14 (* Month: 1901 01 *) 0 (* Month: 1758 01 *) 38 (* Month: 1912 01 *) 0 Pipes Challenge • Challenge: extract 10 most common cmds from History • commands to use? Pipes Challenge • Challenge: extract 10 most common cmds from History ➡ history — displays from .history file ➡ tr — translate or delete characters ➡ cut — remove sections from each line ➡ sort — sort lines of text input ➡ uniq — report or omit repeated lines ➡ tail — show last lines of input Files Manipulation • The History command — history • history [OPTION]... [FILE]… • Show command history, default location ~/.bash_history • options/settings/notes • !! — repeat the previous command • !n — where n is a command number, repeat the nth command • use the up/down-arrows, and the tab extensions to navigate more freely • export HISTFILESIZE=n change the history line limit to n Files Manipulation • The Translate command — tr • tr [OPTION]... SET1 [SET2] • translate or delete characters • options • - s : (replace multiples from SET1 with single instance) • - d : delete characters in SET1 • e.g. tr -s ‘ ‘ says to replace multiple white space with single w.s. Files Manipulation • The Cut command — cut • cut [OPTION]... [FILE]… • Print selected parts of lines from each FILE to standard output. • - d : delimiter (default is TAB) • - f : select these fields ➡ M-N range selection (Mth through Nth field) ✤ M : this field ✤ -N : first field through the Nth field Files Manipulation • The Sort command — sort • sort [OPTION]... [FILE]… • sort lines of text files (or buffers). default is alphabetic sort. • options • - k [KEYDEF]: the “key” on which to sort ➡ KEYDEF: field number and character-position, + options ➡ e.g. F.[C][OPTS] • - n, h : numerical, human-readable sort Files Manipulation • The Unique command — uniq • uniq [OPTION]... [INPUT] [OUTPUT]] • filter adjacent matching lines from INPUT, writing to OUTPUT • options • - c : prefix lines by number of occurances • - u : only print the unique lines • - d : print the duplicate lines only Pipes Challenge • Challenge: extract 10 most common cmds from History ➡ history — displays from .history file ➡ tr — translate or delete characters ➡ cut — remove sections from each line ➡ sort — sort lines of text input ➡ uniq — report or omit repeated lines ➡ tail — show last lines of input history | tr -s ' ' | cut -d ' ' -f 3- | sort | uniq -c | sort -n | tail Advanced: Managing Selective Output • Example: Preserve header info for cmd/file analysis ➡ Examine account usage with sacct ➡ Sort on elapsed time of job • sacct formatted output (slurm.schedmd.com/sacct.html) ! sacct -a -A <account> -o <format list> | awk! ! • pipes in awk: awk ‘ (condition 1) { cmds }; (condition 2) { cmds} ‘ ! sacct -a -A <account> -o JobId,Elapsed,AveRSS | awk ‘ NR < 3 {print};
Recommended publications
  • Shell Scripting with Bash
    Introduction to Shell Scripting with Bash Charles Jahnke Research Computing Services Information Services & Technology Topics for Today ● Introductions ● Basic Terminology ● How to get help ● Command-line vs. Scripting ● Variables ● Handling Arguments ● Standard I/O, Pipes, and Redirection ● Control Structures (loops and If statements) ● SCC Job Submission Example Research Computing Services Research Computing Services (RCS) A group within Information Services & Technology at Boston University provides computing, storage, and visualization resources and services to support research that has specialized or highly intensive computation, storage, bandwidth, or graphics requirements. Three Primary Services: ● Research Computation ● Research Visualization ● Research Consulting and Training Breadth of Research on the Shared Computing Cluster (SCC) Me ● Research Facilitator and Administrator ● Background in biomedical engineering, bioinformatics, and IT systems ● Offices on both CRC and BUMC ○ Most of our staff on the Charles River Campus, some dedicated to BUMC ● Contact: [email protected] You ● Who has experience programming? ● Using Linux? ● Using the Shared Computing Cluster (SCC)? Basic Terminology The Command-line The line on which commands are typed and passed to the shell. Username Hostname Current Directory [username@scc1 ~]$ Prompt Command Line (input) The Shell ● The interface between the user and the operating system ● Program that interprets and executes input ● Provides: ○ Built-in commands ○ Programming control structures ○ Environment
    [Show full text]
  • Linux Fundamentals (GL120) U8583S This Is a Challenging Course That Focuses on the Fundamental Tools and Concepts of Linux and Unix
    Course data sheet Linux Fundamentals (GL120) U8583S This is a challenging course that focuses on the fundamental tools and concepts of Linux and Unix. Students gain HPE course number U8583S proficiency using the command line. Beginners develop a Course length 5 days solid foundation in Unix, while advanced users discover Delivery mode ILT, vILT patterns and fill in gaps in their knowledge. The course View schedule, local material is designed to provide extensive hands-on View now pricing, and register experience. Topics include basic file manipulation; basic and View related courses View now advanced filesystem features; I/O redirection and pipes; text manipulation and regular expressions; managing jobs and processes; vi, the standard Unix editor; automating tasks with Why HPE Education Services? shell scripts; managing software; secure remote • IDC MarketScape leader 5 years running for IT education and training* administration; and more. • Recognized by IDC for leading with global coverage, unmatched technical Prerequisites Supported distributions expertise, and targeted education consulting services* Students should be comfortable with • Red Hat Enterprise Linux 7 • Key partnerships with industry leaders computers. No familiarity with Linux or other OpenStack®, VMware®, Linux®, Microsoft®, • SUSE Linux Enterprise 12 ITIL, PMI, CSA, and SUSE Unix operating systems is required. • Complete continuum of training delivery • Ubuntu 16.04 LTS options—self-paced eLearning, custom education consulting, traditional classroom, video on-demand
    [Show full text]
  • Bash Crash Course + Bc + Sed + Awk∗
    Bash Crash course + bc + sed + awk∗ Andrey Lukyanenko, CSE, Aalto University Fall, 2011 There are many Unix shell programs: bash, sh, csh, tcsh, ksh, etc. The comparison of those can be found on-line 1. We will primary focus on the capabilities of bash v.4 shell2. 1. Each bash script can be considered as a text file which starts with #!/bin/bash. It informs the editor or interpretor which tries to open the file, what to do with the file and how should it be treated. The special character set in the beginning #! is a magic number; check man magic and /usr/share/file/magic on existing magic numbers if interested. 2. Each script (assume you created “scriptname.sh file) can be invoked by command <dir>/scriptname.sh in console, where <dir> is absolute or relative path to the script directory, e.g., ./scriptname.sh for current directory. If it has #! as the first line it will be invoked by this command, otherwise it can be called by command bash <dir>/scriptname.sh. Notice: to call script as ./scriptname.sh it has to be executable, i.e., call command chmod 555 scriptname.sh before- hand. 3. Variable in bash can be treated as integers or strings, depending on their value. There are set of operations and rules available for them. For example: #!/bin/bash var1=123 # Assigns value 123 to var1 echo var1 # Prints ’var1’ to output echo $var1 # Prints ’123’ to output var2 =321 # Error (var2: command not found) var2= 321 # Error (321: command not found) var2=321 # Correct var3=$var2 # Assigns value 321 from var2 to var3 echo $var3 # Prints ’321’ to output
    [Show full text]
  • Shell Script Getopts Example
    Shell Script Getopts Example Gail is constrainedly cryoscopic after delegable Hilbert sag his parcloses illuminatingly. Gonzales often tootle irresistibly when tripersonal Giordano discomposed dissonantly and buffer her Barbarossa. Robert misdraws rompishly. Find that getopts script example we use later will contain whitespace separation with command Instantly share code, notes, and snippets. OPTARG is set to the period character found. They cease in many cases unneeded and brief fact that cartoon always press them its just like matter of personal coding style. File or directory or found. Operator precedence is used when there within five is more arguments. Typically, shell scripts use getopts to parse arguments passed to them. There did many ways to against your remedy environment. Nothing gets printed when no command line options are provided. The return status is zero unless an outcome is encountered while determining the name avid the he directory within an invalid option is supplied. The exit code will be success failure. Log in charge use details from one require these accounts. How does log lumber and cpu usage by an application? Now consider running it bore an unsupported option. No need only pass the positional parameters through to borrow external program. How can I check took a directory exists in a candy shell script? What extent its purpose? When optional, the fashion can buckle on led off additional functionality, as ugly a boolean option. In those cases, it contains a pointer to that parameter. How environment check ride a variable is set to Bash? Connect and deploy knowledge write a single location that is structured and fatigue to search.
    [Show full text]
  • Pingdirectory Administration Guide Version
    Release 7.3.0.3 Server Administration Guide PingDirectory | Contents | ii Contents PingDirectory™ Product Documentation................................................ 20 Overview of the Server............................................................................. 20 Server Features.................................................................................................................................20 Administration Framework.................................................................................................................21 Server Tools Location....................................................................................................................... 22 Preparing Your Environment....................................................................22 Before You Begin.............................................................................................................................. 22 System requirements..............................................................................................................22 Installing Java......................................................................................................................... 23 Preparing the Operating System (Linux).......................................................................................... 24 Configuring the File Descriptor Limits.................................................................................... 24 File System Tuning.................................................................................................................25
    [Show full text]
  • Bash Guide for Beginners
    Bash Guide for Beginners Machtelt Garrels Garrels BVBA <tille wants no spam _at_ garrels dot be> Version 1.11 Last updated 20081227 Edition Bash Guide for Beginners Table of Contents Introduction.........................................................................................................................................................1 1. Why this guide?...................................................................................................................................1 2. Who should read this book?.................................................................................................................1 3. New versions, translations and availability.........................................................................................2 4. Revision History..................................................................................................................................2 5. Contributions.......................................................................................................................................3 6. Feedback..............................................................................................................................................3 7. Copyright information.........................................................................................................................3 8. What do you need?...............................................................................................................................4 9. Conventions used in this
    [Show full text]
  • ANSWERS ΤΟ EVEN-Numbered
    8 Answers to Even-numbered Exercises 2.1. WhatExplain the following unexpected are result: two ways you can execute a shell script when you do not have execute permission for the file containing the script? Can you execute a shell script if you do not have read permission for the file containing the script? You can give the name of the file containing the script as an argument to the shell (for example, bash scriptfile or tcsh scriptfile, where scriptfile is the name of the file containing the script). Under bash you can give the following command: $ . scriptfile Under both bash and tcsh you can use this command: $ source scriptfile Because the shell must read the commands from the file containing a shell script before it can execute the commands, you must have read permission for the file to execute a shell script. 4.3. AssumeWhat is the purpose ble? you have made the following assignment: $ person=zach Give the output of each of the following commands. a. echo $person zach b. echo '$person' $person c. echo "$person" zach 1 2 6.5. Assumengs. the /home/zach/grants/biblios and /home/zach/biblios directories exist. Specify Zach’s working directory after he executes each sequence of commands. Explain what happens in each case. a. $ pwd /home/zach/grants $ CDPATH=$(pwd) $ cd $ cd biblios After executing the preceding commands, Zach’s working directory is /home/zach/grants/biblios. When CDPATH is set and the working directory is not specified in CDPATH, cd searches the working directory only after it searches the directories specified by CDPATH.
    [Show full text]
  • Linux Cheat Sheet
    1 of 4 ########################################### # 1.1. File Commands. # Name: Bash CheatSheet # # # # A little overlook of the Bash basics # ls # lists your files # # ls -l # lists your files in 'long format' # Usage: A Helpful Guide # ls -a # lists all files, including hidden files # # ln -s <filename> <link> # creates symbolic link to file # Author: J. Le Coupanec # touch <filename> # creates or updates your file # Date: 2014/11/04 # cat > <filename> # places standard input into file # Edited: 2015/8/18 – Michael Stobb # more <filename> # shows the first part of a file (q to quit) ########################################### head <filename> # outputs the first 10 lines of file tail <filename> # outputs the last 10 lines of file (-f too) # 0. Shortcuts. emacs <filename> # lets you create and edit a file mv <filename1> <filename2> # moves a file cp <filename1> <filename2> # copies a file CTRL+A # move to beginning of line rm <filename> # removes a file CTRL+B # moves backward one character diff <filename1> <filename2> # compares files, and shows where differ CTRL+C # halts the current command wc <filename> # tells you how many lines, words there are CTRL+D # deletes one character backward or logs out of current session chmod -options <filename> # lets you change the permissions on files CTRL+E # moves to end of line gzip <filename> # compresses files CTRL+F # moves forward one character gunzip <filename> # uncompresses files compressed by gzip CTRL+G # aborts the current editing command and ring the terminal bell gzcat <filename> #
    [Show full text]
  • January 22, 2021. OFLC Announces Plan for Reissuing Certain
    January 22, 2021. OFLC Announces Plan for Reissuing Certain Prevailing Wage Determinations Issued under the Department’s Interim Final Rule of October 8, 2020; Compliance with the District Court’s Modified Order. On January 20, 2021, the U.S. District Court for the District of Columbia in Purdue University, et al. v. Scalia, et al. (No. 20-cv-3006) and Stellar IT, Inc., et al. v. Scalia, et al. (No. 20-cv- 3175) issued a modified order governing the manner and schedule in which the Office of Foreign Labor Certification (OFLC) will reissue certain prevailing wage determinations (PWDs) that were issued from October 8, 2020 through December 4, 2020, under the wage methodology for the Interim Final Rule (IFR), Strengthening Wage Protections for the Temporary and Permanent Employment of Certain Aliens in the United States, 85 FR 63872 (Oct. 8, 2020). The Department is taking necessary steps to comply with the modified order issued by the District Court. Accordingly, OFLC will be reissuing certain PWDs issued under the Department’s IFR in two phases. Employers that have already submitted a request in response to the December 3, 2020 announcement posted by OFLC have been issued a PWD and do not need to resubmit a second request for reissuance or take other additional action. PHASE I: High Priority PWDs Within 15 working days of receiving the requested list of named Purdue Plaintiffs and Associational Purdue Plaintiffs from Plaintiffs’ counsel, OFLC will reissue all PWDs that have not yet been used in the filing of a Labor Condition Application (LCA) or PERM application as of January 20, 2021, and that fall into one or more of the following categories: 1.
    [Show full text]
  • Linux Networking 101
    The Gorilla ® Guide to… Linux Networking 101 Inside this Guide: • Discover how Linux continues its march toward world domination • Learn basic Linux administration tips • See how easy it can be to build your entire network on a Linux foundation • Find out how Cumulus Linux is your ticket to networking freedom David M. Davis ActualTech Media Helping You Navigate The Technology Jungle! In Partnership With www.actualtechmedia.com The Gorilla Guide To… Linux Networking 101 Author David M. Davis, ActualTech Media Editors Hilary Kirchner, Dream Write Creative, LLC Christina Guthrie, Guthrie Writing & Editorial, LLC Madison Emery, Cumulus Networks Layout and Design Scott D. Lowe, ActualTech Media Copyright © 2017 by ActualTech Media. All rights reserved. No portion of this book may be reproduced or used in any manner without the express written permission of the publisher except for the use of brief quotations. The information provided within this eBook is for general informational purposes only. While we try to keep the information up- to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this book for any purpose. Any use of this information is at your own risk. ActualTech Media Okatie Village Ste 103-157 Bluffton, SC 29909 www.actualtechmedia.com Entering the Jungle Introduction: Six Reasons You Need to Learn Linux ....................................................... 7 1. Linux is the future ........................................................................ 9 2. Linux is on everything .................................................................. 9 3. Linux is adaptable ....................................................................... 10 4. Linux has a strong community and ecosystem ........................... 10 5.
    [Show full text]
  • Great Lakes Cheat Sheet Less File Prints Content of File Page by Page Guide to General L Inux (Bash) a Nd S Lurm C Ommands Head File Print First 10 Lines of File
    Viewing and editing text files cat file Print entire content of file Great Lakes Cheat Sheet less file Prints content of file page by page Guide to general L inux (Bash) and S lurm c ommands head file Print first 10 lines of file tail file Print last 10 lines of file Accessing Great Lakes nano Simple, easy to use text editor Logging in from a terminal (Duo required) vim Minimalist yet powerful text editor ssh uniqname @greatlakes.arc-ts.umich.edu emacs Extensible and customizable text editor Transferring files between Great Lakes and your system scp input uniqname@ greatlakes-xfer.arc-ts.umich.edu: output Advanced file management scp -r i nput uniqname@ greatlakes-xfer.arc-ts.umich.edu:o utput scp uniqname@ greatlakes-xfer.arc-ts.umich.edu:i nput output chmod Change read/write/execute permissions which cmd List the full file path of a command GUI Clients PuTTY SSH client for Windows whereis cmd List all related file paths (binary, source, manual, etc.) of a command WinSCP SCP client for Windows du dir List size of directory and its subdirectories FileZilla FTP client for Windows, Mac, and Linux find Find file in a directory Basic Linux file management Aliases and system variables man command Display the manual page for command alias Create shortcut to command pwd Print out the present working directory env Lists all environment variables ls List the files in the current directory export var = val Create environment variable $ var with value ls -lh Show long, human-readable listing val ls dir List files inside directory dir echo $var Print the value of variable $var rm file Delete file .bashrc File that defines user aliases and variables mkdir dir Create empty directory called dir Input and output redirection rmdir dir Remove empty directory dir $( command) Runs command first, then inserts output to the rm -r dir Remove directory dir and all contents rest of the overall command cd dir Change working directory to dir < Standard input redirection cd .
    [Show full text]
  • Introduction to BASH: Part II
    Introduction to BASH: Part II By Michael Stobb University of California, Merced February 17th, 2017 Quick Review ● Linux is a very popular operating system for scientific computing ● The command line interface (CLI) is ubiquitous and efficient ● A “shell” is a program that interprets and executes a user's commands ○ BASH: Bourne Again SHell (by far the most popular) ○ CSH: C SHell ○ ZSH: Z SHell ● Does everyone have access to a shell? Quick Review: Basic Commands ● pwd ○ ‘print working directory’, or where are you currently ● cd ○ ‘change directory’ in the filesystem, or where you want to go ● ls ○ ‘list’ the contents of the directory, or look at what is inside ● mkdir ○ ‘make directory’, or make a new folder ● cp ○ ‘copy’ a file ● mv ○ ‘move’ a file ● rm ○ ‘remove’ a file (be careful, usually no undos!) ● echo ○ Return (like an echo) the input to the screen ● Autocomplete! Download Some Example Files 1) Make a new folder, perhaps ‘bash_examples’, then cd into it. Capital ‘o’ 2) Type the following command: wget "goo.gl/oBFKrL" -O tutorial.tar 3) Extract the tar file with: tar -xf tutorial.tar 4) Delete the old tar file with rm tutorial.tar 5) cd into the new director ‘tutorial’ Input/Output Redirection ● Typically we give input to a command as follows: ○ cat file.txt ● Make the input explicit by using “<” ○ cat < file.txt ● Change the output by using “>” ○ cat < file.txt > output.txt ● Use the output of one function as the input of another ○ cat < file.txt | less BASH Utilities ● BASH has some awesome utilities ○ External commands not
    [Show full text]