Tutorial of Unix Commands

Slides:



Advertisements
Similar presentations
Introduction to Linux command line for bioinformatics Wenjun Kang, MS Jorge Andrade, PhD 6/28/2013 Bioinformatics Core, Center.
Advertisements

Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Introduction to Linux Alan Orth April 17, 2010 ILRI, Nairobi.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
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.
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
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.
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
MCB Lecture #3 Sept 2/14 Intro to UNIX terminal.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
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.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Dedan Githae, BecA-ILRI Hub Introduction to Linux / UNIX OS MARI eBioKit Workshop; Nov , 2014.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface What is the directory tree Some UNIX commands.
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.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
40 Years and Still Rocking the Terminal!
Introduction to Programming Using C An Introduction to Operating Systems.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Linux Commands C151 Multi-User Operating Systems.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
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.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
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.
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.
Tutorial of Unix Command & shell scriptS 5027
Lesson 5-Exploring Utilities
Quality Thought Technologies
Chapter 11 Command-Line Master Class
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.
Web Programming Essentials:
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Shell Script Assignment 1.
Assignment Preliminaries
CSE 374 Programming Concepts & Tools
Linux Basic Commands Visit to more Learning Resources.
INTRODUCTION TO UNIX: The Shell Command Interface
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Introduction to Linux Week 0 - Thursday.
Guide To UNIX Using Linux Third Edition
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
Chapter Four UNIX File Processing.
Introduction Paul Flynn
Tutorial Unix Command & Makefile CIS 5027
Linux Shell Script Programming
Lab 2: Terminal Basics.
Presentation transcript:

Tutorial of Unix Commands Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar/Hector Cen Spring 2018

Outline Introduction How to log in to the servers? How to transfer files between your computer and the server? Unix basic commands

Outline Introduction How to log in to the servers? How to transfer files between your computer and the server? Unix basic commands

What is UNIX? UNIX is an operating system which was first developed in the 1960s It is a stable, multi-user, multi-tasking system for servers, desktops and laptops There are many different versions of UNIX (or based in UNIX): Sun Solaris GNU/Linux MacOS X

The UNIX Operating System Everything in UNIX is either a file or a process A process is an executing program identified by a unique PID (process identifier) A file is a collection of data. They are created by users using text editors, running compilers etc.

The Directory Structure The full path to the file report.doc:   "/home/its/ug1/ee51vn/report.doc" All the files are grouped together in the directory structure The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called root (written as a slash / ) In the diagram above, we see that the home directory of the undergraduate student "ee51vn" contains two sub-directories (docs and pics) and a file called report.doc.  The full path to the file report.doc is "/home/its/ug1/ee51vn/report.doc"

Outline Introduction How to log in to the servers? How to transfer files between your computer and the server? Unix basic commands

How to log in - Windows Download putty (SSH client) from http://www.chiark.greenend.org.uk/~sgtatham/putty/ latest.html PuTTY is a free implementation of Telnet and SSH for Windows and Unix platforms

Connect to the server The host is margay.cs.fiu.edu 1 2 3 4

Log in - Account information Login as : Your FIU username Password : Your first initial + PantherID + Your last initial For example, Steven Jackson with PID 1234567 should have password s1234567j (if you haven’t already changed it)

How to log in - Macos Use the existing SSH client in macOS through Terminal by following the steps: - Search for Terminal from Spotlight, e.g., located on the upper right corner of your screen (or press Command+SpaceBar) - Open Terminal - Connect to the server margay.cs.fiu.edu using the following command: ssh your_FIU_user@margay.cs.fiu.edu - Type your password - Now, you are connected.

How to log in - Macos

Outline Introduction How to log in to the servers? How to transfer files between your computer and the server? Unix basic commands

Transfer files to and from the server You have several options: For Unix-like environments: scp command (secure copy) sftp (through Cyberduck application) For Windows environments: sftp (FTP through SSH) (Filezilla)

Transfer files to and from the server Using scp: Syntax: scp file username@hostname:/destination/folder scp username@hostname:/src/file dest Example: $ scp Project1.docx jdoe001@margay.cs.fiu.edu:/home/bear-b/users/jdoe001 It will copy the file Project1.docx from the local computer to the remote computer and store it in /home/bear-b/users/jdoe001 $ scp jdoe001@margay.cs.fiu.edu:/home/bear-b/users/jdoe001/script.sh Project1/ It will copy the file script.sh from the remote computer to the local computer and store it in Project1 folder

Transfer files to and from the server Using FileZilla (Windows): - Credentials

Transfer files to and from the server Using FileZilla (Windows): - Accept unknown host’s key

Transfer files to and from the server Using FileZilla (Windows): - Connected

Transfer files to and from the server Using FileZilla (Windows): - To upload files to the server

Transfer files to and from the server Using FileZilla (Windows): - File is uploaded to the server

Transfer files to and from the server Using FileZilla (Windows): - To download files from the server

Transfer files to and from the server Using FileZilla (Windows): - File is downloaded from the server

Transfer files to and from the server Using Cyberduck (macOS): - Credentials

Transfer files to and from the server Using Cyberduck (macOS): - Connected

Transfer files to and from the server Using Cyberduck (macOS): - To upload files to the server

Transfer files to and from the server Using Cyberduck (macOS): - File is uploaded to the server

Transfer files to and from the server Using Cyberduck (macOS): - To download files from the server

Outline Introduction How to log in to the servers? How to transfer files between your computer and the server? Unix basic commands

