Chapter 15 - Introduction to Scripting Flashcards

(117 cards)

1
Q

What is the root directory?

A

The top level of a filesystem; on Windows it’s the drive root (e.g., C:), on UNIX-like systems it’s /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a subdirectory?

A

A directory created beneath another directory (a child folder)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do ‘.’ and ‘..’ represent?

A

’.’ is the current directory; ‘..’ is the parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an absolute path vs a relative path?

A

Absolute starts from the root (e.g., C:\Users\Alice); relative starts from the current directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What command lists files in the current directory (Windows)?

A

dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What dir switch lists recursively?

A

dir /s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you show hidden files with dir?

A

dir /a or dir /a:h

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What command changes the current directory?

A

cd or chdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does ‘cd ..’ do?

A

Moves up one directory level

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does ‘cd ‘ do?

A

Changes to the root of the current drive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you create a directory?

A

md or mkdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you create a folder named CTS1133 inside the current folder?

A

md CTS1133

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you remove an empty directory?

A

rd or rmdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you remove a directory tree (and its contents)?

A

rd /s path (optionally add /q for quiet)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What command edits file attributes?

A

attrib

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the read-only attribute do?

A

Prevents edits to a file (+r sets, -r clears)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the archive attribute used for?

A

Marks files that changed since the last backup (+a sets, -a clears)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What does the system attribute do?

A

Marks a file as a system file (+s sets, -s clears)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does the hidden attribute do?

A

Hides files/folders from normal view (+h sets, -h clears)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do you make Cheryl.txt read-only?

A

attrib +r Cheryl.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do you remove the hidden attribute from Cheryl.txt?

A

attrib -h Cheryl.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a script?

A

A text file containing commands that automate a task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

In command syntax docs, what do [square brackets] mean?

A

Optional parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

In command syntax docs, what does ‘|’ indicate?

A

