Ubuntu Linux: How to execute a command on boot before/without login
Just add the command(s) you want in the file
/etc/init.d/rc.local
Make sure that they do not block or cause errors 🙂
Just add the command(s) you want in the file
/etc/init.d/rc.local
Make sure that they do not block or cause errors 🙂
Lets say you have a ton of pictures or photos that you want to resize and add a semi-transparent label at the bottom of this bulk of files and even rename them using a pattern based on a unique number.
You can either do this manually or by using imagemagick. If you chose the second way follow these steps:
First of all install it, from bash/terminal call the following:
sudo apt-get install imagemagick
When that command is successfully completed, navigate to the location that the pictures are and once you are there:
In order to resize all pictures then issue the following command (in this example we make all pictures at most 1200px long or 1200px tall and keep the aspect ratio) :
mogrify -resize 1200 *
NOTE: It will affect the original files! So if you want to keep them make sure to copy them elsewhere BEFORE issuing the above command.
After the above is done, you can issue the following set of commands to:
counter=0; for i in *; do let counter=counter+1; width=`identify -format %w "$i"`; convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:" Some Arbitrary Text " "$i" +swap -gravity south -composite NewFileName.`printf %03d $counter`.jpeg; done
This command will preserve the original files.
All together with printing the file that is being processed as debuging information:
mogrify -resize 1200 *; counter=0; for i in *; do let counter=counter+1; echo $i; width=`identify -format %w "$i"`; convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:" Some Arbitrary Text " "$i" +swap -gravity south -composite NewFileName.`printf %03d $counter`.jpeg; done
Sample/Result Photos:
So you’ve set up KVM on your machine and you have installed a few guests to run on top, now it’s the time to access them.
Since KVM can run without a GUI, you might want to control these guests from the command line. But, how can you do it if you do not know the IP of the guests?
You can either connect to the guest using virt-viewer:
virt-viewer -c qemu:///system $MACHINE &
which requires more bandwidth since it will open up a VNC session.
Or, use ssh to connect using the guest’s name, like this:
ssh $MACHINE
which doesn’t require that you know the IP beforehand.
To achieve this, access guest machines using their hostname only, you can do the following: Edit /etc/resolv.conf and add the line nameserver 192.168.122.1 right after the search entries .
Your file should look something like this afterwards:
domain in.bytefreaks.net
search in.bytefreaks.net
nameserver 192.168.122.1
nameserver 194.44.13.20
nameserver 194.44.13.58
nameserver 194.44.13.11
Then you are ready to go! No restarts needed no extra steps.
NOTES:
sudo apt-get install openssh-server