Ch. 15 - Working with Command-Line Interface

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

CLI

(Command-Line Interface) - quick, powerful, and flexible tool - necessary knowledge for all techs

robocopy

(Robust File Copy) 1. syntax: robocopy [source] [destination] [options] 2. allows copying files/folders across network - fully replicates directory structure on destination system - deletes anything not part of copy 3. can copy from source and make destination mirror it by using /mir switch 4. can copy encrypted files 5. attain full syntax by typing robocopy /?

sfc

(System File Checker) - scans, detects, and restores important Windows system files, folders, and paths - enter *sfc /scannow* from command prompt

chkdsk (/f /r)

(aka checkdisk) 1. runs command-line version of error-checking 2. can use with switches - /f switch: attempts to fix file system errors - /r switch: attempts to locate and repair bad sectors 3. needs access to a drive to run successfully

*del* command

(or erase) used to delete files in Windows - *rm* commands used in macOS and Linux - wildcards allowed with del and rm commands to delete multiple files - remember command line has no Recycle Bin like GUI (check twice and delete once)

md command

(or mkdir) used to create directory - ex: md files make new directory named files - remember Linux is case sensitive

switch

(or option) - extra letter or number to call up modification - may follow either command or target, depends on command - modify behavior of command

rd command

(or rmdir) use for deleting empty directories and subdirectories - rmdir works in Windows, macOS, + Linux - rd only in Windows - rd command followed by /s switch will remove populated folders and contents ex: rd practice /s (directory name is practice) - be very sure before you run this since there is no Recycle Bin!

*dir /p command*

(pause in Windows) results, useful for long directory contents

*ls | more*

(pause in macOS and Linux) tellling OS to take out output of Is and "pipe" or send it through second command (more)

disallowed characters in Windows

* " / \ [ ] : ; | = ,

other Linux emulators

- Konsole Terminal - GNOME Terminal

to show contents of working directory

- Windows: *dir* command - macOS + Linux: *Is* command

macOS and Linux: Do Not use Drive Letters

- boot partition defined as root drive shown as slash (/) - all other storage partitions must go through mounting

CLI in macOS and Linux T

- both based on UNIX - terminal emulator = Terminal

moving between drives in Windows

- cd command not sure to move between drives - simply type drive letter and colon - to return to C: drive, type *C:* - use cd command to move focus to any folder on drive

passwd

- change password - change any user's password if logged in as root (super user)

to run program:

- change prompt focus to directory where program stored ex: cd C:\Windows\System 32 - type name of program with/without its extension, ENTER ex: mmc.exe

apt-get/APT

- command line tool for advanced packaging tool (APT) used on Linux Ubuntu and Mint - used for fetching and installing single applications - can also manage all software on system - need to know name of package want to install

On Windows System:

- create new directory in home directory - use dir to see directory - point prompt to new directory - make another new directory at this location - use dir to see new directory - change prompt focus to home directory - delete new directories using /s switch (repeat on macOS/Linus system using appropriate commands)

format

- enables formatting volumes from command line - can use format x: /q to wipe drive effectively

shutdown

- shutdown <options><time> - shutdown now - shutdown -r now (will reboot)

mastering fundamental commands

- type name of command and desired/allowed switches, ENTER to execute command - multiple switches may be allowable

How does command-line interface work?

- user types in command, press ENTER - command executed - new prompt displayed, ready for next command - command executed - new prompt displayed, ready for next command - command executed just as is when icon double-click in Windows GUI

Using the Command-Line Interface

- usually faster than using GUI - natural choice for jobs when not wanted or need full-blown GUI for OS

cd command

- works in every OS, differences included - change focus of command prompt to different directory

xcopy

- works like copy, has extra switches that allows work with multiple directories 1. /s switch: copies all subdirectories with files 2. /e switch: copies empty subdirectories

macOS' Ways to Open Terminal

1. Launch from Utilities Folder 2. Activate Spotlight, type *terminal*, ENTER

two types of executable files

1. built-in 2. executables

macOs & Linux Prompt

