Wednesday, July 3, 2013
awk tips
1) Search for regular expression "test" in file "my_file" and print first and last field of matched line:
$ awk '/test/ { print $1, $NF }' my_file
2) Regular expression comparison is made by ~ or !~ which result is true or false:
3) Search for lines where first field contains "A" and print that line:
$ awk '$1 ~ /A/' my_file
#or
awk '{ if ($1 ~ /A/) print }' my_file
#where $1 ~ /A/ means "does first field contains A?"
#print is the same as print $0, thus print whole line = all fields
4) grep -v with awk:
awk \!/text/ my_file
5) filed delimiter different than default space:
gawk -F: '{ print $1 }' /etc/passwd
GNU AWK manual:
http://www.gnu.org/software/gawk/manual/gawk.html
Don't redirect Picasa to Google +
No redirect link which also adds cookie for future attempts:
https://picasaweb.google.com/lh/myphotos?noredirect=1
https://picasaweb.google.com/lh/myphotos?noredirect=1
Destroy Xen Domain (virtual host)
#list active domains:
xm list
#some domain can be in bad state - unable to start and unable to create another one with the same name, because configuration file with this name already exists
#to remove domain do these steps:
#terminate domain (remove it from xm list):
xm destroy domainID
#remove autostart link:
rm /etc/xen/auto/domainID*
#remove configuration file
rm /path/to/disk/file
#or remove physical disk or LogicalVolume
#list of all "xm" commands:
console Attach to <Domain>'s console.
create Create a domain based on <ConfigFile>.
destroy Terminate a domain immediately.
dump-core Dump core for a specific domain.
help Display this message.
list List information about all/some domains.
mem-set Set the current memory usage for a domain.
migrate Migrate a domain to another machine.
pause Pause execution of a domain.
reboot Reboot a domain.
restore Restore a domain from a saved state.
save Save a domain state to restore later.
shutdown Shutdown a domain.
trigger Send a trigger to a domain.
top Monitor a host and the domains in real time.
unpause Unpause a paused domain.
uptime Print uptime for a domain.
vcpu-set Set the number of active VCPUs for allowed forthe domain.
xm list
#some domain can be in bad state - unable to start and unable to create another one with the same name, because configuration file with this name already exists
#to remove domain do these steps:
#terminate domain (remove it from xm list):
xm destroy domainID
#remove autostart link:
rm /etc/xen/auto/domainID*
#remove configuration file
rm /path/to/disk/file
#or remove physical disk or LogicalVolume
#list of all "xm" commands:
console Attach to <Domain>'s console.
create Create a domain based on <ConfigFile>.
destroy Terminate a domain immediately.
dump-core Dump core for a specific domain.
help Display this message.
list List information about all/some domains.
mem-set Set the current memory usage for a domain.
migrate Migrate a domain to another machine.
pause Pause execution of a domain.
reboot Reboot a domain.
restore Restore a domain from a saved state.
save Save a domain state to restore later.
shutdown Shutdown a domain.
trigger Send a trigger to a domain.
top Monitor a host and the domains in real time.
unpause Unpause a paused domain.
uptime Print uptime for a domain.
vcpu-set Set the number of active VCPUs for allowed forthe domain.
Tuesday, July 2, 2013
Add watermark in batch with ImageMagic
This adds 2 colored text slightly moved side by side. Size 70 is appropriate for resolution ~2000pixels:
for i in `ls -1 IMG*.jpg`; do echo $i; convert $i -pointsize 70 -draw "gravity southeast fill black text 0,12 'Copyright' fill white text 1,11 'Copyright' " ../new/edit-$i; done
Thanks to:
http://www.imagemagick.org/Usage/annotating/#wmark_image
for i in `ls -1 IMG*.jpg`; do echo $i; convert $i -pointsize 70 -draw "gravity southeast fill black text 0,12 'Copyright' fill white text 1,11 'Copyright' " ../new/edit-$i; done
Thanks to:
http://www.imagemagick.org/Usage/annotating/#wmark_image
Monday, July 1, 2013
Change hostname to permanent on RedHat like Linux server
edit
[root@localhost ~]# grep HOSTNAME /etc/sysconfig/network
HOSTNAME=localhost.localdomain
[root@localhost ~]#
and then run:
[root@localhost ~]# hostname your_hostname
Create (install) new Xen Virtual Machine in text mode
Either you can use graphical tool virt-manger
or this text tool:
[root@localhost ~]# virt-install --prompt
What is the name of your virtual machine? test2
How much RAM should be allocated (in megabytes)? 500
What would you like to use as the disk (file path)? /home/tomas/test2
How large would you like the disk (/home/tomas/test2) to be (in gigabytes)? 4
What is the install URL? http://merlin.fit.vutbr.cz/mirrors/centos/5.9/os/i386
Starting install...
Retrieving file .treeinfo... | 413 B 00:00
Retrieving file vmlinuz... | 2.2 MB 00:01
Retrieving file initrd.img... | 11 MB 00:08
Creating storage file... | 4.0 GB 00:00
Creating domain... | 0 B 00:02
Connected to domain test2
...
also you can continue in text installation or you can start VNC server:
Welcome to CentOS
+-----------+ VNC Configuration +------------+
| |
| A password will prevent unauthorized |
| listeners connecting and monitoring your |
| installation progress. Please enter a |
| password to be used for the installation |
| |
| Password: ********________ |
| Password (confirm): ********________ |
| |
| |
| +----+ +-------------+ +------+ |
| | OK | | No password | | Back | |
| +----+ +-------------+ +------+ |
| |
| |
+--------------------------------------------+
Probing for video card: Unable to probe
No video hardware found, assuming headless
Starting VNC...
The VNC server is now running.
Please connect to 172.16.79.130:1 to begin the install...
Press <enter> for a shell
Starting graphical installation...
XKB extension not present on :1
and continue in graphical mode with "vncviewer" command.
Sunday, June 30, 2013
Xen server inside VMWare host and problem with promisc mode of network card
Running Xen server inside VMWare host (with xen kernel) can cause problem with switching network card into Promiscuous Mode and thus can lead into network card not operational state.
Here is a simple solution of this security problem:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=287
Here is a simple solution of this security problem:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=287
Subscribe to:
Posts (Atom)