Ubuntu: How do I autorun terminal commands at startup in Lubuntu 14.04 LiveCD?


I'm doing some remastering of Lubuntu 14.04 LiveCD, and need to run the following command at startup:

/sbin/ifconfig eth0 netmask  

First, I tried modifying rc.local as follows:

#!/bin/sh -e  #  # rc.local    /sbin/ifconfig eth0 netmask    exit 0  

Execution bit was set via:

chmod +x /etc/rc.local  

That didn't work, so I tried writing this bash script (which I set to executable) and placing it in /usr/bin/

#!/bin/bash  /sbin/ifconfig eth0 netmask  

In conjunction with the above action, I modified rc.local thus:

#!/bin/sh -e  #  # rc.local    /usr/bin/myscript    exit 0  

Didn't work. Keeping the bash script in /usr/bin/, I edited /etc/xdg/lxsession/Lubuntu/autostart with this line:


This, too, failed to produce the desired result. Have I made a mistake with something I've tried, or is there something else I should be doing?


I've been unable to figure out how to utilize the casper parameters mentioned in Elder Greek's answer. Any further help on that front would be greatly appreciated.

The comments in the link he/she posted turned out to be helpful, though. One commenter pointed out that the bash script located at /usr/share/initramfs-tools/scripts/casper-bottom/23networking can be edited to assign a static ip to eth0.

The commenter also mentions editing the /etc/network/interfaces file, which is what I did. It works, but at a price: a lengthy delay at bootup while waiting on the network to configure. Here are the relevant bits:


auto eth0  iface eth0 inet static  address 10.xxx.xxx.xxx  netmask  gateway 10.xxx.xxx.xxx  


default live  label live      say Booting an Ubuntu Live session...      kernel /casper/vmlinuz      append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash ip=frommedia --  

In my experience, what normally happens is that, regardless of what changes you make to the network/interfaces file, when the LiveCD boots, it's forced to a default state by the 23networking bash script I mentioned prior. The ip=frommedia edit at the end of isolinux.cfg forces the script to use whatever is present in the network/interfaces file.

As the commenter mentioned, the 23networking script can be edited to set a static ip. If anyone can help me with that (not so good with bash scripting), that would be great.


If I attempt to run /sbin/ifconfig eth0 netmask manually I get SIOCSIFADDR: Operation not permitted

SIOCSIFFLAGS: Operation not permitted

SIOCSIFNETMASK: Operation not permitted

Following the logic of that, I attempted

sudo /sbin/ifconfig eth0 netmask

Which completed without error. It would seem that you need super user powers for this to succeed.

You may find this documentation useful: https://help.ubuntu.com/community/LiveCDCustomization

Further research on the link above indicates that there is a casper parameter which is in the form:


I found this by googling Ubuntu Live CD custom static ip

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »