CompTIA A+ : Chapter 15 ( Working with the Command-Line Interface)
Once you successfully enter the password in a Terminal to become the root user, the character at the end of the text will usually change from a __ to a __
$ to a #
What are the two ways that most programming languages require you identify a string with?
'Single' or "double quotes"
What are the eleven disallowed characters to have in a Windows filename?
* " /\ [ ] : ; | = ,
What is the only disallowed character is a macOs and Linux filename?
/
When adding switches such as /s and /e to the command xcopy, what do they do respectively?
/s - tells xcopy to copy all subdirectories except for empty ones /e - tells xcopy to copy empty subdirectories
Given the following languages, name their respective file extensions 1. Batch File 2. PowerShell 3. UNIX shell script 4. Python 5. JavaScript 6. Visual Basic Script
1. Batch File : .bat 2. PowerShell: .ps1 3. UNIX shell script: .sh 4. Python: .py 5. JavaScript: js 6. Visual Basic Script: .vbs
What are the two ways you can open a Terminal in MacOS?
1. From the Utilities folder (Finder, Applications, Utilities) you can launch the Terminal app 2. Activate Spotlight (command-spacebar), type Terminal, and press enter
What is the process for moving a file in Linux/macOS? Ex. You're trying to move the hello.odt file located in the test folder to the folder titled Bottle
1. Point the Terminal to the directory that contains the file 2. Type 'mv' with a space afterwards 3. Type the name of the file to be moved with a space afterwards 4. Type the name of the directory you want to move it to with a forward slash in front of it 5. Press enter Should look like: test>mv hello.odt /Bottle
What is the five step process to copying/moving a file to another drive in Windows? Ex. You're trying to move the notes.docx file located in the Jedi drive (C:) to your thumb drive (D:)
1. Point the command prompt to the directory that contains the file (Jedi) 2. Type 'copy' or 'move' at the command prompt and put a space after it 3. type in the name of the file to be copied with a space after it (notes.docx) 4. Type in the name of the new drive (D:) 5. Press enter Should look like> copy notes.docx D:
Explain how you can create a shortcut for the CLI with administrator privileges on your Windows Desktop
1. Right click the Desktop 2. Click New | Shortcut 3. Type in 'cmd' for the location and name 4. Click finish 5. Right click the icon on your Desktop and select properties 6. Under Shortcut, click advanced and check the Run as Administrator box
What are the two ways you can exit the CLI?
1. click the Close box in the upper right corner 2. type in 'exit' at the prompt and click enter
What are the two Terminal commands that allow you to run the command line with advanced privileges (Super user or root privileges) on both macOS and Linux?
1. sudo 2. su
What is a cmdlet?
A commandlet (cmdlet) is a powerful tool used in the Windows PowerShell environment that builds on typical command-line activities
What is a script?
A group of pre-written commands that can be executed all at once from the Command Line to help automate computer tasks
In programming, what is a basic loop?
A type of conditional that tells the computer to run the code over and over until the condition is (or is not) met
What does the passwd command do?
Allows you to change your password (if logged on as the root user you can change any user's password)
What does the command 'cd..' do?
Allows you to go up a single directory level
What does the "grep" command do?
Allows you to search through text files or command output to find specific information or to filter out unneeded information
What does the 'ps' command do?
Allows you to see detailed and customizable information about the processes running on your system
Why is Spotlight such a phenomenal search tool in macOS? How do you activate Spotlight search?
Because it indexes your drives, not just for file names but for content. Therefore, you can search for any key term and it will not only search your file names but your file's content to retrieve that word You activate Spotlight search by using the key combination 'command + spacebar'
How do you run an application from the Command Line?
Change the prompt focus to the folder where the program is located, type the name of the program, then press enter Ex. If you want to run the application called Smash that's located in the Frog folder, you would navigate to the Frog folder (C:\Users\Tom\Frog) then type in Smash (C:\Users\Tom\Frog> Smash) and press enter
What does the 'cd' command do across macOS, Linux, and Windows?
Changes the focus of a command prompt to a different directory
What are the two modes of the vi editor in macOS and Linux? Briefly explain each.
Command Mode: Allows you to give commands such as cut, paste, etc... Insert Mode : Allows you to insert and edit text
What does the robocopy command do? And what does it stand for?
Copy the files and folders from one computer to another across a network Robust File Copy
Name the concept that computers use to distinguish between words and numbers
Data types
In terms of package managers (PM), what PM do Debian Linux-based distributions use and which do Red Hat-based systems use?
Debian Linux-based distributions : Advanced packaging tool Red Hat-based distributions : Red Hat Package Manager
What is another term that techs use for a Folder?
Directory
What does the ifconfig command do?
Enables you to view and change the settings for your network connections
When at the command line, what do F1, F3, and the up arrow do respectively?
F1 - brings back the previous command one character at a time F3 - brings back the entire previous command Right arrow - It's a history of all your previous commands
T/F: You can create scripts from a prompt, but you run scripts in a text editor
False! You can run scripts from a prompt, but you create scripts in a text editor
T/F: Two or more files with the same name cannot exist in different folders on a PC, but two files in the same folder can have the same name
False: 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
What is the best way to open a Terminal in Linux?
Find the search bar or finder tool, type in Terminal, then press enter
What does ls -l on macOS and Linux do?
Gives detailed information about all the files in the list
What does the 'iwconfig" command do?
Gives you all the wireless details about your wireless Network interface controllers (NICs)
What does the gpresult command do?
Gives you an overview of all security policies applied to a single user or computer
How do you access the Command Line Interface (CLI) from a Windows OS?
Go to the search bar and type in 'cmd'
What does the xcopy command do?
It copies multiple files or entire directories from one drive to another
What does the sfc (system file checker) command do?
It corrects corruption! It scans, detects, and restores important Windows system files, folders, and paths Techs use it to find and fix critical Windows system files that have become corrupt
What does the dir /w command in Windows do?
It displays only filenames and directory names arranged in four to five columns across your screen
What does the hostname command do?
It displays the name of your computer
What does the format command do?
It enables you to format volumes from the command line
What does the shutdown command do?
It enables you to shutdown your system or reboot it
What does the 'help' command do across macOS, Linux, and Windows?
It generates a list of commands you may type if you're lost
What is a package manager in Linux?
It gives you the ability to download and fully install and update software from a single command
What does the ~ mean in a Linux terminal?
It means that you're in the home directory
What does the command 'apt-get' do?
It retrieves the information and packages from authenticated sources for installation, upgrade and removal of packages
What does the chkdsk command do? What do the options /f and /r do when entered along with this command
It scans, detects, and repairs file system issues and errors /f - Fixes errors on the disk /r - Locates bad sectors and recovers readable information
What does the following command mean in macOS and Linux? man [command name] How do you exit this command?
It takes you to the manual where you can find out the syntax and switches used by a particular command To exit the manual, press the Q key to quit back to the prompt
What does the command 'pwd' on macOS and Linux systems tell you?
It tells you exactly where you are in terms of which file or folder locations you're currently working in (i.e., it shows you the working directory)
What is a root directory?
It's a folder at the root of the directory tree (It is NOT within the directory tree)
In the CLI, what is a switch?
It's a function that modifies the behavior of a command Ex. /w or /p after dir (so dir /w or dir /p)
In programming, what is a conditional?
It's a script that enables you to specify code that should only run when some condition is (or is not) met
In programming, what is a string?
It's a sequence of characters such as c-o-w
In Windows CLI, you are shown the exact location of where you're working (Ex. C:\Users\mike\Desktop) but in macOs and Linux, you are only shown a ~ (Ex. mike@server:~$) What does the ~ mean?
It's really just shorthand for your users folder. In reality it should read /home/mike
What is vi in macOS and Linux?
It's the default text editor that's used to edit raw text files
What is a file's association?
It's the type of program that supports the file extension. Ex. a file with an extension of .docx or .doc will only open with Word
For the following programming languages, describe the symbols used to indicate comments JavaScript (single line comments and multi-line comments) Batch file (Older and newer way) Visual Basic Script
JavaScript // This is a single line comment /* This is a multi-line comment Batch file REM Older format : : Newer format Visual Basic Script '
How do you get the prompt to point to another drive in Windows?
Just type the drive letter and a colon Ex. E:
What does the command md do in Windows?
Makes a new directory
What does the command mkdir do in Windows, macOS, and Linux?
Makes a new directory
What three programming languages use a A# symbol to indicate comments?
PowerShell, Python, and UNIX
A folder insider another folder is called a __________________
Subfolder
What does the /mir switch commonly seen after robocopy do?
Tells robocopy to copy everything from the source and make the destination mirror it *Means that robocopy will also delete anything in the destination that doesn't match the source folders and files
What does the '|' symbol mean in macOS, Linux, and Windows?
The '|' symbol is called a pipe. You're telling the OS to take the first command (the command in front of '|') and instead of directly sending it to the screen, pipe, or send it through the second command (the command after the '|')
What does the Windows 'dir' command and the macOs and Linux 'ls' command show you?
The contents of a working directory
What are the two parts of a filename?
The filename and the extension Ex. TempleHousePlan.doc
What are environment variables?
They tell running programs all kinds of information
In programming, what are comments used for?
To help anyone reading the script later on understand what's going on
How do you switch between command mode and insert mode in the vi editor?
To switch to command mode, press 'esc'. To switch to insert mode, press 'i'
T/F: Files are not required to have file extensions, but in most cases the OS won't know the file association type without an extension
True
T/F: 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.
True
T/F: Microsoft's PowerShell is a powerful replacement for the traditional windows command shell
True
T/F: The rd/rmdir command alone will not delete a directory if the directory contains files or sub directories
True
T/F: The robocopy command can copy encrypted files as well as resume copying after an interruption
True
T/F: The trick to using a command line is first to focus the prompt on the drive and folder where you want to work
True
T/F: Window's GUI doesn't show file extensions by default, but macOS and most Linux distros do
True
T/F: macOS and Linux can keep you command history even if you close the terminal or reboot the machine
True
How do you run an executable is Linux?
Use the command './' in front of the executable to make it run
How do you change a file name in Linux/macOS? Say you want to change the name of the file from filename1 to filename2
Use the mv command Ex. mv filename1 filename2
What does the following command mean in Windows? [command name] /?
Used if you want to find out the syntax and switches used by a particular command
What does the 'dd' command do?
Used to create an exact, bit-by-bit image of any form of clock storage such as hard drives, thumb drives, and optical media
What does the gpupdate command allow you to do?
Used to update Group Policy settings such as password complexity, logon attempts, and permissions for users to install software
Most programming languages tell the computer to remember a value (such as "281-465-9264") by naming it; we call these named values ___________________
Variables
What is the function of the 'dir /p' command in Windows?
When you're looking for something in a large directory, this command pauses the text from scrolling to quickly down the screen. Just press the spacebar to display the next screen
What is the function of the 'ls | more' command in macOS and Linux?
When you're looking for something in a large directory, this command pauses the text from scrolling to quickly down the screen. Just press the spacebar to display the next screen
What is the default shell (the tool that interprets input) called in Windows, Mac, and Linux distributions?
Windows - Command Mac & Linux - bash
What would the command look like if you were trying to change the directory to Jay, House, House plan in Windows and Linux/macOS?
Windows : cd Jay\House\House plan Linux/macOS: cd Jay/House/House plan
When entering a path in the CLI, which operating systems are case sensitive and which are not?
Windows and macOS are NOT case sensitive Linux IS case sensitive
Which operating systems use a backslash (\) and which use a forward slash (/) to describe directories?
Windows uses a backslash (\) Ex. C:\Test\System MacOS and Linux use a forward slash (/) Ex. usr/local/bin
How do you delete all files with a specific extension in a folder on Windows and Linux?
Windows: del *.docx Linux: rm *.docx
What command deletes and entire directory in Windows and Linux?
Windows: rd <directory name> /s Linux: rm -r <directory name>
Will you be asked for a password after submitting the command sudo or su? Why?
Yes, the CLI will ask for your password because those commands are asking the CLI to run with administrative privileges (which requires password authentication)
What is the command to save your new file and quit vi?
ZZ
What is the standard format of the 'dd' command?
dd if=<source block device> of=<destination image file location> Ex. dd if=/dev/sda of=/dev/sdb (This means you're trying to copy the sda drive onto the sdb drive
What command deletes a single file in Windows?
del
(Scenario) How would you delete all files with the filename "config" in a Windows directory?
del config.*.
What is the command for using a wildcard to locate files in Windows?
dir *.<any file extension> Ex. dir *.txt
When you run a program from a Linux command line, Linux first looks through a series of folders called the path. You can see this path by typing the command ___________________
echo $PATH
When you finish working as root, type _____ and press enter. Terminal won't close permanently but you will return to your normal prompt without root privileges
exit
What is the replacement command for ifconfig in Linux?
ip
What is the command for using a wildcard to locate files in Linux and macOS that start with the letter s?
ls *s -l
How do you move between drives in macOS and Linux?
macOS - Need to look in the /Volumes folder Ubuntu Linux - Look in the /mnt folder for drives and look in the /media/<user name> folder for removable media
The exact location of a file is called its _________
path
What is the command in Windows to delete directories?
rd
What do the commands rd and rmdir do?
rd - Removes a directory only on Windows rmdir - Removes a directory across Windows, macOS, and Linux
What command deletes a single file in Linux & macOS?
rm
Describe the basic syntax of the robocopy command
robocopy [source] [destination] [options] Ex. robocopy d:\testserver\website \\liveserver\website /mir
What is the syntax for the shutdown option in macOS and Linux?
shutdown <options> <time> Ex. shutdown now (shuts the system down now) Ex. shutdown -r now (restarts the system now)