I haven't used a Yun before, but here is my understanding.
The Yun is really 2 separate computers with a bidirectional serial port between them.
The output pins are on the Arduino side. If you want to control Arduino pins from the LINUX side, you need to come up with a simple command syntax for communicating between the 2 computers and write code on both sides that supports that command syntax.
Say the command is:
Where x is the pin number, and n is a value, 0 or 1. (for digital pins). For a PWM output pin you could use a command analogPin and values of n from 0 to 255:
On the LINUX side you'd just send that command through the serial port to the Arduino.
On the Arduino side, you'd write a loop that would wait for data to come into the serial port from the LINUX chip. If it gets data, it would read it into a buffer until it saw a semicolon.
Then it would break the data into separate lines using the semicolon as a delimiter, search for "digitalPin" or "analogPin", parse the data between the command and the semicolon for the values, and issue the digitalWrite or analogWrite command using those values.