Commands about Files (1) ls : list the contents of your current directory. Format Options -a : list all the files including the hidden ones -l : list not only the filenames but also the related info -t : list content sorted by modification time (newest first) ls [option] [directory][file]

Commands about Files (2) ls : list the contents of your current directory. Format ~ (your home directory) Example: List all the files in your Documents folder ls ~/Documents/ ls [option] [directory] [file] Home directory Documents Desktop Downloads / …

Commands about Files (3) File permission Example: ls –l Field1 : A set of nine permission flags Field2 : link count Field3 : owner of the file Field4 : group of the file Field5 : size in bytes Field 6-8 : Last modification date Field9 : file/folder name

Commands about Files (4) chmod : change the permission flags of the files Format Examples chmod g+w myfile chmod g-rw myfile chmod –R g+rw myfile chmod [option] [types][+/-][types of permission] filename Who: u=user, g=group, o=other, a=all (default) Opcode: + means add permission - means remove permission = means assign permission and remove the permission of unspecified fields Permission r=Read, w=write, x=Execute

Example The sticky bit S should have always been called the "restricted deletion bit" given that's what it really connotes. When this mode bit is enabled, it makes a directory such that users can only delete files & directories within it that they are the owners of.

Commands about Files (5) pwd : print out the current working directory cd : change directory cd . (.) means the current directory C (..) means the parent of current directory Cd cd with no argument will return you to your home directory cd . cd .. cd Use the commands cd, ls and pwd to explore the file system.

Commands about Files (6) cp : copy files Format Options -i : It can be used to avoid overwriting the original file -r : Copy the folder and all the files and subfolders under it. cp [options] File1 File2

Commands about Files (7) scp : securely transfer files between two Unix computers To: From: scp [options] username1@source_host:directory1/File1 local_dest scp [options] local_file username1@source_host:/destination

Commands about Files (8) mv : move a file from one place to another or rename a file. Format mv File1 File2 *.txt : all the files ended with .txt

Commands about Files (9) mkdir : create a directory Format rm : remove files or directories Option -i : ask before actually delete -r : delete the folders and all the files and subfolders under it mkdir directory_name rm [option] file1 file2 file3…

Commands about Files (10) test : A command in Unix that evaluates conditional expressions. Format or The functions will return true if the object exist or the condition specified is true. File functions -d Filename : Filename is a directory -s Filename : Filename has a size greater than 0 -f Filename : Filename is a regular file test expression [ expression ] echo: print a message. It's a handy way to create customized output in your terminal

Commands about File’s contents (1) cat : display the contents of a file on the screen Format head : display the first ten lines of a file to the screen tail : display the last ten lines of a file to the screen cat file1 head –n file1 tail –n file1

Commands about File’s contents (2) wc : word count Format Options -w : find out how many words the file has -l : find out how many lines the file has -m: find out how many characters the file has wc [options] file

Commands about File’s contents (3) grep : It searches files for the specified words or patterns. Format: Options: -c : Display the number of columns which satisfied the pattern. -i : Ignore case distinctions in both the PATTERN and the input files. -v : Invert the sense of matching, to select non-matching lines. grep [options] [pattern] file

Pipe: It treats the output the execution of one command as the input of the next command A | B | C

Commands about Text processing (1) cut : extract sections from each line of a file. Format Option -c : character -f : field -d “:” : delimiter (default is a tab) cut [options] [range] filename

Commands about Text processing (2) Range N-M N- -M cut [options] [range] filename

Commands about Text processing (3) awk: It is a text processing utility on Linux based operating systems. It provides an scripting language of its own. Format: Options: -F : specify the file separator -f : specify the file that will be processed. -v var=val : Assigns a value to a variable before execution of the program begins awk [options] [script] file

Commands about Text processing (4) awk examples: Print the first column of the file latlonpts.txt, specifying the delimiter as ‘,’

Commands about Text processing (5) awk examples: Assign main bulding as the value of the variable pattern. It can be later used to perform operations on text.

Commands about Text processing (6) sort : sort lines of a text file or files Default : sort without any option will sort the file alphabetically Format uniq : remove duplicate adjacent lines from sorted file. sort [option] file

Redirection & Pipes (>, >>, <, |) These are operators that allows us to control and/or redirect the commands output. We will focus on the following: >: Directs the output of the command to a file. >>: Appends or create the output of the command to a file. Creates the file if it doesn’t exist, otherwise appends to it. <: Takes input for a command. |: The pipe operator. It passes the output of one command as the input of another.

Redirection & Pipes (>) Example: To send the output of a command to a file. It sent the output of the command date to a file called today.txt. It creates the file if it doesn’t exist, otherwise overwrites it.

Redirection & Pipes (>>) Example: To append the output of a command to a file. It sent the output of the command who to the end of the file called today.txt. It creates the file if it doesn’t exist.

Redirection & Pipes (<) Example: To take input for a command. It took the contents of the file latlonpts.txt as input for the wc command.

Redirection & Pipes (|) Example: To take input for a command. Dumps the contents of the file sample.txt, which is then piped to the program grep and finally piped as input for the wc program. It can be seen as: command1 | command2 | command3

Commands about Text processing (7) sed: stream editor Detailed tutorial : http://www.grymoire.com/Unix/Sed.html Important function -> Substitution Format : sed 's/term1/term2/g‘ filename

Unix Tutorials for Beginners http://www.ee.surrey.ac.uk/Teaching/Unix/unixin tro.html http://people.ischool.berkeley.edu/~kevin/unix- tutorial/toc.html https://users.cs.duke.edu/~alvy/courses/unixtut/