Windows CMD Commands Practice Questions (Command Prompt)

Practice questions on Windows Command Prompt (CMD) commands such as cd, dir, and more, with explanations for every answer.

109 questions · Windows Command Prompt · by Study Foxy

Study these questions free

Questions

  1. In CMD, what does typing cd by itself (with nothing after it) do?

    • Shows the current folder's full path, like pwd
    • Goes to your user folder
    • Goes to the root of C:
    • Clears the screen
  2. You are in C:\Users\student\Documents. What does cd .. do?

    • Moves to C:\Users\student
    • Moves to C:\
    • Moves to C:\Users
    • Lists Documents
  3. You are in C:\Users\student\Documents. What does cd \ do?

    • Moves to C:\
    • Moves to C:\Users\student
    • Moves up one folder
    • Shows an error
  4. You are on the C: drive. How do you switch to the D: drive?

    • Type D:
    • Type cd D and press Enter
    • Type drive D
    • Type cd ..\D:
  5. Which command changes the drive and the folder at the same time?

    • cd /d D:\Games
    • cd D:\Games
    • chdir --drive D:\Games
    • D:\Games /cd
  6. Which character separates folders in a Windows path?

    • Backslash (\)
    • Forward slash (/)
    • Colon (:)
    • Vertical bar (|)
  7. Which is an absolute path?

    • C:\Users\student\notes.txt
    • notes.txt
    • ..\notes.txt
    • .\notes.txt
  8. Which command lists the files and folders in the current directory?

    • dir
    • ls -l
    • list
    • show
  9. Which option makes dir show hidden and system files too?

    • dir /a
    • dir /h
    • dir -a
    • dir /s
  10. What does dir /s *.txt do?

    • Lists .txt files here and in subfolders
    • Lists .txt files in this folder only, skipping subfolders
    • Sorts the .txt files in this folder by their size
    • Deletes every .txt file in this folder and below
  11. What does dir /b show?

    • Only the names
    • Only the biggest files
    • Only backup files
    • Files sorted by date
  12. Which command draws the folder structure as a tree?

    • tree
    • dir /t
    • folders
    • map
  13. CMD commands and file names are not case-sensitive, so DIR and dir do the same thing.

    True or false

  14. In CMD, cd ~ takes you to your home folder, just as it does in Linux.

    True or false

  15. Which command lists the contents of the current directory in CMD?

  16. What do you type to move up one folder? (include the space)

  17. cd .. and cd \ always take you to the same place.

    True or false

  18. Which command creates a new folder named projects?

    • mkdir projects
    • new projects
    • touch projects
    • dir /new projects
  19. What does mkdir school\cs\notes do if none of those folders exist?

    • Creates all three folders in one step
    • Shows an error because school doesn't exist
    • Creates only the notes folder
    • Creates a file named notes
  20. A folder named old still has files in it. Which command deletes it and everything inside without asking?

    • rd /s /q old
    • rd old
    • del old
    • rmdir old /empty
  21. What happens when you run rd old on a folder that still contains files?

    • An error: not empty
    • The folder and its files are deleted
    • Only the files are deleted
    • The folder is moved to the Recycle Bin
  22. Which command deletes a file named draft.txt?

    • del draft.txt
    • rd draft.txt
    • rm -f draft.txt
    • erase /folder draft.txt
  23. What does del *.tmp do?

    • Deletes all .tmp files here
    • Deletes the folder named tmp
    • Deletes one file chosen at random
    • Shows the .tmp files without deleting them
  24. Which command renames report.txt to final.txt?

    • ren report.txt final.txt
    • rename final.txt report.txt
    • copy /r report.txt final.txt
    • name report.txt final.txt
  25. Which command copies notes.txt into the backup folder?

    • copy notes.txt backup
    • move notes.txt backup
    • xcopy /move notes.txt backup
    • cp notes.txt backup
  26. What does move notes.txt archive do (archive is a folder)?

    • Moves notes.txt into the archive folder
    • Copies notes.txt and keeps both
    • Deletes notes.txt
    • Renames the archive folder
  27. Which command copies a folder along with all of its subfolders, including empty ones?

    • xcopy src dest /s /e
    • copy src dest
    • move src dest
    • type src dest
  28. What does robocopy C:\data D:\backup /mir do?

    • Makes D:\backup an exact mirror of C:\data
    • Copies only the newest file
    • Deletes C:\data after copying
    • Shows the differences without copying
  29. You run copy a.txt b.txt and b.txt already exists. What usually happens?

    • CMD asks whether to overwrite b.txt
    • b.txt is silently renamed to b(2).txt
    • The command fails with no message
    • a.txt is deleted
  30. What does attrib +h secret.txt do?

    • Hides secret.txt
    • Deletes secret.txt
    • Encrypts secret.txt with a password
    • Makes secret.txt run as a program
  31. Files deleted with del go to the Recycle Bin.

    True or false

  32. In CMD, wildcards like *.txt match every file whose name ends in .txt.

    True or false

  33. Which command deletes files (three letters)?

  34. Which command renames a file? (short form)

  35. Which commands remove a folder?

    • rd
    • rmdir
    • del
    • dir
    • md
  36. ren can move a file to a different folder or drive.

    True or false

  37. Which command prints the contents of notes.txt on the screen?

    • type notes.txt
    • cat notes.txt
    • show notes.txt
    • dir notes.txt /c
  38. A text file is too long to read on one screen. Which command shows it a page at a time?

    • more log.txt
    • less log.txt
    • type /page log.txt
    • dir /p log.txt
  39. Which command searches report.txt for lines containing Error?

    • findstr Error report.txt
    • grep Error report.txt
    • search Error report.txt
    • dir Error report.txt
  40. Which option makes findstr ignore uppercase and lowercase differences?

    • /i
    • /c
    • /v
    • /n
  41. What does findstr /v Error report.txt show?

    • Lines that do NOT contain Error
    • Only the lines that contain Error
    • The number of lines with Error
    • The line numbers of each Error
  42. Which command finds where notepad.exe is located on the PATH?

    • where notepad
    • find notepad
    • dir notepad
    • locate notepad
  43. What does find /c "Error" log.txt do?

    • Counts lines with Error
    • Deletes the lines containing Error
    • Shows lines without Error
    • Creates a file named Error
  44. The find command is case-sensitive unless you add /i.

    True or false

  45. Which CMD command shows a file's contents, like cat in Linux?

  46. Which CMD command searches files for text, similar to grep? (the more powerful one)

  47. What does echo Hello > hi.txt do?

    • Overwrites hi.txt with Hello
    • Adds Hello to the end of hi.txt
    • Prints Hello and also hi.txt
    • Renames hi.txt to Hello
  48. What does echo Bye >> hi.txt do?

    • Appends Bye to hi.txt
    • Replaces everything in hi.txt with Bye
    • Deletes hi.txt
    • Shows Bye twice
  49. hi.txt contains Hello. You run echo Bye > hi.txt. What does type hi.txt show?

    • Bye
    • Hello Bye
    • Hello
    • Nothing
  50. hi.txt contains Hello. You run echo Bye >> hi.txt. What does type hi.txt show?

    • Hello Bye
    • Bye
    • Hello
    • Bye Hello

Showing 50 of 109. Open the quiz to study them all.