Running a script at startup

Warning: be sure to test your startup scripts manually in a Terminal session (Ctrl-Alt-T in Easy Mode) before following either of the methods below. If your script prevents the graphical desktop from starting properly, your machine may enter an endless boot loop, requiring you to resort to using the Rescue Console.

Easy Mode
  1. Open a Terminal (Ctrl-Alt-T in Easy Mode).
  2. If /home/user/.icewm does not exist, create it. (check for it by “ls -a /home/user”; create it with “mkdir /home/user/.icewm)
  3. In that folder, create a file called startup (“touch startup”).
  4. Make it executable now, before you forget (“chmod 0755 startup”).
  5. Edit it and insert your commands, ensuring that the 1st line is ”#!/bin/sh” (“nano /home/user/.icewm/startup”)
  6. Now, make a copy of /usr/bin/startsimple.sh (“sudo cp /usr/bin/startsimple.sh /usr/bin/startsimple.sh.orig”)
  7. Open the file with nano editor in super-user mode (“sudo nano /usr/bin/startsimple.sh”)
  8. Look for the following line: ”/opt/xandros/bin/AsusLauncher &”
  9. Insert the following code just above it, then save and reboot.
   if [ -x /home/user/.icewm/startup ]; then
   #we have a start up file to execute
   /home/user/.icewm/startup &
   fi
Advanced Mode (KDE)
  1. Open a text editor as root (EX: kdesu kwrite )
  2. Write your script. Ensure that the first line of the script is: #!/bin/sh (otherwise it will be opened in the Text Editor).
  3. Save the script to /home/user/.kde/Autostart/
  4. Give the script execute permission (chmod 0755 /home/user/.kde/Autostart/example.sh)
  5. Reboot
Xubuntu 7.10
  1. Save the script to /home/YourUserName/ExampleName.sh ( the first line of the script must be #!/bin/sh )
  2. Give the script execute permission chmod 0755 /home/YourUserName/ExampleName.sh
  3. Select from your main menu: Applications –> Settings –> Autostarted Applications
    • Click Add
    • Name the application e.g.: Example Script
    • Describe the application e.g.: This is my example script, that makes an example of every user on bootup!
    • Command: enter the path to the script: i.e.: /home/YourUserName/ExampleName.sh (Or use the button for the file chooser to find the script.)
    • Click OK
    • Make sure that the new entry in the Autostarted Applications dialog is checked.
    • Click Close
  4. Reboot
Ubuntu 7.10
  1. Save the script to /home/YourUserName/ExampleName.sh ( the first line of the script must be #!/bin/sh )
  2. Give the script execute permission chmod 0755 /home/YourUserName/ExampleName.sh
  3. Select from your main menu: System –> Preferences –> Sessions
    • Select Startup Programs tab if it is not already selected.
    • Click New
    • Name the application e.g.: Example Script
    • Command: enter the path to the script: i.e.: /home/YourUserName/ExampleName.sh (Or use the Browse… button for the file chooser to find the script.)
    • Click OK
    • Make sure that the new entry in the Startup Programs tab of the Sessions dialog is checked.
    • Click Close
  4. Reboot
Xubuntu / Ubuntu 7.10 (ALL USERS)
  1. As root, save the script to /etc/ExampleName.sh ( the first line of the script must be #!/bin/sh )
  2. Still as root, give the script execute permission chmod 0755 /etc/ExampleName.sh
  3. Edit /etc/rc.local (again, as root) and add the full path to your script above the exit 0 line (place a nice comment above the edit, explaining the command to your older self – any line that starts with a # is a comment)
   # This is my example script, that makes an example of every user on bootup!
   /etc/ExampleName.sh
   exit 0

All users, not just the current user, will be affected by the script.

- If your script requires X, you can add the lines of the script to the bottom of the /etc/gdm/Init/Default script, right before 'exit 0'. Or call it from the Default script. This is the way to add xmodmap changes to all users.