9-2 How do you copy/move/rename/remove files? How do you create a directory ? What is redirection and piping? Readings: See CCSO’s Unix pages andCCSO’s.

Slides:



Advertisements
Similar presentations
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.
Advertisements

NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Working with Files How to create, view, copy, rename and print files.
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.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Preparation for working in the CSIL Basic LINUX operations.
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.
Chapter 7 Advanced Directory and File Management.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  Currently there.
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.
Linux Installation and Administration Lesson 2 Tutor: George Papamarkos.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
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 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 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
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.
Unix Basics Chapter 4.
CS240 Computer Science II Introduction the Unix File System and File Related Utilities Based on “UNIX for Programmers and Users” by G.Class and K. Ables.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
COP3502: Introduction to Computer Science Yashas Shankar.
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.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
Tera Term Brian Smith Chris Vasse Zaheemat Adetoro William Newton Tom Presgraves.
8-2 What is a program? What is a “Window Manager” ? What is a “GUI” ? How do you navigate the Unix directory tree? What is a wildcard? Readings: See CCSO’s.
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.
Linux+ Guide to Linux Certification, Third Edition
Introduction to Programming Using C An Introduction to Operating Systems.
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.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
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.
Files and Directories in UNIX The first file in UNIX file system is “root” or “/”
Basic Unix Commands & GCC Saurav Karmakar Spring 2007.
Linux Stuff Last Update Copyright 2014 Kenneth M. Chipps Ph.D. 1.
The Kernel At a high level, the kernel in an operating system serves as the bridge between applications and the actual data processing of the hardware.
The Unix File sytem. Introduction Tree structure …
Unix Fundamentals CS 127. File navigation cd - change directory cd /var/log cd /etc/apache2 cd ~/Desktop ~ is a shortcut for the home directory.
EMT 2390L Lecture 3 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Learning basic Unix command It 325 operating system.
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.
CMSC 104, Version 8/061L03OperatingSystems.ppt Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux.
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
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.
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Software Tools Recitation 1
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Operating Systems and Using Linux
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
Andy Wang Object Oriented Programming in C++ COP 3330
Tutorial Unix Command & Makefile CIS 5027
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Presentation transcript:

9-2 How do you copy/move/rename/remove files? How do you create a directory ? What is redirection and piping? Readings: See CCSO’s Unix pages andCCSO’s Unix pages

9-3 cp option file1 file2 First Version This is one version of the cp command. file2 is created and the contents of file1 are copied into file2. If file2 already exits, it will be replaced with a new one. where option is -i Protects you from overwriting an existing file by asking you for a yes or no before it copies a file with an existing name. -r Can be used to copy directories and all their contents into a new directory

9-4 cp file1 file2 file3 … dirname Second Version This version copies the files file1, file2, file3,… into the directory dirname.

9-5 Copy the file named mp1_data.m from the cs101/data directory into the pwd. cs101 data > cp ~cs101/data/mp1_data.m. {FILES: mp1_data.m, mp1.m } jsmith mp1 pwd The (.) dot means “here”, that is, your pwd.

9-6 Copy the file named mp1_data.m from the cs101/data directory into the mp1 directory. cs101 data > cp ~cs101/data/mp1_data.m mp1 {FILES: mp1_data.m, mp1.m } jsmith mp1 pwd The (.) dot means “here”, that is, your pwd.

9-7 Example: To create a new directory named “ temp ” and to copy the contents of an existing directory named mp1 into temp, > cp -r mp1 temp This is useful to make a backup copy of your mp1 files.

9-8 mv option file1 file2 First Version This is one version of the mv command. file1 is renamed file2. where option is -i Protects you from overwriting an existing file by asking you for a yes or no before it copies a file with an existing name.

9-9 mv dirname1 dirname2 Second Version In this version dirname1 is renamed dirname2

9-10 mv file1 file2 file3 … dirname Third Version The files file1, file2, file3,… are moved into the directory dirname.

9-11 Move all the files with.c suffix from the temp directory to the mp2 directory. jsmith temp > mv temp/*.c mp2 {FILES: mp2.c, mp2.h } source mp2 pwd Move the input.dat file into the home directory. > mv source/input.dat. {FILES: stat.c, input.dat }{FILES: edit.c }

9-12 rm option file1 file2 file3 … The rm command removes (deletes) each file in the list. where option is -i For each file in the list, the user is asked whether or not to delete. -r Deletes a directory and every file or directory in it. Example: To delete a directory named temp and all its contents, > rm -r temp Where temp is a subdirectory of the present working directory. Be very careful in using this command!!!

9-13 mkdir dirname The mkdir command makes a subdirectory named dirname in the present working directory. Lab assignment: Create a directory named lab2 as a subdirectory of your home directory. Assuming that you are in your home directory, type > mkdir lab2 The mkdir creates a new directory but it does not cd for you.

9-14 Find all files named mp2.c. jsmith mp2 > find -name “mp2.c” -type f {FILES: mp2.c, main.c } workspace mp2 pwd {FILES: mp2.c, main.c } Find all directories named mp2. > find -name “mp2” -type d

9-15 You want to your lab TA and send him/her all your files in the mp2 directory. > tar -czvf blah.tar.gz * creates a file named blah.tar.gz mp2 pwd {FILES: mp2.c, input.c, stat.c, mp2.h, … } When your TA receives this file he/she can extract its contents by typing: > tar -xzvf blah.tar.gz

9-16 Links commands to commands. Pipes are used to direct the output of one command to the input of the second. Unix uses the vertical bar “ | ” symbol to perform piping. General form > command1 | command2

Example: when you use the ls command to list the contents of a directory the output may not fit on one full terminal screen. Since the screen scrolls you may not see the first part of the output. Use a pipe to solve this problem > ls -la | more

9-18 Links commands to a file. Redirection is used to take information that would normally be seen on the screen and funnels it to a file or vice versa. Unix uses the “ > ” or “ < “ symbols to perform redirection. General form > command > filename output redirected to file filename > command < filename input from file filename not keyboard

9-19 Example: you can send the output from the ls command to a file” screen.txt ”. You can then use gedit to edit the file. > ls -la > screen.txt

9-20 passwd - change your password clear - clears the terminal screen leaving the prompt > whoami - identity of the user man command - manual of information concerning command for example, type in “ man finger” to find all the options available for this command.

9-21 alias abbreviation command provides an alias for a command. For example, if you type, > alias dir ls -la then dir is an alias for ls -la so if you type, > dir this is the same as typing in > ls -la To make this change effective each time you login, gedit the.cshrc file and type in the alias command. When you add a line at the end of the.cshrc file terminate the line by typing.

9-22 alias abbreviation ‘ command1 command2 ’ provides an alias for compound commands For example, if you type, > alias dir ‘ls -la | more’ then dir is an alias for ls -la | more so if you type, > dir this is the same as typing > ls -la | more and this command displays the contents of the pwd one screen at a time.

9-23 alias abbreviation ‘ command1 \!* command2 ’ provides an alias for compound commands and passes an argument. For example, if you type, > alias dir ‘ls -la \!* | more’ then > dir lab1 is the same as typing in > ls -la lab1 | more and this command displays the contents of the subdirectory of the pwd named lab1, one screen at a time.

9-24 How to: copy- cp/move - mv/rename - mv/remove-rm files. Use the mkdir command to create a directory. Redirection - uses the “ ” symbol. By default, most commands expect input data from the keyboard and output data goes to the monitor. Using redirection symbols, you can specify that the input comes from a file and output goes to a file. Piping - uses the “ | ” symbol. Output data from one command can be piped as into to another command.