Command Line Linux SysInternals WhoIS Windows

Whois Command Line Utility for Windows

This great command line utility for Windows by Mark Russinovich over at SysInternals is the quick and easy way to get whois info for domain names or IP addresses.

Whois performs the registration record for the domain name or IP address that you specify.


whois domainname [whois.server]
whois IP address [whois.server]

Domainname can be either a DNS name (e.g. or IP address (e.g.

For ease of use I prefer to save whois.exe to my Windows system directory (usually C:WindowsSystem32) which is already in your path so you can invoke whois from any directory in the command prompt.

Download Whois

Command Line Linux Passwords RSync SSH Ubuntu Windows

What is the Linux equivalent to RoboCopy?

The Linux equivalent to Window’s robocopy is the command line file mirroring utility called rsync.

Whether you want to backup your data, distribute files securely or mirror your working documents over the internet from the office to home, between computers on your local network, or from your computer to your web server, rsync can get the job done.

Rsync Switches
To see all the available options, type rsync --help at the command line. Here are a few of the options:

  • -r, –recursive – recurse into directories
  • -u, –update – skip files that are newer on the receiver
  • -n, –dry-run – show what would have been transferred
  • –existing – only update files that already exist on receiver
  • –delete – delete files that don’t exist on the sending side
  • -z, –compress – compress file data during the transfer
  • –exclude=PATTERN – exclude files matching PATTERN

If you’re just getting started with rsync, the -n (“dry run”) switch with -v (verbose) is a great way to see what files would get copied without actually performing the copy. Use that switch to test out your rsync recipe before you run it.

Of course, once you get your rsync command just right, you can place it in a batch file or shell script and automate it using Windows Task Scheduler (or cron on the Mac or a Linux machine). The only problem here is that you’ll get a password prompt every time to log into the machine you’re ssh’ing into; use this handy tip on how to set up passwordless ssh logins to automate rsync without the prompt.

Rsync will run on OS X, Ubuntu, Debian, Red Hat, SUSE, etc. You can even run it on Windows machines with Cygwin which is a Linux-like environment for Windows.

More about Robocopy

Command Line Robocopy RoboCopy Examples Windows

Robocopy Examples

Examples of Microsoft’s Robocopy (robocopy.exe) syntax.

Robocopy Example 1: Copy files from one computer to another, skipping files already in the destination.

robocopy \Computer1reports \Computer2backup *.doc /S

Robocopy Example 2: List files over 32 MBytes in size.

robocopy C:xyz /MAX:33554432 /L

Robocopy Example 3: Move files over 14 days old (note the MOVE option will fail if any files are open and locked).

robocopy C:origin C:destination /move /minage:14

Robocopy Example 4: /MIR is an option to ROBOCOPY where you mirror a directory tree with all the subfolders including the empty directories and you purge files and folders on the destination server that no longer exists in source.

robocopy \sourceserversharepath \destinationserversharepath /MIR


robocopy source-drive:path destination-drive:path /MIR

Robocopy Example 5: The following command will mirror the directories using robocopy:

robocopy \SourceServerShare \DestinationServerShare /MIR /FFT /Z /XA:H /W:5

/MIR specifies that robocopy should mirror the source directory and the destination directory. Note that this will delete files at the destination if they were deleted at the source.
/FFT uses fat file timing instead of NTFS. This means the granularity is a bit less precise. For across-network share operations this seems to be much more reliable – just don’t rely on the file timings to be completely precise to the second.
/Z ensures robocopy can resume the transfer of a large file in mid-file instead of restarting.
/XA:H makes robocopy ignore hidden files, usually these will be system files that we’re not interested in.
/W:5 reduces the wait time between failures to 5 seconds instead of the 30 second default.

Robocopy Example 6: use robocopy to copy all changes to files in a directory called c:data to a directory that contains the date, like data_20091124.  Create a batch file as follows.

@echo off
set day=%date:~0,2%
set month=%date:~3,2%
set year=%date:~6,4%
robocopy "c:data" "c:backupdata%day%-%month%-%year%" /MAXAGE:1

Robocopy Example 7: To mirror the directory “C:directory” to “\server2directory” excluding \server2directorydir2″ from being deleted (since it isn’t present in C:directory) use the following command:

robocopy "C: directory" "\server2 directory" /MIR /XD "\server2 directorydir2"

Robocopy Example 8: Copy a single file:

robocopy <Source Dir> <Destination Dir> <File Name> <Switches> 

Robocopy can be setup as a simply Scheduled Task that runs daily, hourly, weekly etc. Note that robocopy also contains a switch that will make robocopy monitor the source for changes and invoke synchronization each time a configurable number of changes has been made. This may work in your scenario, but be aware that robocopy will not just copy the changes, it will scan the complete directory structure just like a normal mirroring procedure. If there are a lot of files & directories, this may hamper performance.

More Robocopy
robocopy commands
robocopy syntax
Command Line cscript HTTP Headers IIS Linux Windows

Set IIS 6 (and IIS 7) custom HTTP headers from the command line

Command line method to set the Custom HTTP Headers.
*Must execute from (default) c:InetpubAdminScripts:

cscript adsutil.vbs set w3svc/HttpCustomHeaders “X-Powered-By: ASP.NET” “<Header 2>: <Value 2>” “<Header 3>: <Value 3>”

Just replace “Header 2”: “Value 2” and “Header 3”: “Value 3” with your own values. Add more as desired.

Note: This command updates/replaces current values and does not add to them so any existing value must be included or it will be overwritten. I included “X-Powered-By: ASP.NET” as it’s a common default HTTP header value.

This works on both IIS 6 and IIS 7, not sure about previous versions.

Clipboard Command Line DOS Linux Resource Kit Utility Windows

Copy Command Line Output to Windows Clipboard Directly

Starting with Windows Vista and Windows 2003 Microsoft has finally included clip.exe.  With clip.exe you can copy items directly to the Windows clipboard from a command prompt.  XP (and earlier) users can get clip.exe from Microsoft with the Windows Server 2003 resource kit.

You can use clip with a PIPE (|) operator in your command line commands. Here are some examples:

dir /h | clip – Copy the help manual for DIR command to the clipboard

tracert | clip – Trace the path from your computer to another website – the output is automatically copied to the clipboard and not displayed on the screen.

netstat | clip – Check if your computer is connecting to websites without your knowledge.

The clip.exe utility can also be used to copy contents of text files to clipboard directly from the command line.

clip < C:MyFile.txt – will copy all the text from MyFile.txt to your Windows Clipboard.

Copy clip.exe help to clipboard with clip /? | clip:



    Redirects output of command line tools to the Windows clipboard.

    This text output can then be pasted into other programs.

Parameter List:

    /?                  Displays this help message.


    DIR | CLIP          Places a copy of the current directory

                        listing into the Windows clipboard.

    CLIP < README.TXT   Places a copy of the text from readme.txt on to the Windows clipboard.

Batch File Command Line Linux Windows

Testing If a Directory Exists from a Batch File

Going old school here. . .

To check for the presence of a directory (or folder) you can use the IF EXIST statement. For example, to test for C:TEMP and then change to C:TEMP if it exists, else create the directory and change to it, use the following batch file:



Command Line Robocopy RoboCopy Examples Windows

How to Copy Files Multi-Threaded with Robocopy in Windows 7

Robocopy, short for Robust File Copy, is a command-line directory replication and file copy command utility that first made available as feature in Windows Vista and Windows Server 2008, although it has been available as part of Windows Resources Kit. In Windows 7 and Windows Server 2008, Robocopy utility is further enhanced with ability to multi-threaded copy operation feature.

Multi-threaded support allows Robocopy to open multiple threads simultaneously, allowing many files to be copied in parallel. With multi-threaded copying, total time required to complete the operation will be drastically reduced and cut, when comparing with with typical copying one file at time in serial sequential order.

As Robocopy is generally a command-line only utility (although a GUI add-on is available for Robocopy), the new multi-threaded operation capability has to be called via a new switch supported by Robocopy. The new multi-threaded copy feature can be enabled and turned on with the following parameter:


Where n will instruct Robocopy to do multi-threaded copies with n threads (default 8). The value of n must be at least 1 and not greater than 128 (between 1 to 128), with 1 as single thread. In fact, Robocopy will copy files and folders in multi-threaded operation by default, with 8 threads in one go. Note that /MT[:n] switch is not compatible with the /IPG and /EFSRAW operations.

For example,

robocopy C:Folder1 C:Folder2 /MT:32

More Robocopy

Command Line Resource Kit Robocopy RoboCopy Examples Utility Windows

Robocopy Syntax, Command Line Switches and RoboCopy Examples

RoboCopy (Robust File Copy) is a command-line file copying tool in Windows 7, and Windows Vista. Although RoboCopy has been available for free with the Windows Resource Kit, it has never been an official feature of the operating system until Windows Vista. Unlike other built-in file copying commands such as Copy and XCopy, RoboCopy is designed for reliable copy or mirroring of entire folders of any size, and in the copying process, ensure that all NTFS ACLS, attributes, owner information, alternate data streams, auditing information, timestamps and properties are copied except security information unless explicitly requested with /COPYALL switch. And best of all, RoboCopy works over network connections that are subject to disruption or outages with resume copying feature, and has progress indicator on the command line that is useful when copying large files.

RoboCopy Syntax

ROBOCOPY source destination [file [file]…] [options]

Where source is Source Directory (drive:path or \serversharepath), destination is Destination Directory (drive:path or \serversharepath) and file is File(s) to copy where names or wildcards can be specified and default is “*.*” (all files).

RoboCopy Options and Switches
RoboCopy Copy Options

  • /S – copy Subdirectories, but not empty ones.
  • /E – copy subdirectories, including Empty ones.
  • /LEV:n – only copy the top n LEVels of the source directory tree.
  • /Z – copy files in restartable mode.
  • /B – copy files in Backup mode.
  • /ZB – use restartable mode; if access denied use Backup mode.
  • /EFSRAW – copy all encrypted files in EFS RAW mode.
  • /COPY:copyflag[s] – what to COPY for files (default is /COPY:DAT).
    (copyflags : D=Data, A=Attributes, T=Timestamps).
    (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).
  • /DCOPY:T – COPY Directory Timestamps.
  • /SEC – copy files with SECurity (equivalent to /COPY:DATS).
  • /COPYALL – COPY ALL file info (equivalent to /COPY:DATSOU).
  • /NOCOPY – COPY NO file info (useful with /PURGE).
  • /SECFIX – FIX file SECurity on all files, even skipped files.
  • /TIMFIX – FIX file TIMes on all files, even skipped files.
  • /PURGE – delete dest files/dirs that no longer exist in source.
  • /MIR – MIRror a directory tree (equivalent to /E plus /PURGE).
  • /MOV – MOVe files (delete from source after copying).
  • /MOVE – MOVE files AND dirs (delete from source after copying).
  • /A+:[RASHCNET] – add the given Attributes to copied files.
  • /A-:[RASHCNET] – remove the given Attributes from copied files.
  • /CREATE – CREATE directory tree and zero-length files only.
  • /FAT – create destination files using 8.3 FAT file names only.
  • /256 – turn off very long path (> 256 characters) support.
  • /MON:n – MONitor source; run again when more than n changes seen.
  • /MOT:m – MOnitor source; run again in m minutes Time, if changed.
  • /RH:hhmm-hhmm – Run Hours – times when new copies may be started.
  • /PF – check run hours on a Per File (not per pass) basis.
  • /IPG:n – Inter-Packet Gap (ms), to free bandwidth on slow lines.

RoboCopy File Selection Options

  • /A – copy only files with the Archive attribute set.
  • /M – copy only files with the Archive attribute and reset it.
  • /IA:[RASHCNETO] – Include only files with any of the given Attributes set.
  • /XA:[RASHCNETO] – eXclude files with any of the given Attributes set.
  • /XF file [file]… – eXclude Files matching given names/paths/wildcards.
  • /XD dirs [dirs]… – eXclude Directories matching given names/paths.
  • /XC – eXclude Changed files.
  • /XN – eXclude Newer files.
  • /XO – eXclude Older files.
  • /XX – eXclude eXtra files and directories.
  • /XL – eXclude Lonely files and directories.
  • /IS – Include Same files.
  • /IT – Include Tweaked files.
  • /MAX:n – MAXimum file size – exclude files bigger than n bytes.
  • /MIN:n – MINimum file size – exclude files smaller than n bytes.
  • /MAXAGE:n – MAXimum file AGE – exclude files older than n days/date.
  • /MINAGE:n – MINimum file AGE – exclude files newer than n days/date.
  • /MAXLAD:n – MAXimum Last Access Date – exclude files unused since n.
  • /MINLAD:n – MINimum Last Access Date – exclude files used since n.  (If n < 1900 then n = n days, else n = YYYYMMDD date).
  • /XJ – eXclude Junction points. (normally included by default).
  • /FFT – assume FAT File Times (2-second granularity).
  • /DST – compensate for one-hour DST time differences.
  • /XJD – eXclude Junction points for Directories.
  • /XJF – eXclude Junction points for Files.

RoboCopy Retry Options

  • /R:n – number of Retries on failed copies: default 1 million.
  • /W:n – Wait time between retries: default is 30 seconds.
  • /REG – Save /R:n and /W:n in the Registry as default settings.
  • /TBD – wait for sharenames To Be Defined (retry error 67).

RoboCopy Logging Options

  • /L – List only – don’t copy, timestamp or delete any files.
  • /X – report all eXtra files, not just those selected.
  • /V – produce Verbose output, showing skipped files.
  • /TS – include source file Time Stamps in the output.
  • /FP – include Full Pathname of files in the output.
  • /BYTES – Print sizes as bytes.
  • /NS – No Size – don’t log file sizes.
  • /NC – No Class – don’t log file classes.
  • /NFL – No File List – don’t log file names.
  • /NDL – No Directory List – don’t log directory names.
  • /NP – No Progress – don’t display % copied.
  • /ETA – show Estimated Time of Arrival of copied files.
  • /LOG:file – output status to LOG file (overwrite existing log).
  • /LOG+:file – output status to LOG file (append to existing log).
  • /UNILOG:file – output status to LOG file as UNICODE (overwrite existing log).
  • /UNILOG+:file – output status to LOG file as UNICODE (append to existing log).
  • /TEE – output to console window, as well as the log file. 
  • /NJH – No Job Header.
  • /NJS – No Job Summary.
  • /UNICODE – output status as UNICODE.
RoboCopy Job Options
  • /JOB:jobname – take parameters from the named JOB file.
  • /SAVE:jobname – SAVE parameters to the named job file
  • /QUIT – QUIT after processing command line (to view parameters).
  • /NOSD – NO Source Directory is specified.
  • /NODD – NO Destination Directory is specified.
  • /IF – Include the following Files.

RoboCopy Examples
RoboCopy is simple to use, very similar to Copy and Xcopy. For example, to copy entire folder of C:Users to C:UserBackup, simply type:

robocopy C:Source C:Destination

Copy directory contents recursively, all contents of SourceDir to DestDir:

robocopy C:SourceDir C:DestDir /E

Copy directory recursively (/E), and copy all file information (/COPYALL, equivalent to /COPY:DATSOU, D=Data, A=Attributes, T=Timestamps, S=Security=NTFS ACLs, O=Owner info, U=aUditing info), do not retry locked files (/R:0).

robocopy C:source C:destination /COPYALL /E /R:0

Mirror source to destination, deleting any files in destination that are not present in source (/MIR), copy files in restartable mode (/Z) in case network connection is lost:

robocopy C:source \DestServerdestination /MIR /Z

More RoboCopy

Command Line Environment Variables Linux setx setx examples Windows

Setting Windows Environment Variables With SETX

User specific environment variables can be set from My computer -> properties -> advanced -> environment variables. But when you want to do it from script, you need another way. You could perhaps create a script and make shortcut to start menu -> propgrams -> startup. Use folder C:Documents and SettingsAll UsersStart MenuProgramsStartup, if you want to make it available for all users.

From the command line use setx.exe which is available in Windows 2003, XP, Vista, Windows 7 and up. With it you can set environment variables from scripts so that those settings are visible also outside of the executing script. To view setx help type:

setx /?

SETX can be used to set values in the environment of the machine or currently logged on user using one of three modes – command line, registry and file mode.

  • Command Line Mode: setx variable value [-m]
    Optional Switches:
    -m – Set value in the Machine environment. Default is User.
  • Registry Mode: setx variable -k hivekey…value
    Optional Switches:
    -m – Set value in the Machine environment. Default is User.
  • File Mode: setx variable -f file {-a x,y | -r x,y “string”} [-d d] [-x] [-m]
    Required Switches:
    -f <file> – Specify file name to use
    -a x,y – Specify absolute coordinates and offset
    -r x,y “string” – Specify coordinates and offset relative to string

    Optional Switches:
    -d ,: etc. – Specify additional delimiters
    -x – Displays file coordinates. Switches -a -r -e ignored
    -m – Set value in the Machine environment. Default is User.

SETX Examples
For the file type examples you must first create the file that you wish to parse by using “command > filename” i.e. ipconfig > ipconfig.out.

IMPORTANT: SETX writes variables to the master environment in the registry. Variables set using SETX are only available in future command windows and not in the current command window.

SETX Command Line Examples

  • SETX MACHINE DELL – Sets value of MACHINE to be DELL in the users environment.
  • SETX MACHINE “DELL COMPUTER” -m – Sets value of MACHINE to be “DELL COMPUTER” in the machine environment.
  • SETX MYPATH %PATH% – Sets the value of MYPATH to the CURRENT value of the PATH environment variable.
  • SETX MYPATH ~PATH~ – Sets the value of MYPATH to ALWAYS be equal to the value of the PATH environment variable even in the event that the PATH variable changes.

SETX Registry Examples

  • SETX TZONE -k HKEY_LOCAL_MACHINESystemCurrentControlSetControlTimeZoneInforationStandardName – Sets the value of TZONE to the above key ie. “Central Standard Time”
  • SETX BUILD -k “HKEY_LOCAL_MACHINESoftwareMicrosoftWindows NTCurrentVersionurrentBuildNumber” – Sets the value of BUILD to the current Windows NT build ie. “1314”
    Note: Quotes must be used because of the embedded space in “Windows NT”.

SETX File Examples

  • SETX VAR -f ipconfig.out -x – Displays the coordinates for the contents of the file “ipconfig.out”.
  • SETX IPADDR -f ipconfig.out -a 5,11 – Finds value at absolute offset 5,11 of the file ipconfig.out and sets IPADDR to the IP Address (absolute offset 5,11).
  • SETX OCTET1 -f ipconfig.out -a 5,3 -d – Finds value at absolute offset 5,3 and uses “.” as an additional delimiter.  Sets OCTET1 to the first octet of the IP Address
  • SETX IPGATEWAY -f ipconfig.out -r 0,7 “Gateway” – Finds value at relative offset 0,7 to the keyword “Gateway” and sets IPGATEWAY to the first octet of the IP Address
Command Line Command Prompt Linux Windows

Windows Command Prompt: Auto-Complete Paths and Filenames

SUMMARY: Let Windows automatically complete your keyed-in paths and filenames.

If you regularly use the Windows Command (or DOS) Prompt (CMD.EXE), you may find it cumbersome to type in long directories or filenames. With this trick, you can use the TAB key to have Windows automatically complete your path or filename.

For example, if you are at C: and type:

C:>cd doc

Then press the TAB key, Windows will automatically complete the command with:

C:>cd “Documents and Settings”

First you have to make a couple modifications to the Windows Registry (do so at your own risk).

  1. Open Regedit by clicking Start / Run, then type Regedit and press OK (or ENTER). Make sure you are an administrator (especially in Windows 7, Vista and 2008).
  2. Navigate the Registry to My ComputerHKEY_LOCAL_MACHINESoftwareMicrosoftCommand Processor.
  3. In the right pane, double-click “CompletionChar” and key in “9“, then press OK.
  4. Do the same for “PathCompletionChar“.
  5. Close Regedit, then open a new command prompt.
See also: