Explain: Get-Children and Rename-Item

Below, parent command means the main cmdlet being used: Get-ChildItem or Rename-Item.


1. Get-ChildItem -Path C:\Users\sayed\* -Include *.txt

Parent command: Get-ChildItem

Get-ChildItem lists files and folders in a location. It is similar to:

dir
ls
gci

Your rename-files lab explains that Get-ChildItem returns items from one or more locations and can be combined with filtering parameters such as -Include, -Exclude, -Recurse, and -Depth.

Parameters

-Path C:\Users\sayed\*

Means:

Look inside C:\Users\sayed\.

The * wildcard means:

Match all items inside that folder.

-Include *.txt

Means:

Include only files/items matching *.txt.

So this command means:

Show only .txt files under C:\Users\sayed\

Important: -Include usually works best when the path includes a wildcard *, or when used with -Recurse.


2. Get-ChildItem -Path C:\Users\sayed\* -Exclude A*

Parent command: Get-ChildItem

Again, this lists files and folders.

Parameters

-Path C:\Users\sayed\*

Looks at all items inside:

C:\Users\sayed\
-Exclude A*

Means:

Exclude items whose names start with A.

So this command means:

Show all items under C:\Users\sayed\, except items starting with A.

Example excluded names:

Assignment.txt
Archive
Apple.docx

3. Rename-Item -Path "C:\Test\test_file.txt" -NewName "mytest_file.txt"

Parent command: Rename-Item

Rename-Item changes the name of a file, folder, or registry key without changing its contents.

Parameters

-Path "C:\Test\test_file.txt"

Means:

This is the item to rename.

-NewName "mytest_file.txt"

Means:

Rename it to this new name.

So this command means:

Rename C:\Test\test_file.txt to mytest_file.txt.

After the command, the file becomes:

C:\Test\mytest_file.txt

Important: -NewName should be the new name only, not usually a full new path.


4. Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace ".txt", ".log" } -WhatIf

Parent commands

This command uses two parent commands:

Get-ChildItem
Rename-Item

It uses the pipeline to send files from Get-ChildItem into Rename-Item.


Part 1

Get-ChildItem *.txt

Means:

Find all .txt files in the current folder.


Part 2

|

The pipeline sends each .txt file object to Rename-Item.


Part 3

Rename-Item -NewName { $_.Name -replace ".txt", ".log" }

This renames each file.

$_

Means:

The current file object coming through the pipeline.

$_.Name

Means:

The current file’s name.

-replace ".txt", ".log"

Means:

Replace .txt with .log.

So:

report.txt

would become:

report.log

Part 4

-WhatIf

Means:

Show what would happen, but do not actually rename the files.

This is a safety option.

So the full command means:

Find all .txt files in the current folder and show how they would be renamed to .log files, but do not actually rename them.

Compare and Contrast

CommandMain PurposeChanges Anything?Scope
Get-ChildItem -IncludeShows only matching itemsNoFile/folder listing
Get-ChildItem -ExcludeHides matching itemsNoFile/folder listing
Rename-Item -Path ... -NewName ...Renames one specific itemYesOne file/folder
Get-ChildItem ... | Rename-Item ... -WhatIfSimulates bulk renameNo, because of -WhatIfMultiple files

Key Difference: -Include vs -Exclude

ParameterMeaning
-Include *.txtShow only .txt files
-Exclude A*Show everything except names starting with A

Key Difference: Single Rename vs Bulk Rename

Single rename

Rename-Item -Path "C:\Test\test_file.txt" -NewName "mytest_file.txt"

Used when you know the exact file.

Bulk rename

Get-ChildItem *.txt |
Rename-Item -NewName { $_.Name -replace ".txt", ".log" } -WhatIf

Used when many files need the same pattern-based rename.


Safe teaching version

Always test bulk renaming first with:

-WhatIf

Then, after confirming the output is correct, remove -WhatIf:

Get-ChildItem *.txt |
Rename-Item -NewName { $_.Name -replace ".txt", ".log" }

Student comment:

# This command finds all .txt files and uses Rename-Item to change
# their extension to .log. The -WhatIf parameter previews the changes
# without actually renaming the files.

REF: AI Tools/ChatGPT

