Introduction to Linux Workshop 1

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

Introduction: What is Unix?

Mills HPC Tutorial Series. Linux Basics I

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

Week 2 Lecture 3. Unix

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

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

Introduction to the UNIX command line

Introduction to Linux for BlueBEAR. January

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

Unix Introduction to UNIX

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

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 Working with Linux Command Line

CS Fundamentals of Programming II Fall Very Basic UNIX

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

A Brief Introduction to the Linux Shell for Data Science

CISC 220 fall 2011, set 1: Linux basics

CSCI 2132 Software Development. Lecture 4: Files and Directories

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Oxford University Computing Services. Getting Started with Unix

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

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]

CS CS Tutorial 2 2 Winter 2018

Perl and R Scripting for Biologists

Introduction to the Linux Command Line

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

CENG393 Computer Networks Labwork 1

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

Exercise Sheet 2. (Classifications of Operating Systems)

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

Outline. Structure of a UNIX command

Chap2: Operating-System Structures

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

Lab 2: Linux/Unix shell

Command Line Interface The basics

Introduction to UNIX Command Line

CS246 Spring14 Programming Paradigm Notes on Linux

Using the Zoo Workstations

UTA Tech Orientation Spring 2019

UNLV Computer Science Department CS 135 Lab Manual

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

LING 408/508: Computational Techniques for Linguists. Lecture 5

Open up a terminal, make sure you are in your home directory, and run the command.

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

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

Unix Tutorial Haverford Astronomy 2014/2015

CS4350 Unix Programming. Outline

Chapter-3. Introduction to Unix: Fundamental Commands

Operating Systems. Copyleft 2005, Binnur Kurt

Working with Basic Linux. Daniel Balagué

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

1. Open VirtualBox and start your linux VM. Boot the machine and log in with the user account you created in Lab #1. Open the Terminal application.

Operating System Interaction via bash

Introduction. File System. Note. Achtung!

The Unix Shell & Shell Scripts

Scripting Languages Course 1. Diana Trandabăț

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

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

CS370 Operating Systems

commandname flags arguments

INSE Lab 1 Introduction to UNIX Fall 2017

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

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

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

Essential Linux Shell Commands

Computer Architecture Lab 1 (Starting with Linux)

Introduction to Unix: Fundamental Commands

Introduction to Linux

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

UNIX Essentials Featuring Solaris 10 Op System

Computer Systems and Architecture

Getting Started With UNIX Lab Exercises

Linux Command Line Interface. December 27, 2017

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

Files

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

Files and Directories

Useful Unix Commands Cheat Sheet

Introduction. SSH Secure Shell Client 1

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Getting Started with UNIX

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

Linux Command Line Primer. By: Scott Marshall

Introduction to Linux

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

5/20/2007. Touring Essential Programs

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

Getting your department account

INTRODUCTION TO BIOINFORMATICS

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

Introduction to Linux

CSCI 2132 Software Development. Lecture 5: File Permissions

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

Exploring UNIX: Session 3

Transcription:

Introduction to Linux Workshop 1 The George Washington University SEAS Computing Facility Created by Jason Hurlburt, Hadi Mohammadi, Marco Suarez hurlburj@gwu.edu

Logging In The lab computers will authenticate with your NetID and password. Please log into the computer you are sitting at.

Course Goals The goal of this tutorial is to provide hands-on training basics of using Linux via the command line. It addresses people who have no previous experience with Unix-like systems, or who know a few commands but would like to know more. Session 1: Using Linux text editors to create documents Commands Modifying file/directory permissions Linux Environment

Introduction Flavors of Linux at GWU Debian/Ubuntu User friendly, most popular for workstations and Windows replacement machines Uses APT package manager Fedora/Redhat/CentOS Enterprise friendly, most popular for servers and datacenters Uses YUM and RPM package managers SuSE Enterprise and user friendly, popular in Europe Uses YaST (Yet another Software Tool) package manager

Introduction Software vs Operating System All Linux systems generally contain the following two types of software: Operating system For the computer Liaison between computer and user Applications Compiled applications - Matlab, Cadence, etc. Programming applications - Python, C, C++, Java, etc.

Introduction Linux Components Kernel: The heart of the operating system It interacts with hardware. Memory management, task scheduling and file management. Shell: The utility that processes your requests. the shell interprets the command and calls the program that you want. Commands and Utilities: eg: cp, mv, cat and grep etc. Files and Directories: All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the filesystem.

