Thursday, December 17, 2015

How to change the hostname in ubuntu without restart server

sudo vi /etc/hostname
change the existing old_hostname with new_hostname
sudo vi /etc/hosts
change the existing old_hostname with new_hostname
127.0.1.1 old_hostname -> 127.0.1.1 new_hostname
Issues following command without reset the system
sudo hostname new_hostname

Tuesday, December 1, 2015

Using curl to download file

curl http://some.url --output some.file

which --output flag denotes the filename (some.file) of the downloaded URL (http://some.url)

Thursday, November 12, 2015

Regular Expression Concept

Regular Expression concepts

A regular expression, often called a pattern, is an expression used to specify a set of strings required for a particular purpose. A simple way to specify a finite set of strings is to list its elements or members.

Boolean "or"
A vertical bar separates alternatives. For example, abc|abb can match "abc" or "abb".

Grouping
Parentheses are used to define the scope and precedence of the operators (among other uses). For example, abc|abb and ab(c|b) are equivalent patterns which both describe the set of "abc" or "abb".

Quantification
    ?     The question mark indicates zero or one occurrences of the preceding element. For example, colou?r matches both "color" and "colour".

    *     The asterisk indicates zero or more occurrences of the preceding element. For example, ab*c matches "ac", "abc", "abbc", "abbbc", and so on.

    +     The plus sign indicates one or more occurrences of the preceding element. For example, ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac".

    {n}     The preceding item is matched exactly n times.

    {min,}     The preceding item is matched min or more times.

    {min,max}     The preceding item is matched at least min times, but not more than max times.

      .      Dot Matches any single character (many applications exclude newlines, and exactly which characters are considered newlines is flavor-, character-encoding-, and platform-specific, but it is safe to assume that the line feed character is included). Within POSIX bracket expressions, the dot character matches a literal dot. For example, a.c matches "abc", etc., but [a.c] matches only "a", ".", or "c".

  [ ]  A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches "a", "b", or "c". [a-z] specifies a range which matches any lowercase letter from "a" to "z". These forms can be mixed: [abcx-z] matches "a", "b", "c", "x", "y", or "z", as does [a-cx-z].
The - character is treated as a literal character if it is the last or the first (after the ^, if present) character within the brackets: [abc-], [-abc]. Note that backslash escapes are not allowed. The ] character can be included in a bracket expression if it is the first (after the ^) character: []abc].

    [^ ]  Matches a single character that is not contained within the brackets. For example, [^abc] matches any character other than "a", "b", or "c". [^a-z] matches any single character that is not a lowercase letter from "a" to "z". Likewise, literal characters and ranges can be mixed.

     ^         Matches the starting position within the string. In line-based tools, it matches the starting position of any line.

      $        Matches the ending position of the string or the position just before a string-ending newline. In line-based tools, it matches the ending position of any line.

Tuesday, August 18, 2015

Keyboard short cut for windows stickynotes

Ctrl+U     Underlined text
Ctrl+T      StrikeThrough
Ctrl+Shift+L     Bulleted (press once) or Numbered (press twice) list
Ctrl+Shift+>     Increased text size
Ctrl+Shift+<     Decreased text size
Ctrl+A     Select all
Ctrl+Shift+A     Toggles all caps
Ctrl+L     Left aligns text
Ctrl+R     Right aligns text
Ctrl+E     Centers text
Ctrl+Shift+L     Small Alpha list (3rd), Capital Alpha list (4th), small roman (5th), Capital roman (6th)
Ctrl+Scroll Wheel     Increase/Decrease text size
Ctrl+1     Single-space lines
Ctrl+2     Double-space lines
Ctrl+5     Set 1.5-line spacing
Ctrl+=     Subscript
Ctrl+Shift++     Superscript
Ctrl+Z     Undo
Ctrl+Y     Redo
Ctrl+X     Cut
Ctrl+C     Copy
Ctrl+V     Paste
Ctrl+N     New sticky note

Monday, July 27, 2015

Open Command Prompt from windows explorer


This tutorial share out how to open command from windows explorer for windows 8, windows 7 and windows XP

  • Windows 8 
    1. Select the folder you want to open in the command prompt
    2. Go to File -> Open Command Prompt
  • Windows 7
    1. Select the folder you want to open in the command prompt
    2. Right-click on it while holding the Shift key
    3. Select Open command window here
  • Windows XP
  1. Open regedit
  2. Navigate to HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell
  3. Create a new key called Command Prompt
  4. Your default value should be Command Prompt Here
  5. Create a new key called Command under the Command Prompt key
  6. Your default value should be cmd.exe /k pushd %
Your popup menu when you right click on a folder will now contain an option called Command Prompt Here which will open a command prompt in the selected folder.

Thursday, July 2, 2015

Use ls Command to display file size unit

'ls' command to display the file size with the UNIT of KiloBytes, MegaBytes

ls -lah
 

Tuesday, June 30, 2015

Disable HyberV

HyperV may  cause incompatible for virtual box, We can disable HyperV with following command:

bcdedit /set hypervisorlaunchtype off

To Reenable it back with
 
bcdedit /set hypervisorlaunchtype auto
  And restart the system

Monday, June 29, 2015

Mount Virtual Box share folder

Mount Virtual Box share folder command
1. Make sure you add a share folder in Share Folder Setting
2. go to /etc/passwd to check the uid and gid
3. open the terminal and issue the command


sudo mount -t vboxsf -o uid=[uid],gid=[gid] [share_folder_name] [mount_path]    


Sometimes we may need to mount Virtual Box Guess Addition ISO file, following command use to mount VBoxGuessAdditions.ISO

sudo mount -t iso9660 -o loop  [VBoxGussAddition.ISO path] [mount_path]

 


Tuesday, April 28, 2015

Upgrade jdk in centos 5 from 1.6 to 1.7 with alternatives command

1. Download latest java archive from oracle official website
2. Extract the the archieve with tar

# tar xzf jdk-7u79-linux-i586.tar.gz

3. After extracting Java archive file, set up to use newer version of Java using alternatives

# cd /opt/jdk1.7.0_79/
# /usr/sbin/alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 2
# /usr/sbin/alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 2
# /usr/sbin/alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 2
# /usr/sbin/alternatives --set java  /opt/jdk1.7.0_79/bin/java
# /usr/sbin/alternatives --set jar /opt/jdk1.7.0_79/bin/jar
# /usr/sbin/alternatives --set javac /opt/jdk1.7.0_79/bin/javac  
4. After complete step 3, check Java version, make sure the version is what we expected
# java -version




Tuesday, February 10, 2015

Allocate a 512M swap file in digital ocean linux droplet

By default Digital Ocean VPS instance is not configured to use swap space
login as root user, perform the following:
dd if=/dev/zero of=/swap.dat bs=1024 count=512K 
mkswap /swap.dat 
swapon /swap.dat 
#Edit the /etc/fstab, add the following entry. 
/swap.dat none swap sw 0 0