compare contrast these commands: Get-Disk | Format-Table -Auto Get-PhysicalDisk Get-Partition -DiskNumber 0 Get-Partition -DriveLetter D

These four commands are all disk/partition viewing commands, but they look at different levels of storage.

The disk-management lab explains that Get-Disk shows logical disks, Get-PhysicalDisk shows physical disk devices, and Get-Partition is used to view partition information for a disk.

CommandMain PurposeLevel
Get-Disk | Format-Table -AutoShows disks in a clean tableDisk level
Get-PhysicalDiskShows physical storage devicesHardware/storage level
Get-Partition -DiskNumber 0Shows all partitions on disk 0Partition level
Get-Partition -DriveLetter DShows the partition assigned to drive D:Specific drive-letter partition

1. Get-Disk | Format-Table -Auto

Get-Disk | Format-Table -Auto

Shows the disks Windows recognizes.

Useful for checking:

Disk number
Size
Health status
Operational status
Partition style: RAW, MBR, GPT

Format-Table -Auto only improves display by auto-sizing columns.

Use this first when asking:

What disks are connected, and are they initialized?


2. Get-PhysicalDisk

Get-PhysicalDisk

Shows the actual physical storage devices.

Useful for checking:

Friendly name
Media type
CanPool
Health status
Operational status
Size

This is more useful when working with:

Storage Spaces
Physical drives
Hardware-level disk information

Simple difference:

Get-Disk = disks Windows can manage logically
Get-PhysicalDisk = actual physical storage devices

3. Get-Partition -DiskNumber 0

Get-Partition -DiskNumber 0

Shows all partitions on Disk 0.

Useful for seeing:

System partition
Recovery partition
C: partition
EFI partition
Reserved partition

Use this when asking:

What partitions exist on this disk?

Example:

Disk 0 may contain C:, EFI, Recovery, and system partitions.

4. Get-Partition -DriveLetter D

Get-Partition -DriveLetter D

Shows the partition that owns drive letter D:.

Useful when asking:

Which partition is my D: drive?

It gives partition information such as:

DiskNumber
PartitionNumber
DriveLetter
Size
Type

This is more specific than -DiskNumber.


Key Comparison

Get-Disk

answers:

What disks exist?

Get-PhysicalDisk

answers:

What physical storage devices exist?

Get-Partition -DiskNumber 0

answers:

What partitions are on disk 0?

Get-Partition -DriveLetter D

answers:

Which partition corresponds to D:?


Teaching Flow

Use them in this order:

Get-Disk | Format-Table -Auto

Then inspect a disk:

Get-Partition -DiskNumber 0

Then inspect one drive letter:

Get-Partition -DriveLetter D

Then compare physical storage:

Get-PhysicalDisk

Student comment:

# Get-Disk shows disks, Get-PhysicalDisk shows physical devices,
# and Get-Partition shows partitions either by disk number or drive letter.

REF: AI Tools/ChatGPT

Command performs the full setup of a new RAW disk in one PowerShell pipeline:

explain: Get-Disk | Where PartitionStyle -eq “RAW” | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel “MYDATA”

This command performs the full setup of a new RAW disk in one PowerShell pipeline:

Get-Disk |
Where PartitionStyle -eq "RAW" |
Initialize-Disk -PartitionStyle GPT -PassThru |
New-Partition -UseMaximumSize -AssignDriveLetter |
Format-Volume -FileSystem NTFS -NewFileSystemLabel "MYDATA"

Full meaning

Find any uninitialized disk, initialize it as GPT, create one large partition, assign a drive letter, and format it as NTFS with the label MYDATA.


Step-by-step explanation

1. Find disks

Get-Disk

Lists all disks connected to the system.


2. Select only RAW disks

Where PartitionStyle -eq "RAW"

Filters only disks whose partition style is RAW.

RAW means:

The disk is new or uninitialized.

3. Initialize the disk as GPT

Initialize-Disk -PartitionStyle GPT -PassThru

This prepares the disk for use.

GPT means GUID Partition Table, the modern partition style.

-PassThru is important here because it sends the initialized disk object to the next command in the pipeline.

Without -PassThru, the next command may not receive the disk object.


4. Create a partition

New-Partition -UseMaximumSize -AssignDriveLetter

Creates one partition using all available disk space.

-UseMaximumSize means:

Use the full disk space.

