2020 PD1
Environment tutorial
CSIE 梁祐承
GUI environment
for non-CSIE students
Download MinGW / CLion
- If you're using Windows PC
- If you're using Mac
MinGW install
CLion install
CLion activate
- CLion is not free software, you need license to use it
- We provide 200 licenses
- If concurrent users exceeded, you'll get kicked out
- You can also apply for your student license for free
- Please see Moodle for license server address
Toolchain settings
If you installed MinGW, CLion will detect your compiler by default
Write your
first program
New project
Hello, World!
CLI environment
for CSIE students
Linux
- An open-source OS kernel
- There are many distributions
- Debian / Ubuntu
- Fedora / Centos
- Arch linux / Gentoo
- Widely used in servers
- Many distros provide GUI, but it's better to get familiar with command line interface (CLI).
GUI
Graphics user interface
Easy to use, more restrictions
CLI
Command line interface
Hard to use, more powerful
How to get linux environment?
- Install into your disk (best choice but not recommend)
- Use SSH to access linux server
- Use WSL (Windows Subsystem for Linux)
- Need Windows 10 version 1607 or later
- Install guide (WSL 1 is enough)
- MacOS is also an Unix-like OS, so you don't need to install linux if you use Mac (Install XCode instead)
WSL install
Run this command in Windows PowerShell first
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Reboot your computer
- Install Ubuntu 20.04 from Microsoft store
- Start WSL from start menu, wait for automatic install
- Set your username & password
(Password is not visible when typing, just type it & enter)
hint: you can access windows disks in WSL, mouted under /mnt/
Basic linux command
command | meaning | description |
---|---|---|
ls | list | list files in directory |
pwd | print working directory | print current working directory |
cd | change directory | move to another directory |
mv | move | move a file / rename a file |
cp | copy | copy a file |
rm | remove | remove a file |
mkdir | make directory | make an empty directory |
apt | package manager to install new program |
Try some!
# Install necessary software by apt (type your password when asked)
sudo apt update
sudo apt install gcc g++ make cmake vim build-essential -y
# Check where am I
pwd
# See what is in this directory
ls
# make a new directory named "hello"
mkdir hello
# go into new directory
cd hello
# check you're now in hello
pwd
# create an empty file named "test"
touch test
# check "test" exists
ls
# remove it
rm test
vim tutorial
Vim is a command-line text editor, useful when doing server management (you'll need to edit many config files without GUI)
There are many plugins can make vim more friendly, feel free to discover it by yourself (We'll teach you basic operations in this course)
Basic vim command
command | description |
---|---|
vim <file> (in shell) | Edit "filename" file with vim |
i | Go into insert mode to type |
ESC | Go into normal mode to run command |
:w | save (write) |
:q | quit |
:wq | save & quit |
:q! | quit without save |
u | undo |
ctrl + r | redo |
You can download this file into your $HOME as basic config
Write your
first program
-
Edit code with vim
-
compile with gcc
-
Run!
#include <stdio.h>
int main()
{
printf("Hello, Happy World!\n");
return 0;
}
Notice
- When you have questions, use TAs' common email <pd1@imslab.org>, NOT TA's PRIVATE MAIL!!
- Search in English & don't use machine-translated mirror sites!
- Be care of translation difference
- Good reference sites such as
- stackoverflow.com
- 鳥哥的 Linux 私房菜
2020 PD1
By Liang Yu-Cheng
2020 PD1
- 2,152