E3 Linux System Installation and Basic Usage
Install a Linux operating system
We will reuse the content from the PA lecture notes. Please install the Linux operating system according to PA0.
Obtain the ‘One Student One Chip’ framework code.
When you read the PA0 lecture notes and reach the section on obtaining the PA framework code, a prompt box will appear asking you to return to this section of the lecture notes.
First, please add an SSH key to your GitHub account. For detailed instructions, STFW. Then, use the following command to clone the framework code for 'One Student One Chip':
git clone -b master git@github.com:OSCPU/ysyx-workbench.git
Once you've cloned the repository, you can return to the corresponding section of the PA lecture notes and continue reading. However, please pay attention to the following points:
- Treat
ysyx-workbenchas the project directory referred to in the PA lecture notes — in other words, think of ics2022 in the PA lecture notes as being replaced byysyx-workbench - When changing the student number and name in
ysyx-workbench/Makefile, you can leave the student number unchanged until you have completed the preliminary. This back-and-forth may be inconvenient, but we do it intentionally because we want to manage the documentation like code. In other words, the "One Student One Chip" handout should point to the PA handout, so we minimize references to "One Student One Chip" in the PA handout and put all related content in the "One Student One Chip" handout instead. Failure to follow this principle not only makes it difficult for us to maintain the lecture notes, but also makes it difficult for people to know where to look for relevant content when reading the lecture notes.
Installing an OS is the easiest training for independent problem solving
If you are installing and using Linux for the first time, you may encounter a lot of problems. Don't worry, since Linux is used all over the world, there is a high probability that the problems you have encountered have been encountered by other people, and searching for keywords on the Internet will most likely lead you to a solution.
Adopting the right mindset and getting the most out of the exercise.
In fact, you can always get around these drills with a little ingenuity, such as
- Using someone else's VM image or a one-click install and configuration script to accomplish the tasks in this subsection in a snap.
- Finding the so-called PA guide on the Internet and happy that you don't need to study yourself.
- Getting the core code or code for previous "One Student One Chip" cohort from someone and call that study.
Some students will think, "Why can't I refer to other people's guides and codes? I know what I'm doing!" But from the training point of view, "understand" and "independent completion" is very different: do you know why the masters do this, rather than that? How many potholes have the masters stepped in, and what is the rationale behind these potholes, can you see it? You should think about what you have to lose as opposed to what you have to gain by just laying down and copying. The notion that "copying the right thing is a good thing" is a way of lowering your expectations is not in line with the values we are promoting.
In fact, if you're a beginner, these little witticisms can cause devastating damage to your training:
- You're referencing things that you shouldn't be referencing at this stage, and they become the upper boundary of your learning, because you're barely aware of what's wrong with them, which makes it almost impossible for you to do better than them.
- And it gives you the illusion that "I'm a good learner, I'm good at learning," and you don't try, and you don't know how to do it better.
- Worse, you don't get the training you need now, but in the future you'll always be faced with new problems for which there's no cheat sheet or reference code, and you won't be able to solve them.
But to be honest, the TA team has almost no effective way to prohibit people from playing smart. In fact, it's more a matter of recognizing and enforcing them from the bottom of your heart: when you find some so-called cheat sheets, you should think to yourself that "reading them will reduce the effectiveness of the training", and then you voluntarily reject their temptation and insist on completing the experiments on your own. It's similar to the way we all recognize academic integrity: you know it's wrong to cheat on an exam, and then you take it upon yourself to complete the exam independently.
Indeed, academic integrity goes far beyond not cheating on exams, and we recommend reading MIT's interpretation of academic integrity, especially Academic integrity in writing code. Here, we quote some sample statements.
- When the handout asks to "implement X", you must implement X independently without reusing any external resources.
- Sharing code and exchanging test cases are both inappropriate.
You may think these requirements are out of line, but these guidelines are ultimately designed to get you the results you want: don't forget that you're learning to improve, not delivering a program. If you stick with it, you can become a true professional.
Can I use other Linux distributions?
We don't make it mandatory to use a particular Linux distribution, so we often get questions like "will using xxx distro affect my experiments". First of all, please read the tips on distributions in PA0. Beyond that, we probably cannot give a definitive answer, because we probably haven't used it.
In fact, if you decide to use a different distribution, you should be prepared to solve new problems on your own.
Learn Basic Linux Usage
We strongly recommend MIT's Linux tools tutorial series: The Missing Semester of Your CS Education. By studying these courses, you will learn how to use Linux tools to efficiently accomplish various tasks, which will significantly boost your work efficiency.
Required Topics:
- Course overview and the shell
- Shell Tools and Scripting
- Editors (Vim)
- Data Wrangling
- Command-line Environment
- Version Control(Git)
This includes reading the lecture notes and completing the exercises. Additionally, video lectures are available on Bilibili for your reference.
Additional Linux Learning Resources
- The Art of Command Line this article summarizes many commonly used command-line tools and is worth reading.
- Linux101 written by the Linux Users' Association of the University of Science and Technology of China. You can select sections that interest you to read.
The online site Compiler Explorer is great for developing programs with a single source file, but it becomes inconvenient when developing programs with multiple source files, or when needing to coordinate multiple programs to complete more complex tasks. After installing the Linux system, we will migrate our development environment to Linux and utilize some useful tools available in Linux to aid in advanced learning of the C language, laying a foundation for setting up the development environment for subsequent tasks.
Advanced learning of C Language in Linux:
In Linux, complete exercises 0-22, 24-25, and 27-33 from Learn C the Hard Way. You need to copy the sample code into Linux to compile and run it, combining the text RTFSC to understand the sample code and complete the corresponding additional questions.
Note that, the exercises mentioned above are part of the Entrance Interview. If you get stuck on certain questions, you can STFW or ask in the Pre-Study group chat.
Although the C language topics in this tutorial are similar to those in the previous “One-stop Learning for Linux C Programming” tutorial, it also includes introductions to various tools like Makefile and Valgrind, as well as some programming concepts worth learning. These will be very helpful for everyone in future project development work and are definitely worth practicing on Linux. In fact, if your foundational knowledge of C is solid enough, you should not spend too much time reading the code; rather, if you encounter many difficulties while reading the code, you should appreciate this opportunity to help you identify gaps in your understanding.
zhr
