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

Similar documents
Introduction to Linux for BlueBEAR. January

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

Introduction: What is Unix?

Perl and R Scripting for Biologists

Introduction to Linux Workshop 1

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

Computer Systems and Architecture

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to the Linux Command Line

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

Introduction to Linux Organizing Files

A Brief Introduction to Unix

Computer Systems and Architecture

Chapter-3. Introduction to Unix: Fundamental Commands

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

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

Introduction to Linux

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

The Unix Shell & Shell Scripts

Linux Essentials Objectives Topics:

Unix Tutorial Haverford Astronomy 2014/2015

unix intro Documentation

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

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

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

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

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

Lab 2: Linux/Unix shell

Introduction to UNIX/Linux

Introduction to the shell Part II

Introduction to Linux

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

Lab 1 Introduction to UNIX and C

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Introduction of Linux

Mills HPC Tutorial Series. Linux Basics I

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

Linux Command Line Interface. December 27, 2017

Week 1: Linux Intro. The Command Line Interface

Introduction to the Linux Command Line January Presentation Topics

CS CS Tutorial 2 2 Winter 2018

Introduction To. Barry Grant

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

CS Fundamentals of Programming II Fall Very Basic UNIX

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

Basic Linux Command Line Interface Guide

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

Introduction to Linux

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

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

Basic Linux Command Line Interface Guide

Introduction to Unix: Fundamental Commands

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.

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

Lab Working with Linux Command Line

Part 1: Basic Commands/U3li3es

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

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.

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

Course 144 Supplementary Materials. UNIX Fundamentals

Linux crash lecture by Andrey Lukyanenko

Exercise 1: Basic Tools

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

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

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

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

Linux Command Line Primer. By: Scott Marshall

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Short Read Sequencing Analysis Workshop

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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

Useful Unix Commands Cheat Sheet

Tutorial-1b: The Linux CLI

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

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

Chapter 1 - Introduction. September 8, 2016

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

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

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

Introduction to Linux

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

Introduction to UNIX Command Line

UNIX Essentials Featuring Solaris 10 Op System

CS 460 Linux Tutorial

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

CISC 220 fall 2011, set 1: Linux basics

UNIX Quick Reference

No Food or Drink in this room. Logon to Windows machine

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Recap From Last Time:

Linux Systems Administration Getting Started with Linux

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

UNIX. Basic UNIX Command

BGGN 213 Working with UNIX Barry Grant

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

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

Computer Architecture Lab 1 (Starting with Linux)

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

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

Transcription:

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

Linux/UNIX/BSD/OSX/what? v All different v UNIX is the oldest, mostly now commercial only in large environments (e.g. banking mainframe) v Practically from a user perspective, the same v Focus on command line tools

Distributions of Linux v Groups of software at specific versions v Lots of them: Red Hat Fedora Suse Debian Ubuntu Mint..

Remote graphical applications v UoB only provide BlueBEAR v No graphical desktop (Gnome/KDE/Unity) v Remote connection via ssh (PuTTy) v X server running for graphical applications Exceed (UoB desktops) Xming (free) Xquartz (OSX)

Practical v http://www.birmingham.ac.uk/bear Then follow these links in order: v Services v Linux Compute (BlueBEAR) v Access & File Transfer v Windows software to access BlueBEAR v the help page for installing and configuring PuTTY and Exceed (last paragraph of the Windows software to access BlueBEAR section) or v http://tinyurl.com/bear0915

Graphical text editing v From the command prompt run gedit to get a graphical text editor running on the remote system v In the X server you have two copy buffers Copy and paste, as normal Middle click buffer

Exceed (useful tip) v Select text to place it into the copy buffer v Middle click to paste text

A word about directory layout v Unlike Windows (and DOS systems) there are no drives (i.e. no C:\, D:\, U:\ etc.) v Everything exists under a directory, /, called the root directory. v Useful directories to know: /home each user usually has a directory here with their own files in it, known as their home directory. v On BlueBEAR users home directories are located at /gpfs/bb, not /home, for technical reasons, but /home still exists. /tmp temporary files. Any user can create files in this directory. Often deleted when the computer reboots. v On BlueBEAR there is also /scratch on each compute node which is for the same purpose but much larger.

What is a path? A concrete strip to the bottom of the garden v Where the system looks to find programs echo $PATH v Command not found the program isn t in your path

Welcome to the command line v Files and programs are CaSe-SeNsItIvE v You type commands into a program called the shell v Commands are case-sensitive v The tab key is magic, pressing it: once: complete the current command or filename if there is 1 match twice: list all the matching options if there is more than 1 match

Command line syntax v Varies from program to program v Typically of the form tar -cpf foo.tar ~/to_archive/ <command> -<character> <argument> <file> tar -cpf foo.tar ~/to_archive/

Help? How do I use this command? v Each command should have a manual page for it. To view it type man command, e.g. to view the manual for the man command type: man man Press q to quit, use the arrow keys to scroll

Looking at your files v Basic file commands: ls list files cd change directory pwd print current (working) directory

Looking at your files (continued) v Basic file commands: less filename view the contents of your (text) files (press q to quit), space to page down, up/down arrows

Looking at your files (continued) v Basic file commands: tail -f filename watch the end of file as it grows

Organising your files v Basic directory management commands: mkdir newdirectory create directory rmdir directory remove directory (only works if directory is empty)

