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


  • 7
    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
    Commented Jul 1, 2012 at 18:15
  • @Mat I wanted to take the kernel and when it finishes loading, load the MP3 Codec and play a song.
    – Coder404
    Commented Jul 2, 2012 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
    Commented Jul 2, 2012 at 17:20
  • have you entered the kernel? how is it?
    – Xsi
    Commented Nov 23, 2012 at 16:42

2 Answers 2


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.


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.

  • 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
    Commented Jul 2, 2012 at 13:47
  • @slafat01 I am trying not to make a GUI
    – Coder404
    Commented Jul 2, 2012 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
    Commented Jul 2, 2012 at 17:23

Not the answer you're looking for? Browse other questions tagged .