I'm running Kali Linux 2018.1 on a VM. I want to run a bunch of commands that I have stored in the file start.sh at startup. I know how to do this on a normal distro by going into /etc/rc.local, but that doesn't exist in Kali.

Here are some of the commands I want to run.

apt-get clean && apt-get update && apt-get upgrade -y
/etc/init.d/nessusd start

Any suggestions?

  • 5
    Guys (and girls), not every question which mentions kali needs to be closed as a duplicate of that "kali - why won't people help me". This question is well defined, answerable, can help other people, and really isn't even kali specific. – Patrick Apr 20 '18 at 2:33
  • I cant decide wether I prefer the method here. unix.stackexchange.com/questions/263331/… – Rui F Ribeiro Apr 20 '18 at 10:35

You can add this script to /etc/crontab:

@reboot /path/to/your/start.sh

From man 5 crontab:

@reboot    :    Run once after reboot.
  • I'm in the file /etc/crontab. Do I add "@reboot/path/start.sh" to the end of the file and then add "@reboot : Run once after reboot" after that? – rockower Apr 20 '18 at 0:19
  • Yes, add script in format that I've written. – Yurij Goncharuk Apr 20 '18 at 0:24
  • 1
    @rockower You need to preserve the spacing in the answer when editing /etc/crontab. Also, the second code block is a quote from a man page for easy reference, so don't add that to your crontab. – dsstorefile1 Apr 20 '18 at 0:24
  • 2
    This is great-- I personally never knew crontab had support for scheduled tasks on reboot. – EDubman Apr 20 '18 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.