Introduction to Linux, Pico, G++
-
Upload
michael-gordon -
Category
Technology
-
view
364 -
download
0
description
Transcript of Introduction to Linux, Pico, G++
![Page 1: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/1.jpg)
CS111 Lab Linux etc.
Instructor: Michael Gordon
![Page 2: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/2.jpg)
Linux
We will be using the Linux OS, which
may be different from the operating
systems you have used before
(Windows, Mac OS).
There is no GUI or mouse-interface.
Commands are typed at the prompt.
![Page 3: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/3.jpg)
Linux commands
Create a directory (folder): mkdir
[prompt] mkdir mydir
Change current directory: cd
[prompt] cd mydir
[prompt mydir]
Go up one directory: cd .. (note space)
[prompt mydir] cd ..
[prompt]
![Page 4: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/4.jpg)
Commands, continued
Remove a directory (folder): rmdir
[prompt] rmdir mydir
List files/sub-directories: ls (letter ‘l’)
[prompt] ls
List with details: ls -l
[prompt mydir] ls –l
![Page 5: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/5.jpg)
Commands, continued
Copy a file: cp
[prompt] cp origfile newfile
Rename a file: mv
[prompt] mv origfile newfile
Remove a file: rm
[prompt mydir] rm origfile
![Page 6: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/6.jpg)
Pico
Pico is a text editor for Unix. In this lab we
will use it to write our C++ code.
To open or create a file in pico:
[prompt] pico filename.cpp
To save: Control+o (letter ‘o’) prompts you
to overwrite. ‘Enter’ for ‘Yes’. Or change
the file name.
To exit pico: Control+x
![Page 7: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/7.jpg)
In Pico
In Pico we will write our C++ code.
Note: You must move your cursor with the
arrows keys, not the mouse.
To ‘cut’ a line of code, use Control+k
To ‘paste’ use Control+u
![Page 8: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/8.jpg)
Compiling
Once you’ve written a C++ program, you
need to compile it (translate it into
machine code) before running it.
We use a compiler called g++.
[prompt] g++ file.cpp
An executable file is automatically
created (or overwritten) with the name
a.out.
![Page 9: Introduction to Linux, Pico, G++](https://reader035.fdocuments.net/reader035/viewer/2022081816/54bee7514a795991698b45f7/html5/thumbnails/9.jpg)
Executing
To run the executable file, type:
[prompt] ./a.out
To give a name to your .out file:
[prompt] g++ -o name.out file.cpp
To run:
[prompt] ./name.out