Choose one of the alternatives

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
In command syntax docs, what does '...' indicate?
The preceding item can repeat
26
What is the primary purpose of bcdedit?
View and edit the Boot Configuration Data (BCD) store
27
Where is bootrec typically used?
Windows Recovery Environment to repair boot issues
28
What does chkdsk do?
Checks disk/file system integrity; can fix errors
29
What does chkdsk /f do?
Fixes file system errors
30
What does chkdsk /r do?
Locates bad sectors and recovers readable data (implies /f)
31
What command copies files (basic)?
copy
32
What command deletes files?
del or erase
33
What does del /p do?
Prompts for confirmation before deleting each file
34
What does del /f do?
Forces deletion of read-only files
35
What does del /s do?
Deletes matching files in all subdirectories
36
What does del /q do?
Quiet mode; no prompt
37
What does dir /a:attribute do?
Shows files with a specific attribute (e.g., dir /a:h)
38
What command formats a drive?
format
39
What does gpupdate do?
Refreshes local and AD-based Group Policy settings
40
What does gpresult show?
Resultant Set of Policy (RSoP) for user and computer
41
What does help do?
Lists available commands or shows help for a command
42
What does hostname display?
The computer’s host name
43
What does ipconfig do?
Displays and manages IP configuration for adapters
44
What does ipconfig /all show?
Full TCP/IP configuration for all adapters
45
What does ipconfig /release do?
Releases the DHCP lease for the adapter
46
What does ipconfig /renew do?
Requests a new IP from a DHCP server
47
What does ipconfig /flushdns do?
Clears the DNS resolver cache
48
What opens the Registry Editor?
regedit
49
What does regsvr32 do?
Registers or unregisters DLLs/ActiveX controls
50
What is robocopy?
A robust file copy utility for mirroring/syncing directories
51
What opens the Services console?
services.msc
52
What does System File Checker do?
Scans protected system files and repairs them
53
Which SFC switch runs an immediate scan?
sfc /scannow
54
What does shutdown do?
Shuts down or restarts a local/remote computer
55
How do you force a reboot in 0 seconds?
shutdown /r /t 0
56
What does taskkill do?
Terminates processes by PID or image name
57
What does tasklist do?
Lists running processes (local or remote)
58
What does tracert do?
Traces the route to a destination using ICMP
59
What does xcopy do?
Copies files and directory trees (legacy extended copy)
60
What does whoami show?
Current user, group, and privileges info
61
What does winver show?
The Windows version/build information
62
What is a while loop?
A loop that repeats while its condition remains true
63
What is an infinite loop?
A loop whose condition never becomes false, so it never terminates
64
What are common Windows script file extensions?
.bat or .cmd (Batch), .ps1 (PowerShell)
65
What is a Bash script file extension?
.sh
66
What is the PowerShell execution policy?
A setting that controls script execution (e.g., Restricted, RemoteSigned, Unrestricted)
67
How do you view the execution policy?
Get-ExecutionPolicy (PowerShell)
68
How do you set the execution policy to RemoteSigned (current user)?
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
69
How do you run a PowerShell script bypassing policy for one run?
powershell -ExecutionPolicy Bypass -File .\script.ps1
70
How do you run a command as administrator?
Open an elevated terminal (Run as administrator)
71
What is a shebang line (UNIX-like)?
The first line (e.g., #!/usr/bin/env bash) that selects the script interpreter
72
What is piping?
Sending output of one command into another using |
73
What is output redirection?
Using > to overwrite or >> to append command output to a file
74
How do you redirect errors in Windows CMD?
2> to file, or 2>&1 to merge with stdout
75
What are wildcards * and ? used for?
Pattern matching in file names (* many chars, ? single char)
76
How do you echo text to a file (overwrite) in CMD?
echo Hello > file.txt
77
How do you echo text to a file (append) in CMD?
echo Hello >> file.txt
78
How do you check the last command’s exit code in CMD?
echo %ERRORLEVEL%
79
How do you set an environment variable in CMD (current session)?
set VAR=value
80
How do you persist an environment variable in user profile?
setx VAR value
81
How do you reference env vars in CMD vs PowerShell?
CMD uses %VAR%, PowerShell uses env:VAR
82
What is REM in batch files?
A comment marker (lines starting with REM are ignored)
83
What is the PowerShell comment syntax?
# for single-line; <# ... #> for block comments
84
What PowerShell cmdlet lists files?
Get-ChildItem (alias ls, dir, gci)
85
What PowerShell cmdlet changes directory?
Set-Location (alias cd, sl)
86
What PowerShell cmdlet copies items?
Copy-Item (alias cp, cpi)
87
What PowerShell cmdlet removes items?
Remove-Item (alias rm, ri) with -Recurse -Force for trees
88
What PowerShell cmdlet finds text in files?
Select-String
89
What PowerShell cmdlet shows command help?
Get-Help
90
What PowerShell loop iterates over a collection?
foreach (or ForEach-Object in the pipeline)
91
What is a for /L loop example in CMD?
for /L %%i in (1,1,10) do echo %%i
92
What command maps a network drive in CMD?
net use Z: \\server\share
93
What command cancels a network drive mapping?
net use Z: /delete
94
What command shows open network connections?
netstat
95
What command queries DNS records interactively?
nslookup
96
What command tests basic connectivity?
ping
97
What tool schedules scripts in Windows?
Task Scheduler (GUI) or schtasks command
98
What schtasks example runs a script daily at 11 PM?
schtasks /Create /SC DAILY /TN NightJob /TR C:\Scripts\job.ps1 /ST 23:00
99
What robust copy tool option mirrors a directory with robocopy?
robocopy src dst /MIR
100
What robocopy switches reduce retries and add multithreading?
/R:0 /W:0 /MT:16
101
What DISM command repairs component store online?
DISM /Online /Cleanup-Image /RestoreHealth
102
What is the difference between copy, xcopy, and robocopy?
copy is basic files; xcopy handles trees; robocopy is resilient, multithreaded, and suited for mirroring
103
What is case sensitivity in Windows filenames by default?
Case-preserving but case-insensitive (unless explicitly enabled)
104
What is the current working directory?
The directory context where relative paths are resolved
105
How do you quote paths with spaces in CMD?
Enclose in double quotes, e.g., \"C:\Program Files\App\"
106
What does %PATH% represent?
A list of directories the shell searches for executables
107
What is a variable scope in PowerShell?
Where a variable is visible (e.g., Global, Script, Local)
108
What is an exit code 0 vs nonzero?
0 means success; nonzero indicates an error
109
What is error handling in PowerShell?
Try { } Catch { } Finally { } with ErrorActionPreference controlling behavior
110
What is stdin/stdout/stderr?
Standard input, output, and error streams used by processes
111
What does whoami /groups show?
User’s groups and privileges
112
What does taskkill /IM notepad.exe /F do?
Force-kills all notepad.exe processes
113
What does shutdown /s /t 0 do?
Shuts down the computer immediately
114
What does bcdedit /enum do?
Lists current boot entries
115
What bootrec switches rebuild boot structures?
/fixmbr, /fixboot, /scanos, /rebuildbcd
116
What does services.msc allow you to do?
Start, stop, and configure Windows services
117
What does winver quickly identify during support calls?
Exactly which Windows version/build is installed