"Two of the most famous products of Berkeley are LSD and Unix. I don't think that this is a coincidence.” Anonymous.

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Working with Files How to create, view, copy, rename and print files.
Lab6 CPCS361 I.Mona Alshehri. Working with Files and Directories Creating files Create a file with the cat command type the command cat > name_of_file.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
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.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
CS 497C – Introduction to UNIX Lecture 12: - The File System Chin-Chih Chang
Chapter 7 Advanced Directory and File Management.
The Unix Shell. Operating System shell The shell is a command interpreter It forms the interface between a user and the operating system When you log.
CSE 303 Lecture 2 Introduction to bash shell
Guide To UNIX Using Linux Third Edition
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Notes Assignment #1 is due next Friday by 11:59 pm via Test #1 will be held Thursday February 18 at the start of class (one period long) Format:
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”
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.
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
Working with Files Chapter 5. Display a Calendar Display a calendar for a specific month – cal Display a calendar for a specific year – cal 2000.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
Introduction to Unix – CS 21 Lecture 4. Lecture Overview * cp, mv, and rm Looking into files The file command head and tail cat and more What we’ve seen.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Introduction to UNIX Geraint Vaughan. What is UNIX? Command-line operating system (not point- and click) Designed for ‘experts’ Lots of different variants.
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 8: The UNIX File System Continued 1 of 44 Copyright ©2008 by Pearson Education, Inc. Upper.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
1May 16, 2005 Week 2 Lab Agenda Command Line FTP Commands Review More UNIX commands to learn File name expansion - * Introduction of vi.
Manipulating Files Refresher. The touch Command touch is used to create a new, empty file. If the file already exists, touch updates the time and date.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Linux - Ubuntu LECTURE TWO. Objective: Enable students to understand the practical side of Linux operating system. Understand and implement the following.
Linux Commands C151 Multi-User Operating Systems.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson
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.
Learning Unix/Linux Based on slides from: Eric Bishop.
1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full.
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.
Getting started with CentOS Linux
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
Exploring Shell Commands, Streams, and Redirection
Basic UNIX OLC Training.
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
The Unix File System.
Chapter Four UNIX File Processing.
Exploring Shell Commands, Streams, and Redirection
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Tutorial Unix Command & Makefile CIS 5027
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
A shell is a user interface.
Exploring Shell Commands, Streams, and Redirection
LPI Linux Certification
Presentation transcript:

"Two of the most famous products of Berkeley are LSD and Unix. I don't think that this is a coincidence.” Anonymous

Basics of the Unix/Linux Environment Common Commands

Making directories mkdir: make directory % mkdir bin src Projects Classes Makes 4 directories: bin, src, Projects, and Classes in the working directory.

Removing Directories rmdir: remove directory; only works with empty directories but is safe % rmdir bin src Projects Classes Removes the 4 directories bin, src, Projects, and Classes in the working directory -- if they are EMPTY.

Removing files and directories rm: remove files and directories; a very straightforward and DANGEROUS command There is no trash can on a unix machine. CERI accounts are set up so that rm is aliased to rm – i, which means the computer will ask you if you really want to remove the file(s) one at a time %which rm rm: aliased to /bin/rm –i

%rm file1 remove file1? yes % Valid answers. Yes, yes, Y, y – to accept and erase. No, no, N, n – to not erase. - does not erase. Something it does not understand – does not erase.

rm –d: remove directory like rmdir rm –r: remove directory and all subdirectories and files; implies –d; can be very dangerous… one typo could remove months of files % rm -r Classes \rm: You can return to the original definition of rm using the “\”. You will no longer be prompted before a file is removed so don’t make a typo

Looking at files more: browse or page through a text file; opens file quickly and pages down full screen; use space bar to page down less: same as more but allows forward and backward paging; in OSX, more is aliased to less because less is more with additional features

Looking at files continued head -nX: prints the first X number of lines to the screen; default is 10 lines if -n is not specified tail -nX: prints the last X number of lines to the screen; default is 10 lines if -n is not specified (mac/linux) tail -Xf: prints the last X number of lines to the screen; default is 10 lines if -f is not specified (ceri suns)

