Thursday, August 13, 2015

Some commands for Ubuntu 14.10 Utopic Unicorn

Change hostname / Computer name

Temporary:-

hostname [NewComputerNameHere]

The command above will last until restart.

Permanently:-

sudo gedit /etc/hostname /etc/hosts
The command above will let you edit two files, /etc/hostname and /etc/hosts

1. For the /etc/hostname file can be easily done.
    Just rename the existing name to the new computer name you want.
    Then make sure you save your file.

2. For the /etc/hosts file, you have to look for the following line in the file.
    127.0.1.1 YOUR-HOSTNAME
    Replace your new computer name with the old name.
    Then make sure you save your file.
    Finally, reboot your system to let it take effect.

Check your network IP address

hostname -I

The command above will show all addresses for the host.

ifconfig

The command above will show quite an amount of information. For this section, we are interested in the network IP address, therefore, we will lookout for the keyword "inet addr". Beside this will be the IP address for this network interface. 

You might had notice that there are multiple inet addr on your terminal. 
One under wlan0, one under eth0 or one under lo.
1. wlan0 will normally be the first wireless network card that your system have.
2. eth0 will normally be the first wired network port that your system have.
3. lo is a loopback interface on your system that is normally use for testing and troubleshooting for
    software developers.

Check which account you are currently using

whoami
The command above will show which user are you currently. This command is useful when you switch users frequently using the su command and you had lost track of which account are you in currently.





Friday, April 17, 2015

If you need to buy You Need A Budget or YNAB 4, use this link to get a 10% discount off usual selling price. Discount Link.

Sunday, December 22, 2013

Linux Command: Find Out My Linux Distribution Name and Version

Normally these are the 2 commonly used command to be used. You can use any one of the following command to find out your Linux distribution and name:

cat /etc/*-release

or

lsb_release -a

In case you need the kernel information, these are the command commonly used.

uname -a

or

uname -mrs

here are a few more different ways to get some info:-

- In GUI Menu -> System  Settings -> System Info
- inxi -F
- lsb_release -a
- cat /etc/linuxmint/info
- cat /etc/issue
cat /etc/os-release

cat /etc/issue
cat /etc/issue





Thursday, June 20, 2013

C++ Code Reference - Get Process ID & Open process

Code:
GetWindowThreadProcessId(hWnd,&pid);
HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS,0,pid);

Syntax Reference :
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633522(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684320(v=vs.85).aspx/html

Example:

#include <windows.h>

int main()
{
DWORD pid;
HWND hWnd = FindWindow(NULL, "Calculator");
  if(hWnd == 0)
{
            MessageBox(0, "Error cannot find window.", "Error", MB_OK|MB_ICONERROR);
  }
else
{
            GetWindowThreadProcessId(hWnd,&pid);
            HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
    if(!pHandle)
    {
                MessageBox(0, "Could not get handle!\n", "Error", MB_OK|MB_ICONERROR);
    }
    else
    {
                //Write some code here
    }
  }
  return 0;
}

C++ code reference - Find process window

Code:
HWND hWnd = FindWindow(NULL, "Calculator");

Syntax Reference : http://msdn.microsoft.com/en-us/library/aa929233.aspx

Example:

#include <windows.h>

int main()
{
HWND hWnd = FindWindow(NULL, "Calculator");
  if(hWnd == 0)
{
    MessageBox(0, "Error cannot find window.", "Error", MB_OK|MB_ICONERROR);
  }
else
{
                //Write your code to do somethings here
  }
  return 0;
}


Wednesday, February 27, 2013

Microsoft DOS find command

Command Description

Microsoft Reference with additional examples for my own reference in a page.

Find

Searches for a specific string of text in a file or files. After searching the specified file or files, find displays any lines of text that contain the specified string.


Syntax

find [/v] [/c] [/n] [/i] "string" [[Drive:][Path]FileName[...]]

Parameters


/v : Displays all lines that do not contain the specified string.
/c : Counts the lines that contain the specified string and displays the total.
/n : Precedes each line with the file's line number.
/i : Specifies that the search is not case-sensitive.
"string" : Required. Specifies the group of characters that you want to search for. You must enclose string in quotation marks (that is, "string").
[Drive:][Path] FileName : Specifies the location and name of the file in which to search for the specified string.
/? : Displays help at the command prompt.

Remarks

•
Specifying a string
If you do not use /i, find searches for exactly what you specify for string. For example, the find command treats the characters "a" and "A" differently. If you use /i, however, find is not case-sensitive and treats "a" and "A" as the same character.
If the string you want to search for contains quotation marks, you must use two quotation marks for each quotation mark contained within the string (that is,"StringContaining""QuotationMarks").
•
Using find as a filter
If you omit a file name, find acts as a filter, taking input from the standard input source (usually the keyboard, a pipe, or a redirected file) and then displaying any lines that contain string.
•
Ordering command syntax
You can type parameters and command-line options for the find command in any order.
•
Using wildcards
You cannot use wildcards (that is, * and ?) in file names or extensions that you specify with the find command. To search for a string in a set of files that you specify with wildcards, you can use the find command in a for command.
•
Using /v or /n with /c 
If you use /c and /v in the same command line, find displays a count of the lines that do not contain the specified string. If you specify /c and /n in the same command line, find ignores /n.
•
Using find with carriage returns
The find command does not recognize carriage returns. When you use find to search for text in a file that includes carriage returns, you must limit the search string to text that can be found between carriage returns (that is, a string that is not likely to be interrupted by a carriage return). For example, find does not report a match for the string "tax file" wherever a carriage return occurs between the word "tax" and the word "file."

Examples
To display all lines from Pencil.ad that contain the string "Pencil Sharpener", type:
find "Pencil Sharpener" pencil.ad
To find a string that contains text within quotation marks, you must first enclose the entire string in quotation marks. Second, you must use two quotation marks for each quotation mark contained within the string. To find "The scientists labeled their paper "for discussion only." It is not a final report." in Report.doc, type:
find "The scientists labeled their paper ""for discussion only."" It is not a final report." report.doc
If you want to search for a set of files, you can use the find command with the for command. To search the current directory for files that have the extension .bat and that contain the string "PROMPT," type:
for %f in (*.bat) do find "PROMPT" %f 
To search your hard disk to find and display the file names on drive C that contain the string "CPU," use the pipe (|) to direct the results of a dir command to find as follows:
dir c:\ /s /b | find "CPU"
Because find searches are case-sensitive and dir produces uppercase output, you must either type the string "CPU" in uppercase letters or use the /i command-line option with find.

Additional Examples

To show only Established connection results for netstat command.

netstat -ano 1 | find /i "Established"

To show all connection results for netstat command excluding lines contains 127.0.0.1
string in result.

netstat -ano | find /v "127.0.0.1"

This will any string with "REM" statement in the autoexec.bat.

find /c "REM" c:\autoexec.bat




Thursday, February 21, 2013

Enabling debug logging for the Net Logon service

Currently, I am using this tool by Microsoft to trace and track which system/users is having account lockout problem either caused by user or by worm_Conficker. Account Lockout and Management Tools

After downloading the executable file, you should extract it to any folder. Before using the tool, you would need to active debug logging on your Domain Controller first.

To active, you need to add a registry key into you Domain Controller. Here is the link to Microsoft webpage.

In short -> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\DBFlag hexadecimal value of 2080FFFF to enable 0 to disable.

Or you could use this command to enable and disable Net Logon Service and debugging too. Remember to restart the netlogon service after enable/disable of the debug logging.


Enable debug logging -> nltest /dbflag:0x2080ffff
Disable debug logging -> nltest /dbflag:0x0

Stop Net Logon Service -> net stop netlogon
Start Net Logon Service -> net start netlogon


Nltest is included as part of Windows Server 2008 and is also available as part of the Support Tools packages on the installation media for Windows Server 2003, Windows XP, and Windows 2000. 

The netlogon.log is normally under debug folder in the Windows system directory of your Domain Controller which you enable the debug logging.

To delete the netlogon.log file after debugging, you would need to stop the netlogon service before deletion. After deletion you can start back the net logon service again. The commands to do so is as follows.

net stop netlogondel netlogon.lognet start netlogon

Wednesday, January 30, 2013


Function Name

DAY


Syntax

DAY(number)


Description

Returns the day, as an integer, of the given date value. A negative date/time value can be entered. Number is a time value.

Example:


=DateValue("31/01/2013") = 41305


Google Day Function Example
A B
1 Date 41305
2 Formula =Day(B1)
3 Result 31


Tuesday, January 15, 2013

Google Spreadsheet Function - DATEVALUE


Function Name

DATEVALUE

Syntax

DATEVALUE(text)

Description

Returns the internal date number for text in quotes. Text is a valid date expression and must be entered with quotation marks.

Example:



Google DateValue Function Example
A B
1 Formula =DateValue("31/01/2013")
2 Result 41,305






Thursday, January 10, 2013

Google Spreadsheet Function - DATE

Function Name

DATE


Syntax

DATE(year, month, day)


Description

Converts a date written as year, month, day to an internal serial number and displays it in the cell's formatting. Year is an integer between 1583 and 9956 or 0 and 99. Month is an integer between 1 and 12. Day is an integer between 1 and 31.

Example:


Google Date Function Example
A B
1 Date 11/01/2013 11:05:10
2 Formula =Date(Year(B1),Month(B1),Day(B1))
3 Result 11/01/2013





Wednesday, January 9, 2013

Sending Ctrl + Alt + Del to Remote Client in Remote Desktop Connection Session


If you press Ctrl + Alt + Del while using Remote Desktop Connection, your local PC will response to the key pressed rather then the remote PC.

In order to send Ctrl-Alt-Del keystrokes to remote computer connected via Remote Desktop Client, just press Ctrl + Alt + End.

Tuesday, November 20, 2012

Remove saved credentials or password stored in Windows 7

If you are facing problems regarding connecting to a network drive and the system did not prompt you for a username and password. Most likely, you had already a password being saved in the system already. You could type this command to check the credentials that had been stored previously.
rundll32.exe keymgr.dll, KRShowKeyMgr
From here you can remove authenticated network shares so that the next time you will have to type in the credentials again.


Tuesday, October 30, 2012

Linux: CentOS 6.3 - Guide to install GNOME Desktop from CLI using yum

1. You would need to install "X Windows System" first, as this is the based that provide GUI and rich input device capability before installing GNOME Desktop. This will take a while as yum would download packages from the net before installing, therefore please have your internet connection setup before executing. Command to execute :-
# yum groupinstall -y 'X Window System'
2. Next will be the command for installing GNOME Desktop Environment :-
#  yum groupinstall -y 'Desktop'
3.  Done. To start GNOME type the following command :-
# startx
Note: If you would like to start GNOME automatically after reboot, you would need to edit the /etc/inittab file by changing the line " id:3:initdefault: " to " id:5:initdefault: " in the file.


Linux: CentOS 6.3 - Force DHCP client to renew ip address

Here are a few commands that I used to renew the ip address that has DHCP configured.

1. ifdown and ifup command to restart network card eth0 as follows :-

# ifdown eth0
# ifup eth0
2. Restarting the networking services command :-
# /etc/init.d/networking restart
3. Restart network service using service command :-
# service network restart
4. This command is for releasing the ip address :-
# sudo dhclient -r
This command is for getting a ip address :-
# sudo dhclient 

Linux: CentOS 6.3 - Changing the hostname or computer name

First of all, you need the command to check what is your box computer name(hostname).

Please note that all the "#" sign shown are meant to be the start of the command prompt, therefore please ignore it.

To check your hostname, type the following command:
# hostname

I am using the following method to change the hostname of my linux box:-

1. Change the hostname by using sudo hostname command.
# sudo hostname 'newhostname'
(without the quotes)

2. Edit the network configuration file. Type this command to use vi editor.
# vi /etc/sysconfig/network
2.2 Find the following line => hostname = localhost.domain.local
change the "localhost.domain.local" to your new hostname.
(note: in vi editor press i or the insert key to switch to insert/editing mode. Press "Esc" to exit insert/editing mode.)
2.3 Save and close the file.
(note: in vi editor type :wq! follow by enter to save and quit the editor)


Thursday, October 18, 2012

Day Trading Strategies For Beginners

I would strongly recommend beginners for trading read this link below.
http://www.investopedia.com/articles/trading/06/daytradingretail.asp#axzz29ivIcrjr

The author is writing as per experience and stating the truth. As always, practising to be perfect in your trading isn't as easy as being thought or said.

Samsung Galaxy Note 2 review

Here is a review that I find it in real detail but do not that it is a little lengthy.

http://www.techradar.com/reviews/phones/mobile-phones/samsung-galaxy-note-2-1093688/review#articleContent

Merging multiple mp3 files into a single mp3 file for Mac OS X

Trying to create rip an audio book into mp3 while I faced this problem.

Basically, the audio book CD came in various tracks in it.
After ripping it from iTunes to mp3, multiple mp3 files had been created which is not very convenient to manage or listen.

Here is a command from the Terminal which I used to merge the multiples mp3 files together >>

for i in *; do echo $i; cat $i >> bigfile.mp3; done;

This command will actually join the mp3 files together and show the sequence it was being joined. Please rename your file in sequence and make sure there isn't any spaces in the filename.

Tips and Tricks : Increase VirtualBox VDI disk size

Run this command >> VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB

In example :-

To modify the existing vdi operating system to 40000MB instead of default 10GB.
Assume my file name is WinXP.vdi.

Command to run >>
VBoxManage modifyhd WinXP.vdi --resize 40000

Wednesday, October 17, 2012

Difference between encoding and encryption?

Interesting to be suddenly being questioned by someone on this topic.
Here is a simple form to the answer.

    Encoding is changing the way data is presented
      - using a public, generally-understood, and (usually) low-overhead method
      - for the purpose of allowing the data to survive intact and easily recoverable after some sort of transfer.
    Encryption is changing the way data is presented
      - using a method or a key that is restricted and (as it happens) often computationally intensive
      - for the purpose of shielding the data from some people while making it available to others.