Category Archives: Operating System

Solaris Notes

Extracting a solaris package without installing it. #http://serverfault.com/questions/287469/extract-files-out-of-solaris-pkg-file-without-installing pkgtrans filename.pkg /home/user/temporary_package_prefix

Posted in Operating System | Leave a comment

Find with xargs

Search all files under current directory, look for xml node ‘‘, copy and print that node. Send the output to a file. find . |xargs -n1 xmlstarlet sel -t -c “//processorInfo[@ruleType=’store’]” 2>/dev/null > /cygdrive/b/allstore.txt

Posted in Linux | Leave a comment

XMLStartlet – Command line xml queries

xmlstarlet sel -t -c “//YOUR_NODE_ELEMENT_TAG_NAME[@ATTRIBUTE_NAME=’ATTRIBUTE_VALUE’]” YOUR_XML_FILE.xml

Posted in Linux | Leave a comment

Bash Scripting templates

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859# ========================== # Bash tips # ========================== # Run bash by $ /bin/bash scriptname.sh $ /bin/bash scriptname.sh +x  # debug mode # Or put the next line on the 1st line of your file. #!/bin/bash -x ## Double round braket … Continue reading

Posted in Linux | Leave a comment

Enabling SSH (https) for Apache 2 in Ubuntu/Mint/Possibly other Debian distro

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051# Intall apache $ sudo apt-get install apache2   # Enable SSL module $ sudo a2enmod ssl # Restart Apache $ sudo service apache2 restart # Create a directory to store the SSLCertificateFile and SSLCertificateKeyFile $ mkdir  /etc/apache2/ssl # Generate … Continue reading

Posted in Linux, Ubuntu, Web Development | Leave a comment

Directory sharing between Linux and Windows

1. Sharing/serving a Linux directory to Windows $ sudo apt-get install samba $ sudo smbpasswd -a USERNAME $ mkdir /home/USERNAME/sharedfolder $ sudo vi /etc/samba/smb.conf [sharedfolder] path = /home/USERNAME/sharedfolder available = yes valid users = USERNAME read only = no browsable … Continue reading

Posted in Linux, Operating System, Windows 7 | Leave a comment

Choosing the default network card (NIC) that should access the Internet

In the presense of multiple network adapters, it is sometimes necessary to manually specify which one is the default used for internet routing, for example. To accomplish this, you have to manually add a “metric” to each interface. Windows will … Continue reading

Posted in Operating System, Windows 7 | Leave a comment

Getting the current filename using bash

123456789101112131415$ cat ./testfilename.sh #!/bin/bash fullfile=`basename $0` filename=$(basename "$fullfile") echo "filename:"$filename extension="${filename##*.}" echo "extension:"$extension justfilename="${filename%.*}" echo "justfilename:"$justfilename $ ./testfilename.sh filename:testfilename.sh extension:sh justfilename:testfilename

Posted in Linux, Operating System | Leave a comment

Customize your Vim editor using .vimrc

Quick notes: – imap is for when you are in insert mode – map is when your are in command mode Thus when you are in the insert mode, sometime you need to exit to the command mode first using … Continue reading

Posted in Linux | Leave a comment

Search and replace withing a file

1234567sed -i -e"s/SEARCH_TEXT/REPPLACE_TEXT/g" FILENAME.txt # another example using bakup sed -i.bak -e"s/SEARCH_TEXT/REPPLACE_TEXT/g" FILENAME.txt # another example using variable sed -i -e"s/\/pathname/\/pathname-$date/g" "filename-"$date".xml"

Posted in Bash, Linux, Operating System | Leave a comment