1. don't use Windows drive lettering concept, as all forms of storage mounted as folders 2. Linux prompt shows currently logged-on user, system, + current directory 3. use forward slash (/) ex: mike@server: /home$

built-in programs

1. ls 2. mkdir 3. rm

su and sudo

1. open Terminal 2. when command run as root, type *sudo* followed by desired command (system will prompt for password, then run command) 3. if system doesn't have sudo, it will have older counsin *su* 4. type *su* at prompt, ENTER (prompted for root password) 5. after password entered, prompt will change (usually change character at end from $ to a #) and every command enter from then on will execute as root 5. when finished, type *exit,* ENTER (terminal won't close, returns to normal prompt)

Mike's Five-Step copy/move Process

1. point command prompt to directory containing files to be copied or moved 2. type copy/move commands and a space 3. type name(s) of file(s) to be copied or moved (with/without wildcards) and a space 4. type path of new location for file(s) 5. ENTER

2 Alternate Methods to Manually Run Command with Elevated Privileges:

1. right-click command-prompt shortcut, select Run as administrator 2. enter credentials

Access CLI in Windows

1. start shell program cmd.exe 2a. Windows 7: use Start menu (type *cmd,* ENTER) 2b. Windows 8/8.1/10: use Start screen's search bar (type *cmd,* Search charm will appear with full command, ENTER) 3. close: click Close box or type *exit,* ENTER

to use *cd*

1. type *cd* followed by name of directory focused - ex: cd \ obiwan - to return to root direction: type cd\ and ENTER - use forward slash in macOS and Linux 2. can move one level at a time - type *cd Obiwan* 3. jump multiple directory levels in one step - type *cd Obiwan\my\hope* 4. go up single directory level: - type *cd ..*

macsOS and Linux paths

1. use forward slash, disallowed in filenames 2. Linux case sensitive (unlike Windows and macOS) 3. show folder location differently than Windows - show tilde (~): users folder - *pwd*: shows working directory

Windows Prompt

C:\> focus is on root directory of C: drive

correct syntax

[command] [target (if any)] [switches] or [command] [switches] [target (if any)]

super user or root privileges

advanced privileges in command line for both macOS and Linux - 2 Commands: su and sudo

command prompt

always focused on specific folder = *working directory* - operate on files and folders in folder on focused on command line - first focus on drive and folder where you want to work to make commands simpler

root directory

any file in folder at root of directory tree

macOS and Linux don't rely on extensions

any files can be given property of executable file

shell script

arbitrary set of commands saved in file or later use

Windows: Drive Letters

assigned to each hard drive partition - begin with "C:"

F3 function key

brings back entire command at once

F1 function key

brings back the previous command one letter at a time

cp and mv commands in Linux

can also be used to copy folders and their contents - special switch not needed to move or copy folders

two subfolders under same folder

cannot have same same - can only if in different folders

ifconfig

change network connection settings

iwconfig

change wireless network settings

Shells

command-line interpreter 1. Windows: *cmd.exe* 2. macOs & Linux: *bash* 3. alternate shells: - Windows: PowerShell - macOS + Linux: Z Shell (zsh), Korn Shell (ksh), C Shell (csh)

vi

default text editor - in either insert mode or command mode

hostname

display name of computer

executable programs

download program from somewhere, first unzip program then run

filename

early PC days: max 8 characters

mounting

enable OS to treat storage partitions as folders 1. most often mounted to single folder off root drive - Linux: /mount or /media - macOS: /Volumes

path

exact location of file

association

examples - Microsoft Word associated with any file that has the extension .docx/.doc - Powerpoint: .pptx/.ppt

batch file

ext: .bat shell scripting language for old-school command shell on Windows and DOS

JavaScript

ext: .js - browser scripting language developed back in 1990s to enhance Web pages - can now be found in command-line programs, extensions for many desktop applications, etc

Powershell

ext: .ps1 shell scripting language written from ground up for automating modern Windows systems

Python

ext: .py - flexible programming language with simple syntax, well suited for writing both simple scripts and large applications

UNIX Shell Script

ext: .sh - by convention, first line of script file specifies which shell should execute script (and this which shell scripting language it is written in). - often have .sh extension but not necessary

