Mostly MS Dos with some UNIX/LINUX

Slides:



Advertisements
Similar presentations
DOS commands.
Advertisements

Guide To UNIX Using Linux Third Edition
Command Console Tutorial BCIS 3680 Enterprise Programming.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Ch 71 Using ATTRIB, SUBST, XCOPY, DOSKEY, and the Text Editor.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Ch 51 Internal Commands COPY and TYPE. Ch 52 Overview Will review file-naming rules.
Ch 61 Using DEL, REN, MOVE, and RD /S. Ch 62 Overview Will continue to work with internal commands that help manage and manipulate files.
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 environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Introduction to Shell Script Programming
Ch 21 Command Syntax Using the DIR Command with Parameters and Wildcards.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
Ch 41 Program Files, Data Files, and Subdirectories.
The Command Line Mostly MS Dos with some UNIX/LINUX Copyright © Curt Hill.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Chapter 1 : The Linux System Part 2 Lecture 2 11/14/
1.  Microsoft DOS (Disk Operating System) use a command line user interface.command line  A command line user interface means that the user is required.
Introduction to Programming Using C An Introduction to Operating Systems.
File and Folder CLI Commands 12/24/ Agenda Overview of OS functions and the SHELL Internal v External Commands Command History Making & Modifying.
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner.
Batch Files Weaker form of UNIX shell scripts. Introduction UNIX may use one of several shells The shell is the command interpreter It interacts with.
Batch Files Weaker form of UNIX shell scripts Copyright © by Curt Hill.
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
Batch Files More flow of control Copyright © by Curt Hill.
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.
MS-DOS is an acronym for MicroSoft Disk Operating System It is a CUI based operating system. It provides user with a command prompt (generally called.
Systems Administration (Windows) BIT3111 – Lecture 5 (Introduction to Windows OS)
HTML Simple Introduction
The Second C++ Program Variables, Types, I/O Animation!
Lesson 4 0x Operating Systems.
Release Numbers MATLAB is updated regularly
PowerShell Introduction Copyright © 2016 – Curt Hill.
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.
SQL and SQL*Plus Interaction
Introduction to Unix May 24, 2008 Rabat, Morocco Hervey Allen
Unix Shells.
Some Linux Commands.
Console and GUI Programs
The Command Prompt Commands are the way to “do things” in Unix
Guide To UNIX Using Linux Third Edition
PROGRAMMING THE BASH SHELL PART IV by İlker Korkmaz and Kaya Oğuz
Introduction to C Topics Compilation Using the gcc Compiler
INTRODUCTION TO UNIX: The Shell Command Interface
Command Syntax Chapter 2 Using the DIR Command with
Copyright © – Curt Hill Bash Scripting Fundamentals Copyright © – Curt Hill.
Topics Introduction to File Input and Output
Concepts From Alice Switching to Java Copyright © Curt Hill.
You do want to create and edit programs?
Guide To UNIX Using Linux Third Edition
Operating Systems and Using Linux
Chapter Four UNIX File Processing.
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Cmdlets “Command-lets”
Operating System Fundamentals
Copyright © – Curt Hill Bash Flow of Control Copyright © – Curt Hill.
Linux Shell Script Programming
PowerShell Flow of Control Copyright © 2016 – Curt Hill.
CSE 303 Concepts and Tools for Software Development
Functions, Parameters and Scope
Chapter 6 Using DEL, REN, MOVE, and RD /S Ch 6.
OPERATING SYSTEM B-TECH III YEAR I SEM BRANCH :ECE
Topics Introduction to File Input and Output
Review.
LPI Linux Certification
Presentation transcript:

Mostly MS Dos with some UNIX/LINUX The Command Line Mostly MS Dos with some UNIX/LINUX Copyright © 2003-2017 Curt Hill

Introduction The command line interface is a modified time-sharing command interface Predates GUIs Still important for sophisticated professionals such as Software Engineers Microsoft has been trying to remove it from Windows since before XP Much of what you have seen hides the command line stuff Copyright © 2003-2017 Curt Hill

Brief History First time sharing systems are in 1960s Enter a command from a printing terminal Central CPU executes UNIX developed in early 1970s Command format is the name of any program followed by parameters DOS 1 adopts this approach Single user Syntax modifications Copyright © 2003-2017 Curt Hill

Contrast Current Windows believes in two different styles of executables A GUI oriented one and a console oriented one The GUI executable registers its controls and event handlers as its first order of business By default it does not have a console A console executable does have a console It immediately starts to do the work involved Copyright © 2003-2017 Curt Hill

Shells The notion of a shell dates back to early versions of UNIX or before A shell is a command interpreter It gave an interactive means for a user to use the system UNIX allowed anyone to create their own shell, while Windows was less forthcoming in this respect On most previous versions of Windows this is the DOS command prompt – now it is PowerShell Copyright © 2003-2017 Curt Hill

Shell Scripts If the shell can accept commands from a file instead of the console this is called a shell script UNIX has a command redirection feature that enabled this The > and < on the prompt A shell script is a full but simple programming language with variables, flow of control and other features we expect in programming languages Copyright © 2003-2017 Curt Hill

The Console Often called the DOS box Only interface DOS had Recently PowerShell became the default console Paradigm is that of a printing terminal or glass teletype Sequence of lines produced by program and user Minimal editing of the line Recall previous typed line and backspace Copyright © 2003-2017 Curt Hill

Command sequence Machine gives a prompt Usually a C:...> with blinking cursor You answer with Command and <CR> If the command is valid it is executed When command is done go back to prompt Copyright © 2003-2017 Curt Hill

Command format A command has this format CMD parameters and files A command must be properly spelled A parameter is some extra info to the command DOS standard starts with a slash (/) UNIX standard starts with a dash (-) Most are optional In Windows it is the program itself that determines the format of the parameter Copyright © 2003-2017 Curt Hill

Programs The DOS box is actually cmd.exe in the Windows directory PowerShell is powershell.exe UNIX/LINUX calls this thing a shell It has a variety of shells Consistent with the UNIX philosophy Whether a DOS box or UNIX shell they are all command interpreters In early versions they were only command interpreter Now the GUI part interprets some commands Copyright © 2003-2017 Curt Hill

File specification How do we specify a file? In DOS In UNIX Files have several pieces for their name In DOS File name File extension File directory In UNIX The extension is just part of the name A dot is an ordinary character Copyright © 2003-2017 Curt Hill

File name Originally 1-8 characters Name is composed of Now they may be much larger Name is composed of Letters Digits Specials Only characters that have special meaning in DOS may not be used Name should identify the particular project UNIX is a little more restrictive Copyright © 2003-2017 Curt Hill

File type or extension Originally 0-3 characters Now may be more Separated by a dot from name Used to describe the kind of stuff in the file Predefined extensions .exe - program .bmp – bitmap picture .bat - DOS batch file A batch file will be discussed later .ps1 – PowerShell script Copyright © 2003-2017 Curt Hill

File Directory Combination of the disk letter and subdirectory In Windows/DOS disk is a letter followed by a colon In UNIX disk are represented by load points that are named not lettered Directories and subdirectories are delimited by \ in DOS and / in UNIX These may be discussed in a subsequent presentation Copyright © 2003-2017 Curt Hill

Defaults By default if subdirectory is not specified the current disk and directory are used These may be shown in the prompt The form of the prompt may be set by the user Extension Certain programs require certain extensions Each program may assume an extension or not Copyright © 2003-2017 Curt Hill

Wildcards Wildcards are ways to specify a whole group of files at once because of similarity of name * - matches as many characters as possible No characters need follow it until a . ? - matches one and only one character Wildcards are often interpreted by the program so usage varies Copyright © 2003-2017 Curt Hill

The C/C++ main function The standard main function looks like this: int main(int argc, char *argv[]) The initial int is the return value Argc is a count of command line parameters Argv is an array of character strings The actual command line parameters The program needs to interpret these as it sees fit Copyright © 2003-2017 Curt Hill

Parsing the command Def: to parse is to understand the form and meaning of communication or describe the form, function and relationships of a sentence How does DOS determine what to do with the command? Lets look Copyright © 2003-2017 Curt Hill

Executable Location Where can an executable be and be found in the command prompt? You would think that executables must be the Windows directory or one of the Program Files directories This is partially, but not fully true Executables must be on the Path The Path is an environment variable Copyright © 2003-2017 Curt Hill

Environment Variables A set of name value pairs that affect how things operate Both Windows and UNIX have the concept Both systems have a TEMP variable which identifies a directory where a program may create temporary files Both also have the PATH variable Copyright © 2003-2017 Curt Hill

The Path The Path environment variable is a string of directory names When a command needs an executable the Path directories are searched If there are multiple files of the same name, the first one found is used Windows has two paths A global one for all users A local one for each user The two are merged Copyright © 2003-2017 Curt Hill

Finding the Path Like all good Windows options there are multiple ways to examine or set Control Panel / System Advanced System Settings Copyright © 2003-2017 Curt Hill

Advanced Copyright © 2003-2017 Curt Hill

Environment Variables Copyright © 2003-2017 Curt Hill

Command Interpretation Suppose that at the prompt the command: XYZ /z abc.def is entered – what happens? The first word is the command name This may be prefixed by the disk, subdirectory etc. xyz is assumed to be name of command and /z and abc.def is passed to the command for inspection Copyright © 2003-2017 Curt Hill

Search for command 1 First the internal commands are searched for this command The internal commands are in the command processor They do not have file representations They include dir, type, ren, del, copy, etc If it is found then it is executed, otherwise the search continues Copyright © 2003-2017 Curt Hill

Search 2 Next we look in the current directory There are two extensions that can be executed: .EXE .BAT They will be searched in that order: first xyz.exe and finally xyz.bat There used to be a .com format as well If they are not found there, then the path is checked The order of the directories in the path command is then the order they will be searched Copyright © 2003-2017 Curt Hill

Path searches Like in the current directory, the first directory on the path is searched for xyz.exe and then xyz.bat Only if it is not found do we go to the second and subsequent directories If all the directories are searched and the command is not found, then we declare that this is an unknown file or command Copyright © 2003-2017 Curt Hill

Advantages The OS does not distinguish between its own external commands and foreign commands Internal commands have an advantage over other commands However external commands are just files like any other If we want to redefine we can If we want to write a new kind of command that makes life easier all we have to do is put it on the path Copyright © 2003-2017 Curt Hill

Commands We next want to consider various commands that may be useful These are typically file manipulation command Any executable can be used If it generates a window it may still be started from the command line Windows distinguishes between GUI and non-GUI executables Copyright © 2003-2017 Curt Hill

DIR Short for directory Displays the files present in the local Command alone shows all files in current directory You may also use file names and wild cards DIR is an internal command UNIX used ls with different options Copyright © 2003-2017 Curt Hill

Parameters The typical parameter of a command is a file Certain commands may take wildcards The internal commands usually have options started with / The option /? will give a page showing the format and options Non MS programs may have /h or /help instead Next screen shows this for dir Copyright © 2003-2017 Curt Hill

Dir options Copyright © 2003-2017 Curt Hill

COPY Make an identical copy of a file COPY source destination COPY a.dat b.dat Make a copy of a.dat Same disk, directory, etc Retains same date as the a.dat UNIX uses cp with different options Copyright © 2003-2017 Curt Hill

Copy Again Accepts wildcards in source file and matching in destination COPY must give it a new name or copy it elsewhere, since a directory can only have 1 identically named item Concatenation of files is allowed using + between file specs for source COPY b.dat+c.dat all.dat Copyright © 2003-2017 Curt Hill

DEL (ERASE) Removes the file from the disk Accepts wildcards DEL *.bak UNIX uses rm with different options Copyright © 2003-2017 Curt Hill

RENAME Gives a new name May abbreviate to REN May use wildcards UNIX uses mv which moves rather than renames A rename is move to same location with different name Copyright © 2003-2017 Curt Hill

The Screen The DOS screen emulates the printing terminal or glass teletype It displays the lines you typed in as well as the responses that the commands provided Since it is in its own window we can use the scrollbar and see that which happened before The CLS command will clear it Copyright © 2003-2017 Curt Hill

Cursor Keys We may use the cursor keys to modify the current command The left and right keys allows moving in the current command The delete and backspace change Insert toggles whether characters are inserted or overwritten Using the up and down key moves us through the list of commands we have used Makes it easier to reuse the typing of a previous command Copyright © 2003-2017 Curt Hill

Help command DOS still retains the HELP command which will show the commands that exist Following the HELP you may also specify the command that you wish to know more about, such as: HELP COPY Copyright © 2003-2017 Curt Hill

Directory Commands Cd or chdir changes the current directory Md or mkdir creates a new directory Rd or rmdir destroys The directory name follows the command Two specials Single dot refers to the current directory Two dots refers the ancestral Copyright © 2003-2017 Curt Hill

Addendum: Long file names The original FAT file system believed only in the 8.3 name Later, long file names were allowed These also allowed blanks as a valid character There was an algorithm that would convert that long name into an 8.3 name This produced two versions of the name that co-existed The 8.3 name always had a tilde ~ in it Copyright © 2003-2017 Curt Hill

Blanks The command processor has been modified to handle the blanks in a name A long file name may be enclosed in double quotes Then even if it has blanks it can be processed Another trick that helped is for the CD command A tab will fill in one of the available directories Copyright © 2003-2017 Curt Hill

Conclusion We now have the basics Next we learn about redirection, pipes and standard files Then batch files briefly We restart with PowerShell Copyright © 2003-2017 Curt Hill