Introduction Rules to Live By Linux is case sensitive Always try to use lower case Enter = execute, be careful what you do! ^ = control key Many commands require CTRL+ <another key> TAB = the TAB key will autocomplete commands or file paths if possible

Commands The man command nano Text Editor Command Structure Special Features

Commands Command Structure command command option argument Name of the program you want to run -option not always required provides different behavior than the default You can have more than one argument and bundle them together -option1 option2 or -option1option2 argument What the command acts upon, usually a filename There can be more than one argument Sometimes is not required All commands are executed when you press the Enter key.

Commands The FIRST command man A magical command that will tell you all about other commands usage: man <name of command you need information about> man will show a description of the command you are looking up and all of the switches and options for the command Scroll slowly using down, up arrows Scroll down a page at a time using space bar (down), b (up) Return to the beginning by hitting the g key, exit using the q key Exercise: type man cp (no quotes) and read about the copy command

Command nano Text Editor nano filename edit and modify your text file use command on the bottom of the window to save and exit Exercise: Creating and Opening Files Save and Exit Navigation Copying, Cutting and Pasting Searching and Replacing

Command nano Text Editor Navigation Basic ways to move the cursor Home, End, Page Up, Page Down, and the arrow keys Shortcuts Ctrl+A, Ctrl+E (Home, End) Ctrl+Y, Ctrl+V (Page Up, Page Down) Ctr+F, Ctrl+B (move cursor forward, backward) Ctrl+P, Ctrl+N (move cursor up, down one line)

Command nano Text Editor Copying, Cutting and Pasting Copy, Cut and Paste a single line Alt+6, Ctrl+K and Ctrl+U Move multiple lines Multiple Ctrl+K followed by on Ctrl+U Highlighting Ctrl+6 or Alt-A at beginning, move to end

Command nano Text Editor Searching and Replacing Search Ctrl+W, type string, press Enter. Alt-W to search for the same string again Replace Ctrl-\, type string to search, type string to replace, confirm (Yes, No, All, Cancel)

Commands Special Features Can combine several commands on one line - separate with semicolons Example: cd $HOME; mkdir TestDir; cd TestDir; touch testfile.txt

Commands Special Features The pipe character: usually above the enter key Uses the output of one command and inputs it into a second command Example: ls $HOME grep Test

Commands Special Features > and >> Redirects output to a file > overwrites an existing file or creates a new file >> appends an existing file, or creates a new file Example: ls > dir.txt ls >> dir_append.txt (run this command twice)

Commands Special Features <, << ( input redirection ) redirects input from a file to the preceding command < will simply redirect the input to be used as an argument << will redirect the input to be used in place of responses in an interactive program Note: each response should be on a separate line Examples: python < pythoncommands.txt sort << EOF (End of Data marker)

Commands Special Features Backgrounding a process You can move jobs to the background to reclaim control of the shell while a job runs To send a job to the background: When running the process, append & sign at the end of the command If running: bg %jobid to send back, fg %jobid to bring forward jobs l to get a list of job IDs. Example: 1. type "nano &" at the command prompt 2. Hit enter, then type "jobs" to list all of your jobs 3. type "fg 1" to bring nano back to the front

Commands Remote Connections Secure Shell is the most common command to connect to a remote machine. Usage: ssh userid@remote.machine.domain.name Enter password exit to log off Example: ssh netid@linux[machine number +1].cf.seas.gwu.edu

Commands Exercise Run these commands and take note of the output: date cal 2017 cal 3 2017 finger <username> who whoami echo This is a test!

Files and Directories File Structure Concepts Best Practices Manipulation Search and Wildcards

Files and Directories - File Structure

Files and Directories - Concepts Pathname A path through the directory system pwd shows current path / - the forward slash Represents the very bottom (root) of the file system acts as a divider in between directories on the file system

Files and Directories Getting Around pwd: Print Working Directory, shows you where you are. versus.. : Your current directory versus the directory one level above The ~ character: Shortcut your home directory ls: list current path contents ls la: list all details of the current path in long form cd: change directory cd /absolute/path cd path/relative/to/where/i/am

Files and Directories Exercise Use cd to move around the file system cd to the root of the filesystem Type ls cd to your home directory. There are two ways to do this. Use both cd /home/seas/username cd ~

Files and Directories Best Practices When naming a file or folder, no spaces! No Spaces! NO SPACES! Do not use periods except to identify file extensions good: testfile.txt bad: te.st.fil.e.t.xt (This name is valid but will confuse you sooner or later) This is my very special filename I want to remember.txt Avoid special characters / \ ; -? [ ] ( ) ~! $ { } < > Use file names that help identify the file. good: myresume.doc bad: 1234.doc