-AssignDriveLetter means:

Automatically assign a drive letter, such as E: or F:

5. Format the volume

Format-Volume -FileSystem NTFS -NewFileSystemLabel "MYDATA"

Formats the new partition.

NTFS is the Windows file system.

MYDATA is the volume label/name that appears in File Explorer.


What happens after running it?

A new usable drive appears, for example:

E:  MYDATA

You can then store files on it.


Very important warning

This command can erase or prepare disks. Use it only on a new test disk, preferably inside a VM.

Before running it, always check:

Get-Disk

Safer version:

Get-Disk | Where-Object PartitionStyle -eq "RAW"

Then confirm the correct disk before initializing.


Student comment

# This command finds uninitialized RAW disks, initializes them using GPT,
# creates one full-size partition, assigns a drive letter,
# and formats the volume as NTFS with the label MYDATA.

REF: AI Tools/ChatGPT

Variations of: Get-Process | Select Name,Id,CPU | Sort CPU -Descending

Yes. These commands produce the same type of output: process Name, Id, and CPU, sorted by CPU in descending order.

Variation 1: Full cmdlet names

Get-Process |
Select-Object -Property Name, Id, CPU |
Sort-Object -Property CPU -Descending

Variation 2: Sort first, then select

Get-Process |
Sort-Object -Property CPU -Descending |
Select-Object -Property Name, Id, CPU

Variation 3: Use aliases

gps | select Name,Id,CPU | sort CPU -Descending

Variation 4: Show only top 10 highest CPU processes

Get-Process |
Sort-Object CPU -Descending |
Select-Object Name, Id, CPU -First 10

Best teaching version:

Get-Process |
Sort-Object -Property CPU -Descending |
Select-Object -Property Name, Id, CPU

Comment:

# This command gets all running processes, sorts them by CPU time from highest to lowest,
# and displays only the Name, Id, and CPU properties.

REF: AI Tools/ChatGPT

Explain: Get-Process | Select Name,Id,CPU | Sort CPU -Descending

This command shows running processes with selected columns and sorts them by CPU usage/time.

Get-Process | Select Name,Id,CPU | Sort CPU -Descending

Meaning step by step

1. Get-Process

Get-Process

Gets all running processes on the computer.


2. Pipeline |

|

Passes the process objects to the next command.


3. Select Name,Id,CPU

Select Name,Id,CPU

Short form of:

Select-Object Name, Id, CPU

It displays only these properties:

PropertyMeaning
NameProcess name
IdProcess ID
CPUTotal CPU seconds used by the process

4. Sort CPU -Descending

Sort CPU -Descending

Short form of:

Sort-Object CPU -Descending

It sorts the output by CPU from highest to lowest.


Full meaning

Get-Process | Select Name,Id,CPU | Sort CPU -Descending

means:

Get all running processes, show only Name, Id, and CPU, then sort them from highest CPU time to lowest CPU time.

Better formal version

Get-Process |
Select-Object Name, Id, CPU |
Sort-Object CPU -Descending

Student comment

# This command lists running processes, selects only the Name, Id, and CPU properties,
# and sorts the results by CPU usage in descending order.

Ref: AI Tools/ChatGPT

write-output vs write-host

Write-Output vs Write-Host in PowerShell

FeatureWrite-OutputWrite-Host
Sends data to pipeline✅ Yes❌ No
Can be stored in variable✅ Yes❌ Usually no
Can be redirected to file✅ Yes❌ Not normally useful
Used for script output✅ Recommended⚠️ Mainly for display messages
Supports formatting/colorLimited✅ Good for colors

1. Write-Output

Write-Output sends data to the PowerShell pipeline.

Write-Output "Hello PowerShell"

You can store it:

$result = Write-Output "Hello PowerShell"
$result

You can pipe it:

Write-Output "Hello PowerShell" | Get-Member

You can redirect it:

Write-Output "Hello PowerShell" > C:\Temp\output.txt

Use Write-Output when the data may need to be reused, filtered, piped, stored, or exported.


2. Write-Host

Write-Host writes directly to the screen/console.

Write-Host "Hello PowerShell"

It is useful for colored messages:

Write-Host "Success" -ForegroundColor Green
Write-Host "Warning" -ForegroundColor Yellow
Write-Host "Error" -ForegroundColor Red

