Commands tagged blogs

List of Windows Tools and Commands

Useful list of Windows tools and commands

-1st May 2011

A practical list of Windows tools and commands is listed below, more might be added with time.
The followig table mainly displays tools useful for troubleshooting connectivity issues and performance problems.

Network Services Management Support Tools
Active Directory Management Support Tools
Windows Server 2003 Resource Kit Tools
Nslookup, Ping, Tracert
Poolmon, Process Monitor, Speedfan

This is not an attempt of a complete list.

Source: See URL's above.

Tagged as: CommandsTools

How to Clean up a Windows System Drive

How to Clean up a Windows System Drive

-23rd February 2013

This is a list of steps that can be taken to clean up a system drive and thus save space. Make sure you have set up your folder view to show all hidden files and not hide system files. In addition to this list you might want to try ccleaner from Piriform. Ccleaner can be scripted as well.

1. Do you use shadow copies on the system drive? Do you need them? If not you can delete them with the following command: vssadmin delete shadows /for=%SystemDrive% /all /quiet
2. How much space is the shadow storage taking on your system drive? You can resize it here with the following command: vssadmin Resize ShadowStorage /For=%SystemDrive% /On=%SystemDrive% /MaxSize=4GB
3. Are there memory dumps stored on your system? You can safely delete them. If not specifically specified otherwise, you will find them at:
4. Do you run IIS on your server or computer? You can compress the log files at %SystemDrive%\inetpub\logs\LogFiles using NTFS compression.
5. You can safely delete the following:
6. The following can be compressed with NTFS compression:
7. If you are using Windows 7 or Windows Server 2008R2 you might want to try the command dism.exe /online /cleanup-image /spsuperseded to clean up the winsxs folder.
   On Windows Vista or Windows Server 2008 Service Pack 2 the tool that does the same job is Compcln.exe.
   On Windows Vista or Windows Server 2008 Service Pack 1 the tool that does the same job is VSP1CLN.EXE.
8. Finally - you can use cleanmgr.exe to clean up a whole lot more. If you want to script it, you can set it up first with the command cleanmgr.exe /sageset:101
   After choosing what you want to clean up in the dialog box that appears, you cun run the same cleanupjob any time you want with the command cleanmgr.exe /sagerun:101
   The setup for the cleaning job is stored in the registry in several keys under the following path:
   In our example, if we chose to clean up Active Setup Temp Folders, the key "StateFlags0101"=dword:00000002 will be created under
      ..\VolumeCaches\Active Setup Temp Folders indicating this as a part of the 101 cleanup job.
   Thus if you wanted, you could set up a clean up job and export the keys from the registry that you want to constitute the same cleanup job on other computers without you having to go through the graphical user interface every time you want to create that same job. This makes a great opportunity for automating with scripts in large server environments.

This is not an attempt of a complete list.
   Feel free to inform me if you have further suggestions.

Source: Information gathered over time.

Tagged as: CommandsToolsHowTo

Netmap, Netcat, Nmap, Netstat and TCPDump

Netcat, Nmap, Netstat and TCPDump

-20th of December 2013


Netcat as a server to setup port for testing a network connection:
nc -w 600 -k -l 2389
Netcat will listen for 600 seconds(-w) and then stay up after the client disconnects(-k). The client will listen on port 2389.

To test the connection to the netcat server, you can use telnet from a different machine on the same network:
telnet -e p 2389
press p
type quit
press enter

We can also test the connection with netcat as a client:
nc 2389

Send a file over with netcat using udp(-u):
>at the server: $ nc -u -l 2389 > outputfile
>at the client: cat testfile | nc -u localhost 2389

Netcat as a client via a gateway and spoofing its IP:
nc -s spoofed_ip -g <gateway> remote_host <port>
Note: Up to eight hop points may be specified using the -g flag.

Netcat as a port scanner:
nc -r -w1 -v -n -z 3305 – 3320
-r for random ports in range
-w1 for wait 1 second for a reply
-v for verbose output
-n for no name resolution
-z for send no data