Files and Directories Manipulation Create new directories using mkdir command Create new files using text editors, output redirection, or the touch command Example: nano new_file Example: ls -al > pwd_contents Example: touch filename

Files and Directories - Manipulation Another easy way to create a file: Type cat > new_file After this, just start typing Press <Return> to start a new line Use ^d to return to the command prompt View the contents of your newly created file: cat new_file more new_file less new_file

Files and Directories - Manipulation To move or rename a file or directory, use the mv command Move a file to another directory: mv filename dirname Move a directory to another directory: mv src_dir target_dir Rename a file: mv filename newfilename Rename a directory: mv src_dir target_dir

Files and Directories - Manipulation Copy files from one location to another using the cp command Copy a file: cp filename target_dir Copy multiple files: cp filename1 filename2 target_dir Copy a directory: cp -R dirname target_dir Copy multiple directories: cp -R dirname1 dirname2 target_dir

Files and Directories - Manipulation Delete files/directories using the rm command Delete a file: rm filename Delete multiple files at once: rm filename1 filename2 Delete a directory: rm r dirname (or use rmdir) Delete multiple directories at once: rm r dirname1 dirname2

Files and Directories - Search and Wildcards Wildcards can be used to list or find files that meet criteria * : A wildcard is a character that can be used as a substitute for any of a class of characters in a search Examples: ls * ls list* ls jason* ls *jason*.*

Files and Directories - Search and Wildcards grep recognizes patterns in file names or text files and returns files or lines that match the pattern. grep <pattern> filename.txt ls -la * grep <pattern> grep -Ril <pattern> / : will find text pattern inside any file Use quotes if looking for a pattern with a space find searches a file path for filenames that match a pattern find ~/ : find all files in home directory find ~/ -name *.html : find all html files in home directory (case sensitive)

Permissions Format View Permissions Set Permissions

Permissions - Format drwxrwxrwx 10 characters of information First character: tells you whether the listing is a file (-) or a directory (d) Subsequent characters: either r (read), w (write), x (execute), or - (no permission) Characters 2-4: tells you the read (r), write (w), and execute (x) permissions for the owner Characters 5-7: tells you the read (r), write (w), and execute (x) permissions for the group Characters 8-10: tells you the read (r), write (w), and execute (x) permissions for everyone

Permissions - View Permissions d rwx rwx rwx Directory or File Owner Group Other (Everyone) Example ls -la: drwxr-xr-t 2 hurlburj user 2048 Sep 30 10:54 thinclient_drives drwxr-xr-x 2 hurlburj user 2048 Jan 26 10:57 training_dir -rwxr-x--- 1 root bin 175 Sep 22 21:56 usernames.txt -rw------- 1 hurlburj user 44 Sep 22 19:22.vas_disauthcc_478615

Permissions - Set Permissions Modify file permissions using the chmod command Syntax: chmod [u g o a] [+ -] [r w x] arg u = user, g = group, o = other, a = all + will add the permission, - will remove it r = read, w = write, x = execute arg is a filename, a directory name, or a list of either or both For more details, type man chmod Example: chmod u+x file Adds execute permission for the current user on the file named file

Exercise - Create a file and set permissions Make a directory in your home directory Set permissions so everyone can read the directory Create a file inside the directory Set permissions so everyone can read the file Go to the directory and enter pwd Give the directory path to your neighbor and have them run ls on the directory.

Linux Environment Variables Configuration Files Aliases

Linux Environment - Variables Environment variables hold values about your current linux environment, like your text color, home directory location, etc. printenv: shows your currently defined environment variables $PATH and $HOME are two important variables $PATH: list of locations with executables visible systemwide Add locations to $PATH with export : export PATH=$PATH:/path/new Is $PWD a variable? unset : command to remove a variable unset THISISMYVAR

Linux Environment - Configuration Files.profile: stores commands and variable definitions you want every time you log into a shell session. Considered a system wide file.bash_profile: the same as.profile but it only runs when logging into a BASH session. Considered a local file

Linux Environment - Aliases Use the alias command to create command aliases (shortcuts) for commands that are too long to type repeatedly Print a list of aliases: alias p Create a new alias: alias new_ls= ls al Remove an alias: unalias new_ls Add aliases to your.profile to use them every time you login.

Exercise 4. Linux Environment Find the value of your $USER variable with printenv Test your.profile file add ls -la to your.profile add export MYTESTVAR=HELLO to your.profile Close the terminal window and then open a new one Type "printenv" Confirm you can see your new variable

Questions or Requests