Chapter 16: Working with the Command-Line Interface
What are the two wildcards that are used in the command prompt?
* and ?
What is an illegal character in a Linux filename?
/
What is an illegal character in a Linux filename?
/ (forward slash)
CMD What are common switches with the format command?
/FS:filesystem - format with a specific file system /Q - Quickformat /V: Label -specify a Volume Label /C: NTFS only, files on drive will be compressed by default
What are three ways a command line is better than a GUI?
1. Can be quicker to type a command then click through a GUI. 2. Lightweight, and GUI may not be available on other OS's for a particular job 3. Low bandwith if working over a network
The command prompt is popular for three reasons:
1. Does jobs more quickly rather than clicking through graphical interfaces 2. A command line interface (CLI) doesn;t take much OS firepower 3. Text commands take very little bandwith when sent across the network to another system
What are some rules about file and folder names?
1. Folders and files can have spaces in their name 2. The following 11 characters are not allowed: ** /\ [ ] : ; = 3. Files arent required to have extensions, but this is not command
How the command prompt be launched?
1. Type cmd or command in the box (XP) 2. All Programs \ Accessories \ Command Prompt 3. Hold Shift and right click on a folder
What are the limits on duplicate names in files and folders?
2 files in the same folder cannot have the same name 2 subfolders in the same folder cannot have the same name 2 files or folder in different folders can have the same name this also applies to the root directory
what is the max number of characters in a WIndows 2000/XP/Vista filename?
255
Whatever the names of the drives, all OS use a hierarchical directory tree to organize the contents of these drives. All files are put into groups called FOLDERS, although you'll often hear techs use the term DIRECTORY rather than FOLDER. Any file not in a folder within the tree, that is, any file in the folder at the root of the directory tree is said to be the ROOT DIRECTORY.
A folder inside another folder is called a SUBFOLDER. Any folder can have multiple subfolders. Any folder can have multiple folders. Two or more files with the same name can exist in different folders on a PC but two files in the same folder cannot have the same name. In the same way, no two subfolders under the same folder can have the same name, but two subfolders under the different folders can have the same name.
The ls command. The ls command is used to list files. ... ls -a will list all files including hidden files (files with names beginning with a dot). ls -F gives a full listing, indicating what type files are by putting a slash after directories and a star after executable files (programs you can run)
A shell is a program that reads commands that are typed on a keyboard and then executes (i.e., runs) them. ... Every Unix-like operating system has at least one shell, and most have several. The default shell on most Linux systems is bash.
What is a command prompt windows is always focused on?
A specific folder or at the root of a drive like C:\
What was the first universal file format called?
ASCII
What is the command to my MYFILE.TXT read-only?
ATTRIB MYFILE.TXT + R
CMD - How can you find more info on a command?
Add /? after the command Ping /?
What is ASCII and what is it for?
American Standard Code for Information Interchange. It is used as a standard file format readable between multiple programs and has 256 eight bit characters. ASCII files are more commonly known as text files.
What is the external program that enables you to inspect and change file attributes?
Attrib
What tool would you use at a Windows Vista command prompt to edit OS start up parameters located in the data store?
Bcdedit.exe
What user profile directory is displayed at a Windows Vista command prompt by default?
C:\Users\User name
What command do you use to change the focus of the command prompt to a different directory?
CD
What commands can you type at the Run dialog box to access the command-line interface XP?
CMD or COMMAND
Every OS has some method to change file associations. If you want to open MIS office .docx files in LibreOffice instead of Word, there is always a way to do this.
Changing the extension of a data file does not affect its contents but without the proper extension, your OS won't know which program uses it.
What command is used to change file permissions in Linux
Chmod Q
What are parts of a command and order?
Command - Actual command like pint Target - file and folder being targeted like google.com Switches - options in the command like -a The order can be either: command target (if any) switches command switches targeted (if any)
The _______ tells you its ready to receive commands by displaying a specific set of characters called a(n)
Command Line Interface ; Prompt
Mastering Fundamental Commands
Command line is picky and unforgiving. One careless stroke can result in the loss of crucial data with no warning. In this section, you will explore the structure of commands and then play with basic commands to navigate and manipulate your OS's folder structure
Which command would delete every file in a directory?
Delete / all
Extra text typed after a command to modify its operations, such as /w or /p after DIR is called a SWITCH. Almost all switches can be used simultaneously to modify a command.
Dir Command lists the creation date, creation time, <DIR> to tell you it is a folder, and the folder name. now type dir /w command.
Drives and Folders
Drives and Folders
What file system enables you to encrypt files thus making them unviewable by any account but your own?
EFS
For techs who master the interface, the command line provides a powerful, quick and flexible tool
EXAM TIP. You will be asked about command line commands both in Windows and Linux
Which key is used to bring back the previous command one letter at a time?
F1
Which key is used to bring back the entire command?
F3
Command line interface works like a messenger conversation with your computer. The computer tells you it's ready to receive commands by displaying a specific set of characters called a PROMPT. Here's an example of a generic prompt:
Generic prompt: >: want to play a game? >: what kind of game? >: _ The PC goes off an executes the command and when it's finished, it displays a new prompt, often along with some information about what it did: >: want to play a game? >: what kind of game? >: a very fun game >: __
How do you move files in the command prompt?
Have to command prompt in the directory where the file you want to move is. Type and move a space Type the name of the file (or use wildcards) and a space Type the path of the new location for the file(s) Hit enter
What is Unicode?
It replaced ASCII in 1991 and used 16 bit to cover many more international characters. the first 255 characters are the same as ASCII.
CMD What does hostname do?
It will display the hostname of your PC?
In MAC OS and Linux, the promptly is subtly different but functions the same way. MAC and Linux don't use the Windows drive lettering concept. All forms of storage are mounted as folders.
Linux prompts show the currently logged-on user and system as well the current directory.
what best describes the function of the Windows gpresult?
Lists the group policies applied to a user
What command enables you to make a new directory in a Windows XP Professional system?
MKDIR or MD
The exact location of a file is called ________?
Path
What option enables you to share files easily among multiple users on a single Windows system?
Place the files in the public libraries
Extensions are very important in every OS. The file name extension tells the OS what type of program uses the data. this is called the file's ASSOCIATION. For example, MS is associated with any file that has the extension .docx or .doc.
PowerPoint uses .pptx or .ppt graphics file extensions, in contrast, often reflect the graphics standard used to render the image.
What does each letter in Attrib mean?
R = Read Only H = Hidden S = System A = archive
What do you use to rename a file?
REN Command
The Command Prompt
Regardless of the shell you use, the command prompt always focuses on a specific folder, the WORKING DIRECTORY, usually indicated by the prompt. The OS executes commands in the specified folder unless otherwise directed. Here's an example of focus. In Win, if you see a prompt that looks like the following line, you know that the focus is on the root directory of the C: drive C:\>
How do you run a command prompt with elevated or admin privileges?
Right click a command prompt shortcut and then select Run as Admin
How do you run a command at the Windows command prompt with administrative privileges?
Right-click a command-prompt shortcut and then Run as administrator
Why do files have extensions?
So windows knows how to handle/open them
What is the term, when talking about Mac OS X and Linux, that means to run the command line with advanced privileges?
Super User and Root privileges
What is the name for the rules for typing a command correctly?
Syntax
Accessing the Command-Line Interface in MAc and Linux
The command line in MAC and Linux functions identical. Both based on UNIT. The terminal emulator in OS X has a specific name TERMINAL. The many distros of Linux use different emulators such as konsole and gnome-terminal. To make things easy, we will use the command-line interface in Ubuntu Linux, called TERMINAL.
When you open a command-line windows in Windows, it opens focused on your user folder. You will know this because the prompt looks like C:\Users\User name> By typing DIR and then pressing the ENTER key, you will see directory contents
The default prompts in Linux don't show the full path but on my Ubuntu Linux system.
CMD - How can you view a directory's contents?
The dir command
What are the two filename conventions and how are they compatible?
The old system 8.3 had limits of 8 chars and 3 letter extensions Starting with Windows 9x files could be up to 255 chars with long filenames, to stay backwards comp. by stories a long and 8.3 filename for each file
SHELLS
The tool that interprets input is called the COMMAND LINE INTERPRETER known as the SHELL. The default Windows shell is cmd.exe On MAC and Linux, the default shell is BASH . It is easy to replace bash with popular shell names with names like Z Shell (zsh), Korn shell (ksh) and C Shell (csh). in Windows you can replace cmd.exe with PowerShell. It's a standard right of nerd passage to experiment with these alternative shells.
What are wildcards and how are they used?
The two wildcards are ? and * They are used in commands with filenames to substitute without knowing the exact file name
DIR/p = pause ENTER to search for something in a large directory
The | symbol is called a PIPE.
ls Command, like most UNIX commands, is powerful and contains over 50 different switches.
To access another drive, type that drive's letter, followed by ":". For instance, if you wanted to change the drive from "C:" to "D:", you should type "d:" and then press Enter on your keyboard. To change the drive and the directory at the same time, use the cd command, followed by the "/d" switch
CMD - how to you change attributes to all files of a certain type in a directory?
To add hidden to all .mp3 files you would use: attrib + h *.mp3/s
Accessing the Command-Line interface in Mac OS X and Linux
To open Terminal in MAC, either launch the Terminal App from Utilities folder (located in the Applications folder) or activate SPOTLIGHT (Command-Spacebar) type TERMINAL and press ENTER and bring up the Mac Terminal. The way to open up Terminal emulator in Linux various on the distro you use. Search for the search tool and type in TERMINAL and start the program. This brings up the terminal window.
When you are done reading the manual, press the Q key to quit back to the prompt.
Viewing Directory Contents: Dir and Ls The Win DIR COMMAND and the MAC OS and Linux ls command show you the contents of the directory where the prompt is focused. You will use dir or ls more often than any other command at the command prompt.
CMD What is the sfc command?
Windows System File Checker will scan, detect and restore important Windows system files, folders and paths. It can be used from a working Windows install or from an installation dis. You can run it with sfc/scannow
o change directories while in a *nix environment, use the cd command. Below are some basic examples of how this command can be used to change directories. Before changing directories, you need to know what directories are available in the current directory. To do this, use the ls command.
Windows shell. ... The Windows shell provides users with access to a wide variety of objects necessary for running applications and managing the operating system. The most numerous and familiar of these objects are the folders and files that reside on computer disk drives.
The command Prompt windows pops up on your screen with a black background and white text.
You can create an Admin shortcut t the Windows Command prompt by right clicking on the desktop and selecting New-Shortcut. For the location of the item, type CMD and click NEXT. Type CMD to name the shortcut and click Finish. In Advanced Properties dialog box, check the Run as Admin box and click OK. You will now have created a Windows command-prompt shortcut that will always run with admin privileges
CMD What is the shut down command?
You can use it to shutdown a remote PC or yours: shutdown /r\\testserver will shutdown the PC with the hostname testserver and the /r means it will reboot after. You can also use /t 60 to shut it down in 60 seconds
CMD: How do you run a program from the command prompt?
You may need to be in the directory where the program is located and then type the name C:\windows\system32\notepad
How do you know what switches are allowed? How do you know whether the switches come before or after the target? If you want to find out the syntax and switches used by a particular command, in Windows type the command followed by /? to get help.
[command name] /?
The proper way to write a command is called its SYNTAX. The key with commands is that you can't spell anything incorrectly or use a \ when the syntax calls for a /. The command line is almost completely inflexible so you have to learn the correct syntax for each command.
[command] [switches] [target] or [command] [switches] [target]
What is an illegal character in a Windows filename?
\
what is the default shell for Mac OS X and Linux?
bash
Which command in windows can be used to change the focus of the command prompt to a different directory?
cd
Which command will attempt to fix file system-related issues and errors?
chkdsk / f
Which command attempts to locate and repair bad sectors?
chkdsk /r
What is the default shell for Windows?
cmd.exe
CMD How do you delete files>
del or erase
What command is the functional equivalent to the Linux ls command?
dir
Which command shows a quick overview of all security policies applied to a single user or computer?
gpresult
Which command is used if you want newly set policies to work immediately?
gpupdate
What do you type before a Linux command to access help for that command?
help man
What command, identical in both Windows and Linux, will tell you the name of the computer?
hostname
Which command in a Mac OS X or Linux PC can be used to view and change the settings for our network connection?
ifconfig
What Linux command will show detailed information about the contents of a folder?
ls - 1
What command pauses after displaying a screen's worth of directory content?
ls\more and dir / p
What command would be used to find the syntax or switch used in a command?
man [command name]
Which command can be used to make a directory?
mkdir
What command do you use to determine your exact folder location (path) in Linux?
pwd
CMD How can you delete a directory (named chips) with subdirectories?
rd chips /s It will ask if you are sure you want to delete it
Which command can be used to remove a directory?
remdir
What command will delete all of the files in a directory in Linux?
rm *
CMD What is the Robocopy syntax?
robocopy source destination [file [file] . . .] [options\ Example: robocopy D:]testserver\newwebsite \\webhost\companywebsite/mir /mir mirrors a directory meaning it will delete files not in the source directory
Which command scans, detects, and restores important Windows system files, folders and paths?
sfc
What do Mac OS X and Linux call the command-line?
terminal
What is an illegal character in a Windows filename>
the asterisk (*)
What are the two parts of a file's name?
the filename and the extension
What do you use to move a file from the root directory into a subfolder?
the move command
Which command can be used to copy files but can work with multiple directories?
xcopy
CMD How do you copy mulitple folders at once?
xcopy [oldfolder] [newfolder] adding /s will also copy non-empty subfolders adding /e will copy empty subfolders
Filenames and File Formats
All OS manifest each program and piece of data as an individual file. Each file has a name which is stored with the file on the drive. Names of files are broken down into two parts: the file name and the EXTENSION.
If you wanted to delete all of the files in a directory, what command would you type?
DEL
What shows you the contents of the directory that currently has focus?
DIR command
What command pauses after displaying a screen's worth of directory's contents?
DIR/P
When working from the command line, you need to be able to focus the prompt at the specific drive and folder that contains the files or programs with which you want to work.
MAC and Linux OS don't use the idea of drive letters. Instead, the boot partition is defined as the root drive, shown as just as slash: /. All other storage -partitions, optical discs, thumb drives and so on must go through a process called MOUNTING to enable the OS to just treat them as folders. These folders are most often mounted to a single folder off the root drive called /mount or /media in Linux and /Volumes in MAC.
The exact location of a file is called its PATH. The path for the test2.txt file is C:\Test\System. Here are some examples of possible Windows paths: C:\Program files C:\Users\mike F:\FRUSH3\CLEAR D:\
MAC and Linux also use paths. However, folder names are separated by a forward slash (/) instead of the backslash is used by Windows. Also, Windows and OSX are not case sensitive while Linux is case sensitive.
EXAM TIP: exam wants you to know the PWD and PASSWD commands.
Remember this about folder names and file names: Folders and files may have spaces in their names The only disallowed characters in Windows are the following eleven: * " / \ {\[ ] : ; | = , In MAC and Linux, the only disallowed character is a forward slash: / Files are not required to have extensions, but in most cases the OS won't know the file association type without an extension.
Syntax rmdir [Drive:]Path [/s] [/q] rd [Drive:]Path [/s] [/q] Top of page Parameters [ Drive : ] Path : Specifies the location and name of the directory that you want to delete. /s : Removes the specified directory and all subdirectories including any files. Use /s to remove a tree. /q : Runs rmdir in quiet mode. Deletes directories without confirmation. /? : Displays help at the command prompt. Top of page Remarks Using rmdir at the Recovery Console The rmdir command, with different parameters, is available from the Recovery Console. Cannot delete directory with hidden or system files You cannot delete a directory that contains files, including hidden or system files. If you attempt to do so, the following message appears: The directory not empty Use the dir command to list hidden and system files, and the attrib command to remove hidden and system attributes from files. For more information, see Related Topics. Using the backslash character with the path parameter If you insert a backslash (\) before the first directory name in path, the directory is treated as a subdirectory of the root directory, regardless of your current directory. If you do not insert a backslash before the first directory name in path, the directory is treated as a subdirectory of the current directory. Deleting the current directory You cannot use rmdir to delete the current directory. You must first change to a different directory (not a subdirectory of the current directory) and then use rmdir with a path. If you attempt to delete the current directory, the following message appears: The process cannot access the file because it is being used by another process. Top of page Examples To delete a directory named \User\Smith, first ensure that the directory is empty. To do this, type: dir \user\smith /a Only the "." and ".." symbols should display. Then, from any directory except \User\Smith, type: rmdir \user\smith To delete the directory \User and all of the subdirectories and files, type: rmdir /s \user
Removing Directories: the rd command`
What is Robocopy?
Robust copy or robocopy is included in Vista and 7 is a more powerful copy tool
Windows includes a lot of command-line tools for specifics jobs such as starting and stopping services, viewing computers on a network, converting hard drive file systems, and more.
Running a Program in MAC and Linux command line: Open up a terminal. Search for the terminal application in the Dash tool (located as the topmost item in the Launcher). ... Use a text editor to create the C source code. Type the command. ... Compile the program. ... Execute the program.
EXAM TIP: Make sure you know how to use md, mkdir, rd, rmdir, rm, and cd for the exam.
Running a Program in Windows from Command Prompt https://www.wikihow.com/Run-a-Program-on-Command-Prompt
which tool in Windows 8.1 enables you to create a new user account based on a global MS account?
Settings charm
You open a command prompt, you start a shell. The shell acts as the command-line interpreter. Different shells make different command prompts.
Shells are interchangeable and very customizable
CMD How do you copy and rename a file at the same time (Copy Sears.docx from C: to E: and rename it Willis
copy c:\Sears.docx E:\Willis.docx
CMD How do you format a hard drive?
format E: to format the E: drive
https://www.computerhope.com/jargon/d/director.htm
https://en.wikipedia.org/wiki/Mkdir
The CD COMMAND works in every OS.
https://www.computerhope.com/mdhlp.htm
CMD What happens if you type ; in a command?
it interprets it as the end of the command
CMD How do you switch to another drive?
its a letter followed by a ";" like a D: or E:
CMD What should you use when specifying filenames or folders with spaces?
"put the file name in quotes"
Once you get a new prompt, that means the computer is ready for your next instruction. Running commands from the command line from the command line is similiar to clicking icons in the OS GUI. The results are bascially the same; you tell the computer to do something and it responds.
At a command prompt, type NOTEPAD and press ENTER. What happens? The graphical program Notepad opens up, just as if you'd double clicked on its icon
Each file's __________ determine how programs (such as My Computer?) treats the file in special situations
Attributes
mike@server: -$ su password: __ root@seerver:/home/mike# exit mike@server: ~$
EXAM TIP: Many Linux systems disable the root account for safety, rendering the SU command inoperable. The SUDO command enables users to do root things without having the root password.
What is the name of the command-in text editor that comes with Windows?
Edit
How do you copy files in the command prompt?
Have to the command prompt in the directory where the file you want to copy is: type copy and a space type the name of the file (or use wildcards) and a space type the path of the new location for the file(s) Hit Enter
What attribute keeps a file from being displayed when the DIR command is performed?
Hidden
To access the Unix command prompt in Mac OS X, open the Terminal application. It is located by default inside the Utilities folder, which in turn is inside the Applications folder.
In UNIX / Linux file systems, the human-readable address of a resource is defined by PATH. It is an environmental variable that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user.
MAC OS and Linux use a forward slash / instead of a backslash \. This prompt shows user Mike is on the "server" system and is in the home directory. mike@server:/home$
In Windows, if you see a prompt that looks like C:\Diploma\APLUS> you know the focus is on that Folder of the C: drive. The trick is using a command line to first focus the prompt on the drive and folder where you want to work.
It helps to visualize a directory tree as upside down, because in geekspeak, the trunk, or root directory, is described as "above" the folders that divide it, and those subfolders "below' root are spoken of as being "above" the other subfolders inside them. For example, "The file is in the Adobe folder under Program Files."
When describing a drive in Windows, you use its letter and a colon. Hard drive is represented by C: To describe the root directory, put a backslash (\) after the C:, as in C:\. To describe a particular directory, add the name of the directory. For example, if a PC has a directory in the root directory called Test, it is C:\Test.. Subdirectories in a directory are displayed by adding backslashes and names. If the Test directory has a subdirectory called System, it is shown like this: C:\Test\System. This naming convention provides for a complete description of the location and name of any file. If the C:\Test\System directory includes a file alled test2.txt, itis C:\Test\System\test2.txt.
Make sure the prompt points to the directory in which you want to make the new subdirectory before you execute the md command
When you are finished, type DIR to see the new Files subdirectory. Creating folders in MAC and Linux, is again identical but you must use the mkdir command.
If the system doesn't have SUDO, it should have its older cousin SU. With SU, you typically type SU at the prompt and press ENTER, you will be prompted for the root password. Once you have successfully entered the password. Once successfully completed, the prompt will change (usually changing the character at the end of a $ to a #) and every command you enter from then on will be executed as root.
When you finish working as root, type EXIT and press ENTER. Terminal won't close like before, but you will return to a normal prompt.
Both MAC and Linux give you the ability to run the command line with advanced privileges called SUPER USER OR ROOT PRIVILEGES.
Whenever you run a command as root, type SUDO followed by the desired command. The system will prompt for a password and then run the command.
The asterisk is a special character called a(n) _____ that you can use in place of a part or a filename when executing a DOS Command
Wildcard
Structure: Syntax and Switches
You type the name of the command, followed by the target of that command and any modifications of that command you want to apply. You can call up a modification by using an extra letter or number called a SWITCH or OPTION, which may follow either the command or the target, depending on the command.
CMD - how to you add or remove attributes?
attrib + r filename - to add read only attrib - h filename - to remove hidden
CMD How do view file attributes?
attrib [filename] attrib by itself will show attributes in working directory.
CMD How do you go up one directory? (like from sub\meatball to sub)
cd
CMD - how do you go to a subfolder named footlong?
cd footlong
CMD - How can you go to a folder in the root of the directory named example?
cd/example
CMD - How do you go to the root folder of a drive?
cd\
CMD How do you check a hard drive?
chkdsk /f/r /f will fix errors /r will attempt to recover bad sectors
Closing the Terminal
closing a command prompt is easy and done the exact same way in both Windows and OS X and Linux. At the prompt just type EXIT. The terminal window will disappear. mike@server:/home$ exit
CMD How do you make another directory?
md or mkdir followed by the name md Meatball will make a directory called Meatball
Extra text you type after a command to modify its operation is called a(n) __________
parameter or switch
CMD: How do you remove a directory?
rd or rmdir. This will not work if the directory contains files or folders
CMD - What do you use to rename files?
ren or rename ren [Oldfilename] [newfilename]
Accessing the Command-Line Interface in Windows
start the shell program cmd.exe. Go to Start Menu (Vista and 7) or the Start screen's Search bar (Windows 8). In Windows Vista/7 from the Start menu type cmd and press Enter and start the command prompt. In Win8, the search is more hidden but just start typing cmd from Start Screen. The Search cham will appear wiht the full command.