Get all header replies from services listening on ports in range:
echo "" | nc -v -n -w1 3306 – 3307
Example reply: Host '' is not allowed to connect to this MySQL server

Netcat proxy to Google that sends responses on port 123456 back to client:
nc -l -p 12345 | nc 80 | nc -l -p 12346

Show a web page on port 80:
while true; do nc -l -p 80 -q 1 < error.html; done

Send a partition over the network with netcat:
Receiving side:
nc -l -p 9000 | dd of=/dev/sda

Sending side:
dd if=/dev/sda | nc 9000


#2 find what servers respond to ping

SYN scan with spoofed source addresses

Ping scan with a spoofed source address

TCP SYN Scan with OS detection

Scan port range 1-200 with version detection

  • NMAP Project Guide
  • NMAP Ping of Death
  • NMAP tricks #1
  • NMAP tricks #2


    NBTSCAN is the Linux version of NBTSTAT, and can
               handle ranges of addresses instead of just a single host.
    nbtscan -hv

    The tool will scan for netbios information on the host.

  • More NBTSCAN examples


    List all open ports with netstat

    All open ports, numeric with network timers

    Click and see titles under for descriptions

    Click and see titles under for descriptions

  • netstat -au or netstat -at
  • netstat -lt or netstat -lu
  • netstat -st
  • netstat -su
  • Microsofts Netstat
  • Linux and Unix Netstat
  • More Netstat
  • Netstat MAN Pages


    Source: Manual pages

    Tagged as: LinuxCommandsNetwork

    Sed, Cut and Awk

    Sed, Cut and Awk

    -20th of January 2013

    These are over simplified examples, which are good for getting started with an simple overview.
    The commands are executed in the Linux shell or terminal, and exemplify common ways to parse data.

    Usages of sed:

    • Example:
    • sed 's/<find>/<replacement>/<option>'

    • Showing /etc/passwd in tab delimited style instead of semicolon delimited style:
    • more /etc/passwd | sed 's/\:/\t/g'

    • Disabling all yum repos in /etc/yum.repos.list:
    • 						for i in /etc/yum.repos.d/*; do
      							cat $i | sed 's/enable=1/enabled=0/g' > $i

    Usages of cut:

    Issue the command 'man cut' for more information.
    • Filtering only the first and sixth field, and delimiting with two tabs:
    • more /etc/passwd | cut -d: -f1,6 | sed 's/\:/\t\t/g'
    • List how much free memory is on the system:
    • echo 'Free megabytes of memory:' `free -m | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4`

    Usages of awk:

    Awk is more than a command, it borders to a programming language. Examples given here are only teasers.
    • Print all lines longer then 50 characters:
    • awk 'length($0) > 50' /etc/passwd
    • Print columns one and six using /etc/passwd and : as a delimiter, sum column 3 and 4:
    • awk -F":" '{print $1,$6 " - Sum of column 3 and 4, " $3 " + " $4 ": " $3 + $4}' /etc/passwd
    • Print all columns using stdin:
    • awk ' {print $0} '

    Various relevant informational links:

    Sources: Google, Høgskolen i Sør-Trøndelag.

    Tagged as: LinuxCommands

    Change and verify the NTP client in Windows

    Change and verify the NTP client in Windows

    -17th of April 2014

    In the command prompt running as administrator or in a bat file,
    set the NTP client to fetch its time from for instance the following list of time servers(
    the example here is with Norwegian time servers):
    			@echo off
    			w32tm /config /,, /syncfromflags:manual /reliable:yes /update
    			net stop w32time && net start w32time
    			w32tm /resync

    Optionally verify the configuration with the following set of commands:
    			w32tm /query /configuration
    			w32tm /query /status

    Sources: Microsoft

    Tagged as: ToolsCommandsHowTo

    make targets - an overview

    Make targets - an overview

    -15th of August 2014

    This short article aims to give a quick overview of several of the make targets in Linux that I have found useful to know, and what they do. Simple examples follow underneath the list of targets. From the man pages for the make command; "The purpose of the make utility is to determine automatically which pieces of a large program need to be recompiled, and issue the commands to recompile them."

    Note: These targets are setup in the Makefile. The usage of these as shown below is what is the normal standard, but can deviate if the Makefile deviates.
    • binrpm-pkg - Builds the kernel as compiled binary.
    • rpm-pkg - Builds the kernel as rpm package.
    • deb-pkg - Builds the kernel for Debian only.
    • tar-pkg - Builds the kernel as uncompressed tarball.
    • rargz-pkg - Builds the kernel as gzip compressed tarball.
    • tarbz2-pkg - Builds the kernel as bzip2 compressed tarball.
    • dep - Make all dependencies. The command 'make dep' ensures all dependencies are in place.
    • modules - Compiles kernel modules.
    • modules_install - Installs modules for the kernel.
    • bzimage - Compiles and makes kernel as bzImage.
    • <none> - When compiling application sources, issuing make without a target will simply compile the sources. In kernel compilation, the make command without any target normally is the same as 'make bzimage' and 'make modules'.
    • install - Compiles and installs the application if we are compiling application sources. If compiling a kernel; creates a ramdisk, copies in kernel file to /boot and sets up that keeps tracks of pointers to functions in the kernel.
    • all - Is the same as 'make' without a make target (see description above) and then also make 'modules_install' if we are doing kernel compilation.
    • mrproper - Cleans up old configuration, temporary files, modules and module dependencies. Removes everything make config creates.
    • clean - Cleans up everything 'make all' created, but leaves the configuration if ./configure or 'make config' was run.
    • distclean - Cleans anything ./configure created.
    • oldconfig - Reads the existing .config file and prompts the user for options in the current kernel source that are not found in the file. This is useful when taking an existing configuration and moving it to a new kernel.
    • silentconfig - Works exactly the same way as oldconfig does, but it does not print anything to the screen, unless it needs to ask a question about a new configuration option.
    • config - Make configuration with text based user interaction. The options are prompted one after another. All options need to be answered, and out-of-order access to former options is not possible.
    • menuconfig - Make configuration with graphical menu (only text input). You can navigate through the menu and change the options you want.
    • xconfig - Make configuration with graphical menu using Qt4. Requires dev-qt/qtgui to be installed.
    • gconfig - Make configuration with graphical menu using GTK+. Requires x11-libs/gtk+, dev-libs/glib and gnome-base/libglade to be installed.

    Compilation of application sources: Kernel Compilation:
    make install
    make menuconfig
    make modules
    make modules_install
    make install

    Various relevant informational links:

    Sources: The whole of the World Wide Web

    Tagged as: LinuxCommands

    How to convert IMG to ISO

    How to convert IMG to ISO

    -22nd of February 2013

    Thought I would share my notes on converting IMG files to ISO in Linux.

    Note: ># represents the command prompt and is not
    actually a part of the commands shown below:

    Option 1. >#ccd2iso file.img file.iso
    Option 2. >#mount -o loop <img file> <mountpoint>
       >#mkisofs -dvd-video -o <iso output file> <mountpoint>
       mkisofs is the same as genisoimage in Debian.
    Option 3. Just rename the img file to an iso file :)

    IMG and ISO file formats is usually a file image of a CD, DVD or BD. The entire contents of the disk is contained within the ISO or IMG file. With various tools, an ISO can be set to contain any set of files to later be used as a image for the creation of CD's, DVD's or such. Both the ISO and IMG files need to be mounted on a mountpoint or virtual drive to be read and used by the operating system. When mounted, they will act as a real CD, DVD or such to the operating system.

    Sources: No real sources

    Tagged as: LinuxHowToCommands

    Expand logical volume - LVM

    LVM - How to expand a logical volume

    -18th of October 2013

    This article will briefly describe how to expand a logical volume that is part of a LVM.

    Note: ># represents the command prompt and is not actually a part of the commands shown below:
    Before we start the following needs to be summarized:
       a. A partition on a disk is made a 'Physical Volume.'
       b. This 'Physical Volume.' will then be added to a 'Volume Group.'
       c. In the end we have a 'Logical Volume' that the 'Volume Group' is a part of, and that is mounted to the file system.
    This howto can be performed on most Linux distributions. It will have to be done by issuing the commands in order on a terminal command prompt. You will most likely need root privileges, either by sudo or by logging in as root. How to use the terminal, sudo or login as root will not be explained here. For extending swap space, use the guide below and see here.
    So here we go:
       1. Add the disk to the physical computer or virtual machine(if that is the case).
       2. Boot the machine. Some say a rescan will be enough, I had to boot.
       3. List the disk with: fdisk -l
    Disk /dev/sdc: 8589 MB, 8589934592 bytes
    255 heads, 63 sectors/track, 1044 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
       4. Make a partition on this disk:
       # fdisk /dev/sdc
    > Then press 'n' to add a new partition.
    > Then press 't' change the partition type. Choose 8e(Linux LVM).
    > Then press 'w' to write the partition table.

       5. List the disk again with: fdisk -l
    Disk /dev/sdc: 8589 MB, 8589934592 bytes
    255 heads, 63 sectors/track, 1044 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xa0d940fd

    Device Boot   Start   End   Blocks   Id   System
    /dev/sdc1   1   1044   8385898+   8e   Linux LVM
       6. Make a Physical Volume out of /dev/sdc1:
       # pvcreate /dev/sdc1
       After this is done, I would want to know what Volume Group to place my Physical Volume. To find that, I would start by finding the name of the Logical Volume that is mounted on the filesystem, and see what Volume Group it is using. In my case the mount point /mnt/syslogs is full, so I type mount in the console to get a list of mounts on the filesystem and see what is mounted on /mnt/syslog:
       /dev/mapper/vgLogDisks-lvSysLogs on /mnt/syslogs type ext4 (rw)
    From this I know that the Logical Volume I am looking for is 'lvSysLogs.' I will then use the command lvdisplay to list information about logical volumes on the system. By this I find '/dev/vgLogDisks/lvSysLogs', with:
       VG Name    vgLogDisks

    I can verify the existence of this group by using the command vgdisplay.

       7. I will add our Physical Volume to vgLogDisks judging by the information above:
    # vgextend vgLogDisks /dev/sdc1
    Volume group "vgLogDisks" successfully extended
       8. Our Logical Volume that makes out /mnt/syslog is still no larger despite its Volume Group getting a new disk. We therefore ectend our Logical Volume by the new disk:
    # lvextend /dev/vgLogDisks/lvSysLogs /dev/sdc1
    Extending logical volume lvSysLogs to 17.99 GiB
    Logical volume lvSysLogs successfully resized
       9. After this is done it is time to extend the filesystem to fit the Logical Volume:
    # resize2fs /dev/vgLogDisks/lvSysLogs
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/vgLogDisks/lvSysLogs is mounted on /mnt/syslogs; on-line resizing required
    old desc_blocks = 1, new_desc_blocks = 2
    Performing an on-line resize of /dev/vgLogDisks/lvSysLogs to 4715520 (4k) blocks.
    The filesystem on /dev/vgLogDisks/lvSysLogs is now 4715520 blocks long.
       10. Finally, we verify that the disk has all its new space:
    # df
    Filesystem    1K-blocks    Used    Available    Use%    Mounted on
    /dev/mapper/vgSystem-lvRoot    10014648    1967016    7538912    21%    /
    tmpfs    1962520    0    1962520    0%    /dev/shm
    /dev/sda1    297485    67833    214292    25%    /boot
    /dev/mapper/vgSystem-lvLog    2064208    85584    1873768    5%    /var/log
    /dev/mapper/vgLogDisks-lvSysLogs    18565884    9709504    7913792    56%    /mnt/syslogs

    Sources: LPIC-2 Study Guide: ISBN: 978-1-118-00015-1

    Tagged as: LinuxHowToCommands

    Main page
    VMWare Hyper-V General
    Active Directory
    SQL 2008
    SQL 2016