LilyPond is a nice piece of software not only for writing music, but also for learning music and music notation, if you follow the documentation. You can write music in plain text and LilyPond will output it in beautiful notation as PDF, PostScript, or TeX files. It is primarily a music typesetter for Linux, but it can also generate MIDI files that allow you to actually hear your compositions with the instruments you select.
Alternatively you can use Noteedit, a tool for writing and editing scores in a graphical user interface. It includes numerous features, such as specification of MIDI instruments and polyphony. Lyrics, chord markings and guitar diagrams are supported as well. Noteedit can export to various formats, including LilyPond and MIDI.
Rosegarden is another great music composition tool for Linux. In includes an advanced audio and MIDI sequencer.
MuseScore is a well designed program that will help you get started on composing and playing music in no time. It provides an easy to use graphical editor to typeset music scores. You can use the mouse or keyboard shortcuts to add and edit staffs and notes. Several templates are available. These screenshots give you an idea of the beautiful typesetting.
You can also play your compositions, either by outputting them as MIDI files, or by enabling sound during editing. The latter option requires the installation of a sound font. For download information see here.
MusE is an open source software package that functions as a feature rich digital audio workstation for Linux systems. Traditionally such devices are referred to as "sequencers", as they combine audio signals from various sources into a sequence of sound output.
The software includes functions for recording and editing audio. It has a mixer, represented in an integrated graphical user interface, that enables mixing of MIDI and audio signals. A flexible piano roll interface allows you to view several parts of a song simultaneously. A drum editor provides suitable functions for creating percussive patterns.
MusE supports LADSPA, Jack, and ALSA. LADSPA stands for Linux Audio Developer's Simple Plugin and provides a standard for packaging audio processors and effects into a plugin library that can be used from any sequencer that supports this standard. Jack is a system for routing the audio output between programs that support this standard, and ALSA, the Advanced Linux Sound Architecture, provides soundcard drivers to enable audio and MIDI functionality.
The LMMS (Linux MultiMedia Studio) software allows you to select from a wide range of instrument sounds, and compose melodies, cords, and beats using simple, intuitive editors. Multiple tracks enable you to mix sounds in flexible ways. LMMS offers a free alternative to commercial software like FL Studio. You can quickly get hang of the basic functionality by following the online tutorials (look under "Help" in the menu bar). For more information see here.