Visual Basic Script

ext: .vbs - legacy scripting language for Windows and other Microsoft apps - slowly being replaced by other languages like PowerShell

subfolder

folder inside another folder

C:\Test represents:

folder named Test on hard drive

gpupdate

force workstation to update to new group policies

folders

groups of files (aka directory)

color coding

indicates which files are executable files

pruning and grafting

involve moving entire folders including files and subfolders within folder - faster with command line than GUI - also gives finer control

dir command

list creation date, creation time, file size in bytes, filename and extension 12/12/2021 10:18 AM <DIR> Windows now type *dir /w* command: only shows filenames, arranged in 4/5 columns across screen finally type *dir/?*: lists all possible switches for command

ps

lists process running on system

PowerShell

more powerful replacement for traditional Windows command-line interface 1. uses powerful tools called *cmdlets* 2. syntax more complex that regular command-line use 3. type *powershell* in search bar, ENTER

in order to make Linux run a newly downloaded executable file

need to add period and slash in front of executable ex: ./runme

vertical line (|)

pipe command - used in all 3 OS, incredibly powerful

ls command

powerful, contains over 50 different switches use *ls* with *-l* = ls -l

dd

primarily used to create exact, bit-by-bit image of any form of block storage ex: - copy hard drive - backup removable flash drive - wipe a disk

syntax

proper way to write command - can't spell anything incorrectly or use \ when syntax calls for /

gpresult

quick overview of all security policies applied to singer user or computer

Closing Terminal

same for Windows, macOS, and Linux - at prompt type *exit* - terminal window will disappear

Arrow Keys

scrolling and editing - up and down: scroll through commands - left to right: edit commands

grep

search through text file or command output to find specific info or filter out unneeded info

path

series of folders that Linux looks at when running a program - command *echo $PATH*

shutdown

shut down or reboot local or remote machine - /r switch tells it to reboot

scripting

small program to help automate computing tasks - shell scripting language - run scripts from prompt but create scripts in text editor

wildcard

special characters that enable commands to act on more than one file at a time * : represents any number of characters ? : represents single character ex: find all files that end in .txt, type dir *.txt

prompt

special set of characters indicating computer ready to perform ex: >: want to play a game? >:__

-l

stands for long listing - gives detailed information about files

C:\Test\System Represents:

subfolder named System in Test directory

extension

tells OS which program uses data - changing extension doesn't affect file contents

each file has a name

two parts: filename and extension - separated by a dot (ex: thisfile.txt, fred.exe, Noextension) - matters when working in CLI, need to know type of file accessing when typing command

to find correct syntax and switches in Windows:

type *[command name] /?*

to find correct syntax and switches in macOS or Linux

type *man [command name]*

file format

unique method of binary organization for every program (one program can't read another program's file unless converts other program's file format into its file format)

Linus Ways to Open Terminal Emulator (vary with Linux distro)

use Finder or Search function on desktop, type *terminal* to start program

text commands

very little bandwidth needed when sent across network to another system

*help* command

when you're really lost, type this at command prompt for lists of commands you may type

difference between copy and move

whether or not original is left behind 1. Windows Commands: - copy - move 2. macOs + Linux commands: - cp - mv

if you attempt to enter command at command prompt that requires administrative priveleges:

will receive UAC dialog box


Set pelajaran terkait

Principles of Marketing - Chapter 8

View Set

Network+ Chapter 10 Command-Line Tools

View Set

Chapter 3: Collecting Objective Data: The Physical Examination

View Set

Chapter 37: Nursing Care of the Child With an Infectious or Communicable Disorder

View Set

APR Exam Practice Questions Set 01

View Set

10- PROJECT COMMUNICATIONS MANAGEMENT

View Set

Parallel and Perpendicular Slopes and Equations

View Set

PSYCH 11: Week 3 Infancy and Toddlerhood

View Set

AP Human Geography Chapter 10/11

View Set

EXAM III: Chapter 12 - Adaptive Immunity

View Set

10.5 - Functional Groups - Part 2

View Set

Chapter 1 - Elements of the Immune System and Their Roles

View Set