But it does not send normal output to the pipeline.

Example:

$result = Write-Host "Hello PowerShell"
$result

$result will not contain "Hello PowerShell".


Main Difference

Write-Output "Data"

means:

Send this data forward in the pipeline.

Write-Host "Message"

means:

Show this message on the screen.


Teaching Example

Write-Output "notepad" | Get-Process

This can work because "notepad" is passed through the pipeline.

But:

Write-Host "notepad" | Get-Process

will not work the same way because Write-Host only prints to the screen.


Best Practice

Use:

Write-Output

for real script output.

Use:

Write-Host

for user-friendly messages, colors, headings, or progress-style display.

Example:

Write-Host "Checking services..." -ForegroundColor Cyan
Get-Service | Where-Object Status -eq "Running"

REF: AI Tools/ChatGPT

Power Shell: explain: Get-Disk | Where PartitionStyle -eq “RAW” | Initialize-Disk -PartitionStyle GPT

This command finds uninitialized disks and initializes them using the GPT partition style:

Get-Disk | Where PartitionStyle -eq "RAW" | Initialize-Disk -PartitionStyle GPT

Step-by-step explanation

1. Get-Disk

Get-Disk

Lists disks connected to the system.

It shows information such as:

Number
FriendlyName
OperationalStatus
Size
PartitionStyle

2. Where PartitionStyle -eq "RAW"

Where PartitionStyle -eq "RAW"

Filters only disks where the PartitionStyle is RAW.

RAW usually means:

The disk has not been initialized yet.

So PowerShell is looking for a new/unprepared disk.


3. Initialize-Disk -PartitionStyle GPT

Initialize-Disk -PartitionStyle GPT

Initializes the selected RAW disk and sets the partition style to GPT.

GPT means:

GUID Partition Table

GPT is the modern partitioning style and is recommended for most new systems. Your lab notes explain that GPT is more modern and reliable than MBR, supports many partitions, and supports disks larger than 2 TB.


Full meaning

Get-Disk | Where PartitionStyle -eq "RAW" | Initialize-Disk -PartitionStyle GPT

means:

Get all disks, find the disks that are not initialized, and initialize them using GPT.


Important warning

This command can affect disks. Students should run it only on a test VM disk, not on a real important disk.

Safer version:

Get-Disk | Where-Object PartitionStyle -eq "RAW"

First check which disk is RAW.

Then initialize a specific disk:

Initialize-Disk -Number 1 -PartitionStyle GPT

What comes after this?

Initializing the disk does not create a usable drive letter yet.

Usually the next steps are:

New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter

Then format it:

Format-Volume -DriveLetter E -FileSystem NTFS -NewFileSystemLabel "DataDisk"

Student comment

# This command finds disks with RAW partition style and initializes them as GPT.
# RAW means the disk is not initialized. GPT is the modern partition style.
Ref: AI/ChatGPT

GPT in PowerShell

Ref: AI Tool/ChatGPT

GPT in Disk Management

GPT means GUID Partition Table.

It is a modern disk partitioning system used to organize partitions on a hard drive, SSD, or virtual disk.

In PowerShell disk management, you may see it here:

Get-Disk

Example output:

Number  FriendlyName      PartitionStyle
------  ------------      --------------
0       Virtual Disk      GPT
1       Virtual Disk      RAW

What GPT does

GPT tells the operating system:

  • where partitions start and end
  • how many partitions exist
  • what type each partition is
  • how the disk should be organized

Before a new disk can be used, it usually must be:

Initialized → Partitioned → Formatted

GPT is chosen during the Initialize stage.


GPT vs MBR

FeatureGPTMBR
MeaningGUID Partition TableMaster Boot Record
AgeModernOlder
Max disk sizeVery large disksAbout 2 TB limit
Partition limitMany partitionsUsually 4 primary partitions
ReliabilityMore reliableMore prone to corruption
FirmwareUEFILegacy BIOS
Recommended todayYesOnly for old compatibility

Your lab notes explain that MBR is older, has a 2 TB disk size limit, and supports only a limited number of primary partitions, while GPT is modern, more reliable, and supports much larger disks.


What does RAW mean?

Before GPT is applied, a new disk may show:

PartitionStyle: RAW

RAW means:

The disk is not initialized yet.

So this command:

