Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In the linux kernel is there a file that I can start to add my code, ex. load libraries?

thanks

share|improve this question

closed as not a real question by Gilles, Ulrich Dangel, uther, Chris Down, Michael Mrozek Jul 3 '12 at 4:46

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

6  
You can't load (ordinary) libraries in the kernel. You can load modules (and how you write those is well documented on the web). Where you add custom code depends on what you're trying to do... –  Mat Jul 1 '12 at 18:15
    
@Mat I wanted to take the kernel and when it finishes loading, load the MP3 Codec and play a song. –  Coder404 Jul 2 '12 at 4:37
    
Why do you need to do that in kernel space? Just make an init script that calls mpg321, mplayer etc... to play your audio file. –  Renan Jul 2 '12 at 17:20
    
have you entered the kernel? how is it? –  Xsi Nov 23 '12 at 16:42
add comment

2 Answers

up vote 4 down vote accepted

If you're trying to accomplish a user-space task by directly modifying the operating system's kernel, you're doing something wrong 99.999% of the times.

For cases where a direct interaction with kernel's subsystems and data structures is required, people invented the loadable kernel modules.

I think you have a misunderstood the terms kernel and shell.

To answer your question: in order to play an mp3 file at system startup, you should probably get mpg123 or some other command-line music player, and launch it via an init script, after your sound system is initialized, as Mat already pointed out in an earlier comment.

For more information on init scripts usage, refer to your distribution's documentation and man-pages.

share|improve this answer
add comment

In response to your reply to Mat, I doubt that would have anything to do with a kernel library or module; therefore, I would leave the kernel as is.

Depending on what desktop environment you are using, you can set up a program to execute after everything is loaded. I assume you have the mp3 codec on your machine. So for example, in KDE, you can access 'System Settings' and under the 'System Administration' heading, you can click on 'Task Scheduler' and set up a program to run at as a personal cron or a system cron.

Of course, I don't know exactly what you are trying to accomplish here based on what you have asked. But I think the task schedule will accomplish what you want.

share|improve this answer
2  
Or use an init script to start an mp3 player as soon as the sound setup is done (that should be relatively easy with something like mpd). –  Mat Jul 2 '12 at 13:47
    
@slafat01 I am trying not to make a GUI –  Coder404 Jul 2 '12 at 15:00
    
Then don't make a GUI, make an init script that runs an audio player. There's no need to mess with kernel space. –  Renan Jul 2 '12 at 17:23
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.