Lesson 7 - Chapter 1: Introducing the Command Line Interface Flashcards
What does CLI stand for?
Command-Line Interface
What is a CLI?
a text-based interface app that sends typed commands to the command interpreter (shell)
What is a command interpreter also called?
Shell
Do all the different OS CLI accept the same commands?
No, but Linux and macOS accept similar commands
What are the (at least) 2 CLIs that Windows 10 and 11 have?
- Command Prompt
- PowerShell
What’s the executable file for Command Prompt?
cmd.exe
What is the “Terminal” in Win11?
is a…. that can…
The Terminal is a container that can run multiple CLIs on its own, different tab
What is a “container”?
a lightweight piece of software
How do you open a new tab in Terminal and choose its CLI in Win11?
You click the down arrow in the tabs area, click the CLI you want
How do you get to the Terminal in Win11 quickly?
Win + X or Right-Click the Start button, select Terminal
How do you set a default CLI in Win 11 to Command Prompt? [in Command Prompt]
5 steps
- Have the desired CLI open in the tab
- Settings
- Set “Default Terminal Application” to “Windows Console Host”
- Set “Default Profile” to “Command Prompt”
- Save
How do you quickly open a CLI tab in Terminal in Admin mode?
Ctrl right-click as you click the desired CLI
The macOS Terminal app accepts most of the same commands as…?
Linux
How do you get to the Terminal in macOS?
Finder > Applications > Utilities > Terminal
In a Linux command prompt, what does using the prefix “sudo” and “su” do? (2)
sudo = elevated privileges for the Linux command prompt
su = elevated privileges for the entire session
It’s the Linux version of running in Admin mode (except the app isn’t run in Admin mode it’s set by the user running the command)
What’s the difference between Command Prompt and command prompt?
- Command Prompt is the CLI name
- command prompt is the spot in the CLI where you type
What does “working directory” refer to?
Working directory = the current location
Can you customize the command prompt?
Yes, Power Users usually do
What is the default prompt for Windows CLI?
It shows the complete path to the working directory (including drive letter)
What is the default working directory in Windows 11?
the default working directory in Win 11 CLIs is the user’s personal directory
What does the Linux and macOS CLI command prompt show? (3)
- Current location (working directory)
- Current User
- System Name
What does > indicate in a Windows command prompt?
it means the end of the command prompt
For a Linux Terminal, what indicates the end of the prompt?
$ means the end of the command prompt for Linux
In Linux, what’s shorthand for the user’s home directory?
~ is shorthand for the user’s home directory
What does the “home directory” in Linux refer to?
the top-level directory to which the user has access
(roughly similar to Windows’s personal directory default)
Do you use drive letters in Linux Terminal app prompts?
No, drive letters don’t exist (for Linux and macOS)
Since drive letters don’t exist for Linux and macOS, how do multiple physical disks show up on those systems? (2)
- Linux = mounted in /mnt or /media/username
- macOS = mounted in /Volumes
Because macOS and Linux don’t use drive letters, how are the drives mounted?
the drives are mounted logically to the existing directory tree
What does the “cd” command do?
Changes the focus of the command prompt to another directory
(Change Directory)
Which OS does the “cd” command work in? (3)
- Windows
- Linux
- macOS
When using cd, if the desired directory is a sub-directory of the current one what can you do?
You can use shorthand of the directory name (Public, for example, without a slash) to cd into that sub-directory
When would you need to use the backslash on a directory in a command prompt for Windows when changing directory?
When changing to a directory that’s not a sub-directory
What does the command prompt look like when using cd to go from Users down to the Public directory? (Windows)
c:\Users>cd Public
(shorthand because it’s a sub-directory)
What does the command prompt look like when using cd to go from Users to the Windows directory (not a sub-directory)?
c:\Users>cd \Windows
(need to add the backslash for non sub-directories)
What does the “root directory” mean? (Windows)
The root directory is the top-level directory in the hierarchy
(like c:)
To go from the root directory to the Public directory under Users, what does the command prompt look like? (Windows)
c:>cd \Users\Public
(the full path from the c:\ root top-level directory)
How do you go back up «one level» in the hierarchy in the command prompt when trying to go from C:\Windows\System32 to C:\Windows?
c:\Windows\System32>cd ..
What’s the command prompt to go back to the root directory from the Windows directory?
c:\Windows>cd \
What would you use in the Windows command prompt to go back to the root directory as a shortcut?
backslash
by itself c:\Windows>cd \
Linux: to go from the user’s home directory ~ to a sub-directory, what can you use?
you can just use the directory name
vanesa@Ubuntu:~$cd Documents
Linux: How do you go from a sub-directory of vanesa’s home directory (Documents) to another directory within vanesa’s home directory (Downloads)? (prompt)
vanesa@Ubuntu:~/Documents$cd ~/Downloads
(need the ~ and a forward slash)
Linux: To go from the home directory to ~/Documents/Jedi, what would the prompt look like?
vanesa@Ubuntu:~$cd ~/Documents/Jedi
(needs the full path)
Linux: To go back up one level in the hierarchy, what do you use?
2 dots just like Windows
Linux: How do you go back to the root directory from “Documents”?
vanesa@Ubuntu:~/Documents$cd ~
(you use the ~ root directory shortcut to go back to root directory)
What indicates the end of a prompt for Windows and Linux? (2)
Windows = >
Linux = $
How do you change to another drive letter in the Windows CLI?
change to focus to another drive by typing the target drive letter with a colon
d: or D:
Which OS’s CLI is case-sensitive for paths? (2)
Linux and macOS
Are Windows paths case-sensitive?
No
On Linux, are ~/desktop and ~/Desktop the same directory?
No, they’re different directories hence why Linux is case-sensitive
Commands require proper ____
syntax
What is syntax?
a, s, p
the combination of arguments, switches, and parameters that follow the command
How do you switch the default CLI when right-clicking the Start menu in Windows?
Right-click the taskbar > taskbar settings > toggle off “Replace Command Prompt with Windows PowerShell in the menu when I right-click the start button or press Windows + X”
How does the default prompt differ on Windows and Linux/macOS?
Windows = Shows the complete path to the working directory
Linux/macOS = Shows the working directory, current user, and system name
What do commands use arguments for?
Arguments are used by commands to collect input that’s placed into variables [it’s basically the details]
(like which directory to change to would be the argument)
What are switches also called?
options
What are switches?
they’re codes that specify how the command should process the input
(also called options)
How do (short form) switches usually look like? (2)
- Usually preceded by a slash (/f)
- Usually preceded by a dash (-h)
Each switch may have 3 forms:
- Short form with 1 hyphen or forward slash (-v or /?)
- Long form with 2 hyphens (–help)
- Both
Which switch form is sometimes case-sensitive?
Short forms
Can short switches be combined?
Yes, to change multiple options at once
(ls -la for example)
What happens if you use switches that don’t make sense together? (2)
- Command fails
- Command silently ignores some options
What is a parameter?
an argument (detail) that’s associated with a switch (how to process command)
(-f Notes or file=Notes)
What do the 2 forms that a switch associated with a parameter would look like? Long and short (2)
- Short-form switch - a space before parameter (-f Notes)
- Long-form switch - a = between (file=Notes)
On Windows, how do you view the syntax documentation for almost any command? (2)
- help command
- /? switch
In Terminal, how do you view syntax documentation for almost any command? (2)
- man (manual) command
- -h switch(not working for me on Ubuntu)
How do you request documentation on the cd command? (2) Windows and Linux
- help cd (Windows)
- man cd (Linux)
(both have a primary argument that requests documentation on a topic)
When viewing syntax documentation for a command, optional arguments and switches appear in….?
brackets
(but you don’t type them with brackets in the command line)
Switches are nearly always…. ?
optional
For some commands, is the order of the items important?
Yes
How should you place the order of the syntax?
in the order shown in the help system (switches order usually doesn’t matter but some may need to be placed before/after a required argument)
Required arguments don’t have ____ around them (in the syntax documentation)
brackets
How do mutually exclusive switches appear in the syntax documentation (using /? for example) ?
they appear within a single set of brackets with a pipe symbol between them
ex [/A | /B]
What does it mean when something is mutually exclusive?
they can’t happen at the same time
(either A OR B)