Get-Disk | Where PartitionStyle -eq "RAW" | Initialize-Disk -PartitionStyle GPT

means:

Find uninitialized disks and initialize them using GPT.


Important warning

Initializing, partitioning, or formatting the wrong disk can cause data loss.

Before running disk commands, always check:

Get-Disk

Then identify the correct disk number.

Safer version:

Get-Disk | Where-Object PartitionStyle -eq "RAW"

Then initialize only the correct disk:

Initialize-Disk -Number 1 -PartitionStyle GPT

Full GPT disk setup example

Step 1: Find RAW disk

Get-Disk | Where-Object PartitionStyle -eq "RAW"

Step 2: Initialize disk as GPT

Initialize-Disk -Number 1 -PartitionStyle GPT

Step 3: Create a new partition

New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter

Step 4: Format the volume

Format-Volume -DriveLetter E -FileSystem NTFS -NewFileSystemLabel "DataDisk"

Simple classroom explanation

GPT is the modern way Windows organizes partitions on a disk. It replaces the older MBR system and is better for modern systems, larger disks, and UEFI-based computers.

Student comment:

# GPT stands for GUID Partition Table.
# It is the modern partition style used for initializing new disks.
# It is preferred over MBR because it supports larger disks and more partitions.

20 mixed quiz questions on Quoting and Control Statements.

20 mixed quiz questions on Quoting and Control Statements.


Quiz: Quoting and Control Statements

True/False Questions

1. True/False

Double quotes prevent all shell interpretation, including variable substitution and command substitution.

Answer: False
Explanation: Double quotes prevent some special character interpretation, but they still allow variable substitution and command substitution.


2. True/False

Single quotes prevent the shell from interpreting variables, command substitution, globs, and other metacharacters.

Answer: True


3. True/False

The backslash character can be used to remove the special meaning of a metacharacter.

Answer: True


4. True/False

The semicolon ; runs the next command only if the previous command succeeds.

Answer: False
Explanation: The semicolon runs commands one after another, even if the previous command fails.


Multiple Choice Questions

5. Multiple Choice

Which command correctly assigns the value hello there to the variable var?

A.

var=hello there

B.

var = “hello there”

C.

var=”hello there”

D.

var=’hello’ there

Answer: C


6. Multiple Choice

What will the following command display?

var=hello

echo ‘$var’

A. hello
B. $var
C. var
D. Nothing

Answer: B
Explanation: Single quotes prevent variable substitution.


7. Multiple Choice

What does command substitution allow you to do?

A. Delete a command from history
B. Run a command and use its output inside another command
C. Convert a local variable into an environment variable
D. Stop all special characters from working

Answer: B


8. Multiple Choice

Which control statement runs the next command only if the previous command succeeds?

A. ;
B. &&
C. ||
D. \

Answer: B


Multi-Select Questions

9. Multi-Select

Which of the following are shell metacharacters or special characters mentioned or implied in this topic?

Select all that apply.

A. *
B. ?
C. Space
D. &&
E. cat

Answers: A, B, C, D


10. Multi-Select

Which commands correctly use command substitution?

Select all that apply.

A.

echo Today is `date`

B.

echo Today is $(date)

C.

echo Today is date

D.

today=$(date)

echo “$today”

Answers: A, B, D


11. Multi-Select

Which statements about double quotes are correct?

Select all that apply.

A. They can keep words with spaces together
B. They allow variable substitution
C. They allow command substitution
D. They prevent absolutely all shell interpretation
E. They can help assign a value with spaces to a variable

Answers: A, B, C, E


12. Multi-Select

Which statements about control statements are correct?

Select all that apply.

A. ; runs commands one after another
B. && runs the next command only if the previous command succeeds
C. || runs the next command only if the previous command fails
D. && always runs the second command
E. || means command substitution

Answers: A, B, C


Fill in the Blank with Choices

13. Fill in the Blank

The command below uses __________ quotes.

echo “$var”

Choices:
A. single
B. double
C. back
D. no

Answer: B. double


14. Fill in the Blank

The symbol __________ is used as an escape character in the shell.

Choices:
A. ;
B. \
C. ||
D. &&

Answer: B. \


15. Fill in the Blank

The control statement __________ means logical OR.

Choices:
A. ;
B. &&
C. ||
D. $()

