femindharamshi10
Posts: 102
Joined: Thu Jan 07, 2016 1:28 pm

Default commands

Sat Jan 09, 2016 1:22 pm

Hello,
i want to run some command whenever my raspberry pi is powered u (boots).
I am totally new and dont know any technical terms etc or any methods..
can you tell step by step what all i need to do if the following random commands are the commands that i want to run whenever my pi boots up :

Code: Select all

sudo chown 777 /media/HDD/RD

Code: Select all

sudo chgrp debian-transmission /media/HDD/RD
these codes are just for example... the codes that i want to put, i dont know them yet.. but will figure out soon if i find a way to do what i want to do... please help me !

User avatar
Laurens-wuyts
Posts: 716
Joined: Wed Aug 21, 2013 7:35 pm
Location: Belgium
Contact: Website

Re: Default commands

Sat Jan 09, 2016 1:48 pm

Just add your codes to: /etc/rc.local just before the 'exit' line.

Laurens

JMK8
Posts: 42
Joined: Tue Apr 28, 2015 10:00 am

Re: Default commands

Sat Jan 09, 2016 2:27 pm

...alternatively create a script file in your /home/pi directory with all the commands you want to execute at boot time (make it executable), then create a crontab entry (crontab -e)...

@reboot /home/pi/your-script-filename

I normally do it this way to avoid editing/messing with "system" files and to keep everything in one place.

JohnK

femindharamshi10
Posts: 102
Joined: Thu Jan 07, 2016 1:28 pm

Re: Default commands

Sun Jan 10, 2016 4:38 am

JMK8 wrote:...alternatively create a script file in your /home/pi directory with all the commands you want to execute at boot time (make it executable), then create a crontab entry (crontab -e)...

@reboot /home/pi/your-script-filename

I normally do it this way to avoid editing/messing with "system" files and to keep everything in one place.

JohnK
I dont know to create scripts nor do i know to make them executable.. can you please elaborate.. thank you so much for your help. (what is a crontab entry)

JMK8
Posts: 42
Joined: Tue Apr 28, 2015 10:00 am

Re: Default commands

Sun Jan 10, 2016 11:15 am

Fire up your Pi.
If you boot to the desktop open a terminal window, if you boot to the console do nothing.
Type "nano my-startup-commands" (do not enter the quotes, here or in rest of this...)
Type in the commands you want to run at boot time (don't forget "sudo" if that command needs it).
When done enter "CTL-o" (control key and lowercase o) and hit the return key.
Enter "CTL-x" (control key and lower case x).
Enter "chmod +x my-startup-commands", hit return.
Test your commands by entering "./my-startup-commands" and correct any errors by re editing with nano.
Enter "crontab -e".
Type in "@reboot /home/pi/my-startup-commands" at the end of all the text you will see.
Enter "CTL-o" (control key and lowercase o) and hit the return key.
Enter "CTL-x" (control key and lower case x).
Reboot your Pi, it should execute your commands at boot-up

If this is all too complicated for you I suggest you need to look for a good beginners guide or HOWTO to Linux.

Best of luck. JohnK.

femindharamshi10
Posts: 102
Joined: Thu Jan 07, 2016 1:28 pm

Re: Default commands

Tue Jan 12, 2016 2:45 am

JMK8 wrote:Fire up your Pi.
If you boot to the desktop open a terminal window, if you boot to the console do nothing.
Type "nano my-startup-commands" (do not enter the quotes, here or in rest of this...)
Type in the commands you want to run at boot time (don't forget "sudo" if that command needs it).
When done enter "CTL-o" (control key and lowercase o) and hit the return key.
Enter "CTL-x" (control key and lower case x).
Enter "chmod +x my-startup-commands", hit return.
Test your commands by entering "./my-startup-commands" and correct any errors by re editing with nano.
Enter "crontab -e".
Type in "@reboot /home/pi/my-startup-commands" at the end of all the text you will see.
Enter "CTL-o" (control key and lowercase o) and hit the return key.
Enter "CTL-x" (control key and lower case x).
Reboot your Pi, it should execute your commands at boot-up

If this is all too complicated for you I suggest you need to look for a good beginners guide or HOWTO to Linux.

Best of luck. JohnK.
No it dint work... it gives error -bash: my-setup-commands : no such file or directory

Image
https://drive.google.com/file/d/0BycF1S ... sp=sharing

the above link has a screenshot of the error
Attachments
error screensshot.jpg
error screensshot.jpg (30.77 KiB) Viewed 1072 times

QuietZone
Posts: 89
Joined: Sat Dec 05, 2015 7:13 pm

Re: Default commands

Tue Jan 12, 2016 3:25 am

Well, you see, "startup" and "setup" are different words.

You must pick one or the other and stick with it.
"If you haven't got anything nice to say about anybody come sit next to me." — Alice Roosevelt Longworth

femindharamshi10
Posts: 102
Joined: Thu Jan 07, 2016 1:28 pm

Re: Default commands

Tue Jan 12, 2016 5:59 am

QuietZone wrote:Well, you see, "startup" and "setup" are different words.

You must pick one or the other and stick with it.
ohhh yea... i dint seee... sooo sorry

Return to “General discussion”