0% found this document useful (0 votes)
1 views61 pages

CSCI1520 25spring Tutorial 2

This document is a tutorial on Command Line Interface (CLI) and the introduction of UTM, aimed at students of The Chinese University of Hong Kong. It covers the basics of CLI, including commands and their usage across different operating systems, as well as detailed steps for installing a Windows virtual machine on Mac using UTM. The tutorial also compares CLI with Graphical User Interface (GUI) and provides practical examples of command usage.

Uploaded by

ke ke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views61 pages

CSCI1520 25spring Tutorial 2

This document is a tutorial on Command Line Interface (CLI) and the introduction of UTM, aimed at students of The Chinese University of Hong Kong. It covers the basics of CLI, including commands and their usage across different operating systems, as well as detailed steps for installing a Windows virtual machine on Mac using UTM. The tutorial also compares CLI with Graphical User Interface (GUI) and provides practical examples of command usage.

Uploaded by

ke ke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 61

CSCI1520 Tutorial 2

Command Line Interface & Introduction of


UTM

The Chinese University of Hong Kong


January 20, 2025

Yuxuan Bian
[email protected]
Ho Sin-hang Engineering Building (SHB)
1026 17 Fri 9:30-11:30

1
Outline

1 Introduction to
CLI

2.Basic usage of system


commands

3. Introduction of UTM

2
Part 1. Introduction to CLI

3
Introduction to CLI

1 Operating system (OS)


2 Graphical User Interface
3 (GUI) Command Line
4 Interface (CLI)
Comparisons on GUI and
CLI

4
Operating system (OS)

A system software
manages all of the other
application programs in a
computer
acts as an intermediary between
programs and the computer
hardware
applications interact with operating
system by application program
interface (API)
users interact with operating system
through user interface, such as CLI
or GUI
5
Graphical User Interface (GUI)

allows users to interact with electronic devices through


graphical icons
enhance the usability, i.e. efficiency and ease, of
use for the underlying logical design of programs

(a) Windows (b) MacOS (c) Linux


GUI GUI GUI

6
Command Line Interface (CLI)

receives commands from a user in the form of lines


of text sets parameters for the environment and
invokes executables
may be difficult for a new user to become familiar
with all the commands and options available

(d) Windows (e) MacOS (f) Linux


CLI CLI CLI

7
Comparisons on GUI and CLI

GUI CLI

Ease of Use easier to understand and use more difficult

Display of Information in various forms, such as plain in plain text form


text, images, videos, gifs
and so on
Memory Consumption more memory consumption less memory consumption

Level of Precision a lower level of precision higher precision by providing


arguments
Input both keyboard and mouse only keyboard

8
Part 2. Basic usage of system commands

9
Basic usage of system commands

1 Opening CLI
2 Concepts: path, commands and
3 arguments Basic commands usage

10
Opening CLI in Win

Method 1: search “ c m d ” i n the windows search box


Method 2: invoke the “run”window by Win+R, input
“cmd”

11
Opening CLI in Win

Method 3: Opening CLI via VS2022


Tool ->Command Line ->Developer Command
Prompt

12
Opening CLI in Mac

13
Basic Usage of commands

Windows Command Mac/Linux Command Usag


Name cd Name c Change CWDeto a new location
d List the files and folders of the target
di ls directory Compile a .cpp file
r g++ Compare files line by
cl 2 line Run the
/EHsc diff executable
1
./ copy one or multiple files to the target
FC nam directory delete files/directories
name.ex e clear the screen
e cp display the contents of a
copy rm file
del clea rename files/directories
cls r move files to the target
type cat directories
ren mv open CWD in GUI
move mv
explor ope
er n

Strictly speaking, cl is the compiler in Visual Studio 2022.


1

And g++ is the compiler that comes pre-installed with


2

MacOS/Linux. 14
Commands and arguments

Commands: a text string consists of words separated by


any number of space symbols
Command name: the first word, indicates the
operation or the executable to run
Argument(s): the rest of words, provides options
and/or inputs

15
Imagine a file explorer

The file explorer will tell you which folder you are
looking into.
And this folder is called current working
directory. The CLI prompt will also tell
this.

16
Change the current working directory

Win/Mac/Linux: cd
<path>
Change CWD to <path>

In this example, we first go to the subdirectory


CSCI1540-T2.
After CWD is set to CSCI1540-T2, we go back to the
upper-level directory.

17
How are files and folders organized?

Just like a
TREE.

18
How to locate a file or directory: absolute path

One’s absolute path is the path from the root of the


tree to it.

19
How to locate a file or directory: related path

We can travel on the file system tree to access


a file/dir from current working directory to the
target file/dir. and the path we go through is
called the related path.

20
Change the current working directory

Specifically, in Windows CLI, if we want to change the


current working directory to a directory on another partition
(e.g. partition D),
We should first type “D:” to switch to this
partition and then cd to that directory.

21
Compile a .cpp file

Windows: cl /EHsc <source file>