Answer: C. ||


Matching Questions

16. Matching

Match each quoting method with its purpose.

Quoting MethodPurpose
1. Double quotes ” “A. Prevent almost all shell interpretation
2. Single quotes ‘ ‘B. Escape one special character
3. Backslash \C. Allow variables and command substitution while grouping text
4. Backquotes ` `D. Perform command substitution

Answer:

Quoting MethodCorrect Purpose
Double quotes ” “C
Single quotes ‘ ‘A
Backslash \B
Backquotes ` `D

17. Matching

Match each control statement with its meaning.

Control StatementMeaning
1. ;A. Run next command only if previous command fails
2. &&B. Run commands one after another
3. `

Answer:

Control StatementCorrect Meaning
;B
&&C
`

Ordering Questions

18. Ordering

Put the steps in the correct order to create a variable with spaces and display it.

A. Display the variable using echo “$var”
B. Use double quotes around the value
C. Assign the value using var=”hello there”

Correct Order:

  1. B
  2. C
  3. A

Final Commands:

var=”hello there”

echo “$var”


19. Ordering

Put the commands in the correct order to test whether /home exists and print success or failure.

A.

echo failure

B.

ls /home

C.

echo success

D.

&&

E.

||

Correct Order:

  1. B
  2. D
  3. C
  4. E
  5. A

Final Command:

ls /home && echo success || echo failure


Short Answer / Higher-Order Questions

20. Short Answer

A student writes the following command and gets an error:

var=hello there

Explain why this happens and write the corrected command.

Sample Answer:
The shell treats the space as a separator. It reads var=hello as one part and there as another command or statement. Since there is not a valid command, an error occurs.

Correct command:

var=”hello there”

The double quotes keep hello there together as one value.

30 mixed quiz questions on Linux Command Line Skills

30 mixed quiz questions on Linux Command Line Skills. They include TF, MCQ, Multi-select, Matching, Ordering, Fill in the Blank with Choices, and Short Answer questions, testing concept knowledge, hands-on command skills, analysis, and higher-order thinking.


Quiz: Command Line Skills

True/False Questions

1. True/False

The command line interface is slower than the GUI and provides less control over the operating system.

Answer: False
Explanation: The CLI is powerful, fast, and gives users strong control over the system.


2. True/False

A shell is an application that allows users to access operating system services by entering commands.

Answer: True


3. True/False

Bash is one of the most commonly used shells in Linux.

Answer: True


4. True/False

Local variables remain available even after the terminal window or shell is closed.

Answer: False
Explanation: Local variables exist only in the current shell session.


5. True/False

The PATH environment variable helps the shell find executable files for commands.

Answer: True


Multiple Choice Questions

6. Multiple Choice

Which of the following best describes the CLI?

A. A graphical interface that uses icons and menus
B. A text-based interface where users type commands
C. A file manager only
D. A web browser interface

Answer: B


7. Multiple Choice

In the prompt below, what does ~ usually represent?

ivanovn@atlas:~$

A. The root directory
B. The current user’s home directory
C. The system name
D. The command history file

Answer: B


8. Multiple Choice

In the command below, what is /home?

ls /home

A. Command
B. Option
C. Argument
D. Variable

Answer: C


9. Multiple Choice

In the command below, what is -l?

ls -l

A. Argument
B. Option
C. Shell name
D. Environment variable

Answer: B


10. Multiple Choice

Which command shows the list of previously typed commands?

A. which
B. type
C. history
D. alias

Answer: C


11. Multiple Choice

Which command shows the executable file that will run when a command is typed?

A. which
B. unset
C. export
D. history

Answer: A

Example:

which ls


12. Multiple Choice

Which command can identify whether a command is internal, external, alias, or function?

A. pwd
B. type
C. env
D. echo

Answer: B


Multi-Select Questions

13. Multi-Select

Which of the following are popular Bash shell features?

Select all that apply.

A. Command history
B. Inline editing
C. Scripting
D. Aliases
E. Variables
F. Automatic hardware replacement

Answers: A, B, C, D, E


14. Multi-Select

Which of the following are valid parts of a typical Linux command format?

Select all that apply.

A. Command
B. Options
C. Arguments
D. Wallpaper
E. Keyboard layout only

Answers: A, B, C

