Do I need to know how to program in C to work with Linux From Scratch?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Do I need to know how to program in C to work with Linux From Scratch?
Hello, how are you?
I have this little dream/ambition to create my own Linux Distro. I do know how to work with Shell Scripting (Bash), but I have never touched a single line of C. Also, if it's not too much trouble, do you have any tips on how to get started with this challenging task?
I have searched everywhere for the answer to my question, but I have not been very successful. In advance, a thousand apologies if this is a silly question or if this is the wrong place to ask; I am new to this forum.
Thank you in advance, my friends. I wish you all the best!
I played with LFS a few years ago, and, based on my experience, no (I learned a lot, also). You do need (or will quickly acquire) familiarity with the command line, but you don't need to be a coder.
I have this little dream/ambition to create my own Linux Distro.
The very first thing you need to do is to specify this distro. What do you want to achieve exactly? And probably you need to look around if that was already made by somebody.
Quote:
Originally Posted by Carmazum
I do know how to work with Shell Scripting (Bash), but I have never touched a single line of C. Also, if it's not too much trouble, do you have any tips on how to get started with this challenging task?
To create a full distro you need to know how can you build it, release it, how will you update it, how will you apply vulnerability fixes (just to name a few). How do you want to manage the installed/available packages, what hardware will be supported .....
I guess shell scripting is quite useful, but not enough for this task.
No, you don't need to know anything about C. But you do need to know some other things. I would suggest the following as basic requirements:
1) You must be comfortable using the command line.
2) You must understand bash shell constructs such as loops and conditions, and know what common Unix utilities such as grep and echo do, because you will be using them a lot.
3) You must be comfortable with copying, renaming and moving files using commands.
4) You need to understand some basic file concepts such as ownership and permissions, and symbolic links.
5) You need to understand the basic steps in building software (configure, make, make install) and what each step does. You don't need to understand how each stage works internally. The LFS Book has an excellent general chapter on this.
You can build LFS without knowing any of this, simply by blindly obeying the instructions. But you will not learn anything by doing it that way and it won't be much fun either.
It wouldn't hurt to run through a hello world tutorial in C: it's just as easy as bash, except you run it through a compiler at the end, creating a binary.
When you use other people's c code (why reinvent the wheel), their code is referenced with an "include" command in your script, and their code is stored in an "include directory". As you navigate the linux file system, you notice directories called include, and with just a minimal tadge of c programming, with just a hello world tutorial under your belt, those include directories won't seem like foreign places in the file-system to leave alone, but rather they'll be familiar: oh, that's the directory where the c-programmers store their header files that they reference with includes...
There are other files and directories lurking about within the linux file system that are all part of the C ecosystem. I would link to a hello world tutorial for you, except a book at a shop caught my eye: "Just enough C and C++ Programming", and I went through the tutorial in that book. But I reckon any linux based C tutorial would do, and it's well worth a few hours to not feel like a foreigner when navigating your operating system: especially if you plan on rebuilding it.
Last edited by slac-in-the-box; 03-07-2022 at 10:07 AM.
Reason: changed "I" to "eye" :)
C is worth learning for its own sake. It's a very powerful language and intimately connected with Linux. The Linux kernel, the GNU utilities and the GNU C compiler are all written in it. But the original question was do you need to understand C in order to do Linux From Scratch and I don't think you do.
Basically what hazel said, though:
2) I do understand loops but not much the case statements, and
5) I learned that from building LFS
And I know my way around file systems and partitions.
Also I am still somewhat confused with many nested brackets.
But I did manage to finish LFS. And so will you if you give it a try.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.