Organising your files v Basic file management commands: touch file create an empty file rm file remove a file (there is no recycle bin!) cp file newfile copy a file (creates a duplicate) mv file newfile move a file (renames the file)

dot files and directories v User config settings stored in them v Please don t delete! v Useful ones to edit (to set things every time you login):.bash_profile.bashrc BUT BE CAREFUL!

Links v There are two types of links on unix systems: symbolic links known as symlinks, like a shortcut to the file hard links a new reference to the same file (you are very unlikely to ever use these) v Creating a symlink: Use the ln link command with the -s, symlink, option. E.g. to create a link to /gpfs/bb/username/myfile called /tmp/link_to_myfile type: ln s /gpfs/bb/username/myfile /tmp/link_to_myfile

Users and groups v Username maps to a numeric UID Command id returns details v Member of least one group v Group names map to a numeric GID Command groups lists your groups groups username

User permissions v By default users have no special permission v root is equivalent of administrator v Command su - username would change to that user if you know the password v Modern systems use sudo to do commands with elevated permission (or as another user) v UoB central systems don t allow sudo or su to normal users

File Permissions v Files (and directories) can have different permission sets for groups and users Files r read the file w write to the file x execute (run) Directory r list contents of directory w create new files/folders x traverse (e.g. cd to directory)

File Permissions v Try doing ls ld ~/ v This shows permissions on home directory v First character indicates file (-), directory (d) or link (l), next 3 characters is user, next 3 group, final 3 is all other users v + sign indicates extended ACLs applied

File permissions mkdir testdir touch testdir/testfile chmod is used to change permissions chmod g+rwx testdir (then check with ls -ld testdir) chmod o+x testdir/testfile

File permissions v As well as using rwx etc, bit masks can also be used, the following are equivalent: chmod 755 directory chmod u+rwx,go+rx directory

Shell variables v Lots set at login env v Can set own export FOO=bar echo $FOO Value of $FOO is now available to other things in shell v ~/ - shortcut to home directory v ~someuser/ - shortcut to another user home directory

Some useful tools v grep string filename Look for string occurrences in the file grep ldap /etc/nsswitch.conf What does do? grep c ldap /etc/nsswitch.conf

Some useful tools v diff file1 file2 Shows the differences between two files diff /etc/nsswitch.conf ~/nsswitch.conf

Editing files v Can edit from Windows and use share Windows files use different line endings dos2unix ~/filename v Lots of editors under Linux nano is a basic, easy to use one Others joe, vim, emacs

Editing files v Create and edit a new file in home directory: nano ~/testfile.txt Type in some text Save the file with CTRL+o Exit with CTRL+x Check the contents of the file (Remember cat or less?) Edit the file again, try CTRL+k, CTRL+u, CTRL+w to see what they do

Pipes and redirection v (pipe) can be used to send output of command into another ls al /gpfs/bb grep $USER v > redirects the output of a command E.g. to a file STDOUT STDERR 2>&1

Pipes and redirection v Try these: ls al /gpfs/bb grep $USER ls al ~/ > ~/ls.output Cdgffgffg > ~/error.output Cdgffgffg > ~/error.output 2>&1

Scripts v Allow series of commands to be repeated v Can pass arguments in, use variables etc. v Need to be executable to run from command line v First line shows the interpreter (or shell) to use, e.g. #!/bin/bash #!/usr/bin/perl

Scripts v Use the text editor to create a new script file to: Create a directory (mkdir) Change to a directory (cd) List the directory contents with all details (ls) Create a new empty file (touch) List the directory contents with all details (ls) v Remember to set the shell in the first line #!/bin/bash v Make it executable (chmod) v Run the script./scriptname (You could also try redirecting the output to a file)

Scripts #!/bin/bash mkdir ~/tempdir cd ~/tempdir ls -al touch somefile ls -al

Archiving and compressing v A tar file (traditionally tape archive) is a way of grouping a set of files together into a single file v gzip or bzip2 are often used to compress files v So for example a.tar.gz file would be similar to a zip file

Archiving and compressing v Create a new tar file, being verbose of the files, preserving file permissions: tar -cvpf ~/newfile.tar ~/testdir v Compress the file: gzip -9 ~/newfile.tar v List contents of compressed file: tar -tzf ~/newfile.tar.gz v Extract contents to a new directory: mkdir ~/newdir cd ~/newdir tar -xvzpf ~/newfile.tar.gz

Process management v Everything you execute causes at least 1 process to be generated v Programs which fork may create multiple subprocesses v The command top shows the processes running using most CPU (q to exit)

Process management v Processes may be in several different states: Running in foreground Suspended (stopped, no further processing happens) Backgrounded (running but no longer attached to terminal) Zombie (In a bad way, typically no longer doing anything useful)

Process management v Command line processes can be stopped using CTRL+z v Running bg will then background the process v Jobs lists processes from the current terminal and their state v fg returns a suspended or background process to the controlling shell

Process Priority v Each process has a priority which determines how much CPU time will be allocated when the CPU is busy with many applications v renice can be used to change the priority of a process (users can only reduce) v On shared systems, it is sociable to renice heavy compute processes which you are leaving running

Looking for processes v The command ps will list your running processes and their processid v ps -ef grep vi Would look for processes called vi

Signals v Signals are used to tell processes to do something, typically: To tell a process to reread a config (HUP) To tell a process to terminate (TERM) To forcefully kill a process (KILL) HUP and TERM rely on signal handler in code kill -SIGNAL processid

Any questions?