CSP Preliminary Round Knowledge: Linux Systems
preamble
In recent years, almost all of the first 5 multiple-choice questions in the CSP preliminary round have one or two questions related to the use of Linux systems, so as a preparation for the CSP-J/S 2024, I've organized them.
I wish you all the best in all your exams this year!
1、Commonly used file operation commands
The following file names are all csp, and the file names to be copied or modified are all rp.
functionality | command |
---|---|
New Folder | mkdir |
New Blank Document | touch |
Reproduction of documents | cp |
Copying a folder and its containing files | cp-a |
Delete Folder | rm-r |
Delete file | rm |
Modify the file name | mv |
Modify folder name | mv |
2、Commonly used directory operation commands
functionality | command |
---|---|
Changing the current file directory | cd |
Display the current working file path | pwd |
Show files and folders | ls |
3. Compilation options
$g++ -o hello
The above command compiles and stores the file name in the-o
Make a selection. If omitted, the output file defaults to If renamed to a file, the renamed file is overwritten.
And you can also use commands with multiple compilation options for flexible compilation. Example:
$g++ -g -Wall -lm -O2 -std=c++14 -o hello
The above code is also meant to be compiled into an executable, but with a few extra compilation options:
coding | functionality |
---|---|
-g | Add the gdb debugging option to generate files with debugging information |
-Wall | Turn on all warnings |
-lm | Open the math library file, the same as in cpp.#include<cmath>
|
-O2 | O2 optimization of files |
-std=c++14 | The default source for the compiled program is c++14, as this is the only default source option in NOI Linux 2.0 |
-O0 | Turn off all optimizations |