General format:

command [options]… [arguments]…


15. Multi-Select

Which commands are examples of shell built-in/internal commands mentioned in the module?

Select all that apply.

A. cd
B. echo
C. /bin/ls
D. /usr/bin/cal

Answers: A, B


16. Multi-Select

Which statements about environment variables are correct?

Select all that apply.

A. They help control the Linux runtime environment
B. They are also called global variables
C. Examples include PATH, HOME, and HISTSIZE
D. They can never be displayed
E. The env command can list them

Answers: A, B, C, E


17. Multi-Select

Which commands are related to aliases?

Select all that apply.

A. alias
B. unalias
C. type
D. history
E. format

Answers: A, B, C

Explanation:
alias displays or creates aliases.
unalias removes aliases.
type can identify whether a command is an alias.


Fill in the Blank with Choices

18. Fill in the Blank

A command is a program that performs an __________ on the computer.

Choices:
A. icon
B. action
C. extension
D. theme

Answer: B. action


19. Fill in the Blank

The most commonly used shell in Linux is __________.

Choices:
A. Bash
B. Finder
C. Explorer
D. Android

Answer: A. Bash


20. Fill in the Blank

The command __________ is used to turn a local variable into an environment variable.

Choices:
A. unset
B. export
C. which
D. history

Answer: B. export


21. Fill in the Blank

The command __________ removes a variable.

Choices:
A. unset
B. alias
C. which
D. type

Answer: A. unset


Matching Questions

22. Matching

Match each term with its correct description.

TermDescription
1. CLIA. Program that processes commands
2. TerminalB. Text-based interface for typing commands
3. ShellC. Program that runs a shell
4. BashD. Common Linux shell

Answer:

TermCorrect Description
CLIB
TerminalC
ShellA
BashD

23. Matching

Match each command with its purpose.

CommandPurpose
1. historyA. Shows the path of an executable command
2. whichB. Shows command history
3. envC. Lists environment variables
4. unsetD. Removes a variable
5. exportE. Converts a local variable into an environment variable

Answer:

CommandCorrect Purpose
historyB
whichA
envC
unsetD
exportE

24. Matching

Match each command type with its correct meaning.

Command TypeMeaning
1. Internal commandA. Short name for a longer command
2. External commandB. Command built into the shell
3. AliasC. Command stored as an executable file
4. FunctionD. Structure used to create or change command behavior

Answer:

Command TypeCorrect Meaning
Internal commandB
External commandC
AliasA
FunctionD

Ordering Questions

25. Ordering

Put the steps in the correct order to create and display a local variable.

A. Display the value using echo $var
B. Assign the value using var=Hello
C. Open or use a shell

Correct Order:

  1. C
  2. B
  3. A

Final Commands:

var=Hello

echo $var


26. Ordering

Put the steps in the correct order to make a local variable available as an environment variable and confirm it.

A. Use env | grep var
B. Create the variable using var=Hello
C. Export the variable using export var

Correct Order:

  1. B
  2. C
  3. A

Final Commands:

var=Hello

export var

env | grep var


27. Ordering

Put the steps in the correct order to create, test, and remove an alias.

A. Run the alias name
B. Create the alias
C. Remove the alias using unalias
D. Check the alias using type

Correct Order:

  1. B
  2. D
  3. A
  4. C

Example:

alias mydate=’cal 7 2000′

type mydate

mydate

unalias mydate


Short Answer Questions

28. Short Answer

Explain the difference between an option and an argument. Give one example command.

Sample Answer:
An option modifies the behavior of a command. An argument gives the command additional information, such as a file or directory name.

Example:

ls -l /home

In this command, -l is the option and /home is the argument.


29. Short Answer / Hands-on

Write the command to create a local variable named course with the value Linux, then display the value.

Answer:

course=Linux

echo $course


30. Higher-Order Short Answer

A student types cal, but the shell returns:

command not found

Using your knowledge of external commands and the PATH variable, explain two possible reasons this happened and one command that can help investigate the problem.

Sample Answer:
One possible reason is that the cal program is not installed. Another possible reason is that the executable file exists, but its directory is not listed in the PATH variable. The shell searches the directories listed in PATH to find external commands.

A useful command is:

which cal

The student can also check the PATH variable using:

echo $PATH

REF: AI Tools