Skip to main content

Posts

Showing posts with the label Script

Howto create an autostartup script for Debian and Ubuntu systems

You can make one autostartup script for ubuntu(debian) easily, and put commands to be started up automatically at boot. Here’s what you have to do: sudo nano /etc/init.d/ local.startup You can name the new file whatever you want, but in this example i haveused local.startup . Type #!/bin/sh on the first line of the file. Now type your command(s) underneath, one after the other. Now save and close and make the file executable with sudo chmod +x /etc/init.d/local.startup Make the file to be recognized as an init script: sudo update-rc.d local.startup defaults 80 Now when you restart you will have the commands in the file auto started.

Inline Shell Script with a For Loop

Often I'm asked how to traverse a list of items in a file. You can easily go through a list of items using a for loop. Here's an example of copying selected contents of originalDir to destinationDir via the command line. #sh #for i in `cat   /home/esofthub/mylist.dat ` #do #cp -pr / originalDir /$i / destinationDir /. #echo $i done #done sh – shell cat – lists each item in the list one iteration at a time cp – the copy utility for a local workstation (plain files and directories, no symbolic links) -pr – these options preserve the permission, "p" and copies recursively, "r" echo – lists the item copied