Command Line

How to find a Program Version on List of Computers Using wmic and psexec

Using wmic, you can easily get a list of most of the applications installed on a computer:

wmic Product get Name

How to find a Program Version on List of Computers Using wmic and psexec1

To list the name & version of a program that you know part of the name to, run the following:

wmic product where "Name like '%Java%'" get Name, Version

To list the name & version of a program that you know the full name of, run the following:

wmic product where "Name='Java 7 Update 60'" get Name, Version

How to find a Program Version on List of Computers Using wmic and psexec 2

 

 

Now that you know how to get a program name & version using the command line, now you just need to learn how to run the command on a group of computers. There are two ways to do this, both involving psexec, a utility from the sysinternals suite.

Windows - How to Measure Time or Length of Command or Executable

There are serveral reasons you would want to see how long it takes to execute a command, or run a program. Perhaps you are benchmarking a command line application you made, or want to see how long it takes to run the same command on different computers. Whatever your reason, here are 3 ways to measure the time it takes to execute a command or application on Windows. In my example, I'm seeing how long it takes to perform a DNS query (you can replace the underlined portion with the command you want to time):

1. In PowerShell, run the following command:

Measure-Command {nslookup itswapshop.com}

 

2. Here is a one-liner you can run from the command prompt:

cmd /v:on /c "echo !time! & nslookup itswapshop.com & echo !time!"

 

3. Save this at a batch file, and then run it:

echo %time%

nslookup itswapshop.com

echo %time%

 

Here is a screenshot of each method:

Windows - How to Measure Time or Length of Command or Executable

How to Find Listening Ports on Windows from Command Line

Any version of Windows, including XP, Vista, 7, Server 2003, Server 2008, and Server 2012, you can use the netstat command to find listening ports on a system. This helps you are troubleshooting if a service or server is actually running on a system. Simply run the following command to find all listening ports on a system:

netstat -an | find /i "listening"

Find Listening Ports - Windows

Linux - History Command Tutorial - How to Run Previous Commands and Clear History

The history command is very useful for people who use the command line. If you haven't used it before, now is a great time to make it a habit, as it can save you time.

The history command by itself will provide a numbered list of previously executed commands:

history - tutorial run previous commands 1

To execute one of the previously ran commands, use the exclamation mark followed by the number of the command (no spaces):

!3

history - tutorial run previous commands 2

To clear the history, run the following command:

history -c

history - tutorial run previous commands 3

To simply run the last ran command again, run the following command:

!!

Hope this helps some of you become more proficient in the command line!

Linux - Change to Home Directory From the Command Line Terminal

A lot of people don't know you can do this, or don't know how. Obviously to change directories you use the cd command. To change to your home directory, run the following command:

cd ~

Change_to_home_directory_linux_terminal

You can also use this method to reference files or folders in your home folder. For example:

cat ~/Documents/send-connector.txt

is the same thing as this:

cat /home/user/Documents/send-connector.txt

Linux - Log out of Unity or Gnome from Command Line Terminal

To log out of Gnome or Unity from the command line, simply run this command:

gnome-session-quit

It will prompt you to click the 'log out' button. To log out without being prompted, run this command:

gnome-session-quit --no-prompt

This should work in any Linux distribution (Ubuntu, Debian, openSUSE...) that is using Unity, Gnome, or a Gnome based desktop environment.

Ubuntu Linux - How to Find IP Address from Terminal and GUI

Finding your local LAN ip address in Ubuntu Linux is very easy. There are 2 ways to find it, from the command line or from the GUI.

Command Line:

Just open the terminal and run this command: ifconfig

Ubuntu Linux - Find IP Address 1

 

GUI:

Right click on the Network Manger icon in the top right corner and click on "Connection Information". You will then see a window displaying your ip address and other useful network information:

Ubuntu Linux - Find IP Address 2

Ubuntu Linux - Find IP Address 3

Ubuntu Linux - How to Restart or Reboot System from Command Line Terminal

 

Restarting or rebooting an Ubuntu Linux computer or server from the command line is very simple. Just run the following command:
 
sudo reboot
 

Ubuntu Linux - How to Shutdown System from Command Line Terminal

Shutting down an Ubuntu Linux computer or server from the command line is very simple. Just run the following command:

sudo shutdown -P 0

-P means 'Power Off' and 0 is the number of seconds to wait before powering off.

How to Get List of All Groups in Domain from Command Line - Windows

To get a list of all groups in a domain and export them into a text file, run the following command (you need to have the appropriate permissions to run this command, a domain admin will work):

net group /domain > domain-groups-list.txt

This will export a list of all domain groups into a text file in the working directory. This should work in any Microsoft Windows Active Directory Domain.

Pages

Subscribe to Command Line