Please ensure that the extension of your source file must
be “.cpp”.
Mac/Linux: g++ <source file>

22
Compile a .cpp file

Windows: cl /EHsc <source file>


You may get the output “cl : The term ’cl’ is not
recognized as the name of a cmdlet. . . ”
You can start the CLI using method 3, because cl.exe is
in Visual Studio 2022.
Mac/Linux: g++ <source file>
You may find the output is “a.out”. It is an executable
file with a default name.
You can change the name of output by adding “-o <output
name>” You can specify the C++ standard version by
adding the parameter
-std=c++<version>

23
List the files and folders of the target directory
Windows: dir <path>
MacOS/Linux: ls <path>
If you don’t input the <path>, it will be defaulted
to CWD.

24
Display the contents of a text file

Win: type <file1>


Mac/Linux: cat
<file1>

25
Copy files

Win: copy <file1><file2 >


Mac/Linux: cp
<file1><file2>

26
Move files

Win: move <file1><file2 >


Mac/Linux: mv
<file1><file2>

27
Compare the contents of two files

Win: FC <file1><file2 >


Mac/Linux: diff
<file1><file2>

28
Open the current folder in CLI with a pop-up window
Win: explorer <path>
Mac/Linux: open <path>

29
Delete files or folders

Win: del <file/path>


Mac/Linux: rm <file>
Mac/Linux: rm -r
<path>
Be very careful that
deleted files will not
appear in Recycle
Bin!!!

30
Provides information about system commands

Win: help <command name>


Mac/Linux: man <command
name>

31
Clear the CLI

Win: cls
Mac/Linux:
clear

32
Autocomplete

Using the tab button.


In Windows system, it matches the first candidate
according to dictionary order
A new “ t a b ” w i l l switch the autocompletion to next
candidate

33
Wildcard character “ * ”

Matches any string of characters.


a*.txt: all .txt files whose name starts with “a”, e.g., abc.txt,
a23de.txt a.*: all files with name “a” no matter of the
extension, e.g. a.txt, a.cpp
* : all files

34
Wildcard character “ * ”

Matches any
string of
characters.
ab*.txt : all .txt
files whose name
starts with
“ab”
del command
to delete files

35
Part 3. Introduction of UTM

Visual Studio cannot directly installed on Mac.


For Mac user, you need to:
• First, install a Windows virtual machine on your Mac
• Then, install the Visual Studio on the Windows virtual machine

36
Installation

1. Download from: https://mac.getutm.app/

37
Installation

2. Open UTM
• Open the download file (UTM.dmg),
and move it to “Applications”
• Open the “UTM” app

38
Installation

3. Click: “Create a New Virtual Machine”

39
Installation

4. Click: “Virtualize” and Choose “Windows”

40
Installation

5. Click: “Fetch latest Windows installer”


• Redirect to App store
• Click “Get” to download ”CrystalFetch ISO Downloader” APP
• After it installed, open it

41
Installation
6.
Choose
“Version” and
“Architecture”
.

Click
“Download”

42
Installation
6.
Waiting download.

After downloaded,
choose a destination
where you want to
save it.

43
Installation
7. Load the download “.iso” file in UTM.
• Click “Browse”
• Choose the downloaded “.iso” file
• Click “Continue”

2
1

3
44
Installation
7. Allocate the memory and CPU cores.
• Click “Continue”

45
Installation
8. Allocate the Storage.
• Click “Continue”

46
Installation
8. Set the Shared Directory (optional).
• Click “Continue”

47
Installation
9. Verify the Summary
• Click “Save”

48
Installation
10. Start the Virtual Machine
• Click the play button

49
Installation
10. Start the Virtual Machine
• Press any key to start the
windows
• Set the language,
location and keyboard,
then click “Next”

50
Installation
10. Start the Virtual Machine
• Choose “I don’t have a product key”, then click “Next”

51
Installation
10. Start the Virtual Machine
• Choose “Windows 11 Pro”,
then click “Next”
• Choose “Accept”, then click
“Next”

52
Installation
10. Start the Virtual Machine
• Choose “Drive 0”, then click
“Next’
• Wait installing

53
Installation
11. Setup Windows
• Set country
• Set keyboard
• Set account name & passward

54
Installation
11. Setup Windows
• Waiting

• Windows is opened

55
Installation
12. Proceed with UTM Setup
• Click “Next”
• Click “I Agree”
• Wait installing
1

2
56
Installation
12. Proceed with UTM Setup
• Click “Confirm” • Click “OK”

57
Installation
13. Restart the Virtual Machine
• After click “OK” in the last step, you may encounter your VM to be
unresponsive.
• If so, turn off your virtual machine

58
Installation
13. Restart the Virtual Machine
• power it on again after clearing
• Waiting re-start

59
Installation
14. Now, you can download and install Visual Studio on the Windows
Virtual Machine.

60
Thanks for your
attending.

Yuxuan Bian
[email protected]
Ho Sin-hang Engineering Building (SHB)
1026 17 Fri 9:30-11:30

61

You might also like