Manipulating files cat: concatenate files into a single column; it dumps the entire file contents to the screen unless redirected to a file o Since it dumps the entire file contents to the screen, we can use it to “print out” or ”type out” a file. %cat dead.letter Hello...testing Another Unix philosophy issue – use of side effects. We don’t need another command to print or type the contents of a file to the screen as it is a side effect of the cat command.

Example: make one file out of file1, file2 and file3 and call it alltogether. %cat file1 file2 file3 > alltogether or %cat file1 file2 file3 This command (does not need input redirection, exception to regular rule that input comes from Standard IN) takes files file1, file2, and file3 and puts them into file alltogether or you can skip creating the file alltogether

Creating files using cat - type the command %cat > name_of_file Now type in your text. Press the key to start a new line. When you have finished typing in your text, enter Ctrl-d (Press and hold down the Ctrl key and type a "d"). This stops the cat command and returns you to the system prompt. %cat > test.file Hello everyone CNTL-D %more test.file Hello everyone

paste: concatenate files with each file a new column; when used on a single file, it dumps the entire file contents to the screen

Piping and Redirect Input and output on the command line are controlled by the |, >, <, and ! symbols | : pipe function; sends the output from command on left side as input to the command on the right side % cd SACdata % ls | head -n

Piping and Redirect > : redirect standard output (screen) to a specific file* % cd SACdata % ls | head -n5 > directory.list % more directory.list * In tcsh, this will not overwrite a pre-existing file with the same name. In bash shell, the > overwrites any pre-existing file with no warning

Piping and Redirect >! : redirect standard output (screen output) to a specific file and overwrite the file if it already exists * % ls | head –n5 >! directory.list % more directory.list *This syntax is specific to tcsh, your default CERI shell; in bash this will put the output into a file named !

Piping and Redirect >> : concatenate standard output (screen output) to the end of a specific file % ls | head –n2 >! directory.list % ls | tail –n2 >> directory.list % more directory.list tmp tmp.file < : redirect file on right as input to command on the left % head –n1 < suma1.hrdpicks

Copying, moving, or linking files & directories cp: copy files cp -r: copy directory and all files & subdirectories within it % cp file1 Project/SUMATRA/file2 % cp file1 Project/SUMATRA/.

mv: move files or directories % mv file1 file2 Project/SUMATRA/. If you want to change the names when you move them, you have to do them one at a time % mv file1 ESCI7205/HW/HW1 % mv file2 ESCI7205/HW/HW2

ln -s: create a symbolic link between two files % ln –s sourcefile1 Project/SUMATRA/targetfile1 % ln –s sourcefile1 Project/SUMATRA/. This makes the file show up in the new directory (the target) listing, but the file really only exists in the original place.

Wildcards Wildcards all you to match multiple instances of characters/numbers in file or directory names They can be used in combination with almost all unix commands Wildcards are essential when dealing with large amounts of geophysical data

Wildcards * : represents zero or more characters or numbers % ls 2/*.BHZ.* 2/HIA.BHZ.SAC 2/WMQ.BHZ.SAC 2/filt.HIA.BHZ.SAC 2/filt.WMQ.BHZ.SAC % ls 2/f*.BHZ.* 2/filt.HIA.BHZ.SAC 2/filt.WMQ.BHZ.SAC ? : represents a single character or number % ls 2/HIA.BH?.* 2/HIA.BHE.SAC 2/HIA.BHN.SAC 2/HIA.BHZ.SAC

Wildcards [] : single placeholder used to specify a range of characters or numbers rather than all possible characters or numbers % ls 2/HIA.BH[E,N,Z].* 2/HIA.BHE.SAC 2/HIA.BHZ.SAC 2/HIA.BHN.SAC % ls */HIA*198[0-9]* 795/HIA.BHZ.D : /HIA.BHZ.D.1988:14:35: /HIA.BHZ.D.1988:03:43: /HIA.BHZ.D : /HIA.BHZ.D :

CNTL-C Use CNTL-C to quit a job If you accidently start something that isn’t working, CNTL-C will quit and return you to a blank command line

See this link for a list and description of many Unix commands and-unix-commands/