Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

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.





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





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:][PathFileName 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 /ifind 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