Original Post: https://www.coderscat.com/how-to-learn-linux
I still remember the days when I started using Linux with Ubuntu 4.04 in 2004, students apply for installation CD on Ubuntu’s website, then we will receive a package which contains CD in several days later.
How nice! Since then, I spend most of the programming time on the Linux platform and learned much from Linux and the community. I must say, with learning Linux, I become a better programmer.
I always suggest beginner start with Linux when learning to program. But how to learn it, what exactly do we want to learn? This is a guide for the beginner to learn Linux from scratch.
Maybe you have heard that Linux is cooler tools for hackers, or that Linux is more developer-friendly. In my opinion, there are three key reasons for learning Linux.
- The first truth is: Linux has dominated the server market, most computing servers are run Linux. As a developer, especially for Web development, you need to write code run on Linux, deploy code on Linux, and you maybe need to maintain a Linux server.
- Learn system programming API and low-level programming. With the trend of IoT, there is more software involving low-level programming, coding with standard C/C++ is a requirement for this kind of task. This kind of development usually needs proficient skills with Linux.
- Learn system fundamentals and internals. Linux is an open-source project, maintained by thousands of developers around the world. There are many good books and resources about Linux internals, which will help you much with the learning operation system.
Different target should follow different learning path, we could roughly divide the target into several levels:
- Daily usage
- Application development on Linux, operation, and maintenance
- System development
- Kernel development
You should learn according to this path, every previous step is a precondition to the next. If you don’t know how to use Linux as a daily OS, you can not use it as a development OS, and of course, dig into internals will be much harder.
Find Linus’s book: Just for Fun: The Story of an Accidental Revolutionary, let’s begin the funny journey.
Daily usage includes:
How to login and logout How to connect to the Internet How to open the command line How to install uninstall software using the command line How to edit text How to create, move, delete files How to view the contents of a file and extract the file ......
The hardest part of this stage is the transition from the graphical interface to the command line. My suggestion is like learning swimming, try to throw yourself into the water, you will never learn how to swim if you don’t get into the water.
So, please just try to install a Linux distribution on your PC.
You can install multiple operating systems on a PC. Don’t even try to use Linux on virtual machines, this will give you a chance to hold back from daily usage on Linux.
Which Linux distribution should be should beginner to use?
Well, there are about 10 commonly used Linux distribution, choose any one of the top 5 will be OK. Choose mainstream distributions, such as Ubuntu, Centos, etc. It is easier to solve problems when encountering problems.
There mainly differences among them are graphical interface and package management.
There is various kind of application development, including Web application, desktop GUI application, command line or application for various tasks and computing.
You maybe need to learn Web development, C/C++/Python or any other programming languages.
Developing on Linux is a different experience compared with Windows. Unlike on Windows, developers usually have an IDE for development.
Most of the time, your toolchain is a set of various little tools, and you need to run them and combine them in a shell.
You need to learn:
- How to write a code in an editor, commonly editor should be Vim/Emacs and VScode.
- How to compile or build your program
- How to launch your program from the command line
- How to locate bugs, run a program with debugger
You should learn some shell scripts programming, at least to the level that you could understand most common shell scripts. Currently, most developer prefers to use Python/Ruby to replace shell scripts, but there are still many existing scripts.
Try to set up your favorite development environment on Linux, here are some tools may be used. Remember to keep tracking of your configurations, I use Git to for configuration version control.
This stage, of course, involve much other specific domain knowledge, this depends on your choose technology and framework, for the most modern programming language, such as Ruby/Python/Rust, it will be easier to set up the environment.
If you set up your environment properly, your coding productivity will x5 than before.
This stage is a long learning process, keep patience.
If your task is to develop some low-level software, such as storage or networking application, you need to learn Linux system development.
System programming is different from most application development, system programming involving more OS or networking stuff. You need to know the details most commonly used Linux Kernel Interface. For historical and performance reasons, system development usually needs to know C/C++, system API provided in C.
are both good resources for the Linux programming interface.
Networking is another important field for system programming, Unix Network Programming will be your best choice.
This is also not an easy stage, less programmer has the ability to coding in C/C++, it’s a trend that the new generation prefers to modern and high-level programming languages, such as Rust, Python.
Remember the fundamentals are the same, the core knowledge of system programming will sharpen your skills, expand your design ability.
The requirements of Kernel’s development are relatively high. You will be a HERO after finish this. At this time, you should have studied the courses of the operating system.
The kernel contains submodules such as memory management, process scheduling, virtual memory, file system, device drivers, etc. Of course, more related commands are also necessary for development, such as readelf, nm, ipcs, iostat, objdump, free, chrt, pmap, uptime, top, pidstat, etc.
Robot Love’s Linux Kernel Development is the best introduction book for Kernel development, it will give you a good big picture of the kernel.
Another good book list for Kernel development:
Remember, because there are too many fields in Kernel development, it’s almost impossible for beginners to start all the fields. Your learning strategy should:
- Get the big picture of Linux Kernel, a good method is read Robot Love’s book, an alternative strategy is to learn the old version of Linux because of the codebase is much smaller, you could spend about 2 weeks to finish it. xv6 is another good choose, with good reading materials.
- Focus one specific submodule, choose one submodule which most interested you, and try to understand the details and design of it. Try to involve the Kernel development community, read the document, join Linux mail list, review other’s patch and try to submit your patch to Kernel. Linux Kernel community has its collaboration style, you need to learn the rules. It will be a milestone after you submitted the first patch. If you have enough knowledge and skills for one subdomain, it will be much easier to transfer to another one.
It will cost many years to be a master of Kernel programming, happy hacking and have fun.