Commands tagged windows (84)

  • Functionally the same as the Microsoft Robocopy (https://en.wikipedia.org/wiki/Robocopy) command below but with the benefits of compression and optionally specifying a user. robocopy /e [//host]/source/path [//host]/destination/path Options: -a: archive mode - rescursive, copy symlinks as symlinks, preserve permissions, preserve modification times, preserve group, preserve owner, preserve device files and special files -hh: Numbers in human-readable K=1024 format. Single "h" will produce human-readable K=1000 format -m: don't copy empty directories -z: use compression (if both source and destination are local it's faster to omit this) --progress: Shows progress during the transfer and implies --verbose (verbose output) --stats: Summary after the transfer stops Show Sample Output


    0
    rsync -ahhmz --progress --stats [[user@]host:]/source/path/ [[user@]host:]/destination/path/
    juangmorales · 2014-11-13 18:52:45 20
  • Also resolves hostname


    0
    nslookup . ifcfg.me
    Eun · 2014-11-17 09:35:28 7

  • 0
    netstat -anop tcp | find ":8010"
    ferantivero · 2014-12-23 13:04:54 8
  • IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type powershell Create a log file of your Motorola Surfboard SB6141 downstream signal strengths. Uses the built-in curl to request signal strength data from your SB6141 cable modem. HTML page 192.168.100.1/cmSignalData.htm has the signal strength numbers for the 8 downstreams. Some HTML/DOM processing parses out the 8 values from the above page. The eight extracted signal strengths are then logged to a file. A small while-loop watches the clock & repeats the process every 10 seconds. Show Sample Output


    0
    while(1){while((date -f ss)%10-gt0){sleep -m 300} echo "$(date -u %s) $((curl 192.168.100.1/cmSignalData.htm).parsedhtml.body.childnodes.item(1).firstchild.firstchild.childnodes.item(5).outertext|%{$_ -replace '\D+\n',''})">>modemlog.txt;sleep 1;echo .}
    omap7777 · 2015-12-24 02:12:10 11
  • IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type powershell Uses sajb to start a PowerShell background job that pings an IP host every 10 seconds. Any changes in the host's Up/Down state is time-stamped and logged to a file. Date/time stamps are logged in two formats: Unix and human-readable. A while(1) loop repeats the test every 10 seconds by using the sleep command. See the Sample Output for more detail. I use this command to log Up/Down events of my Motorola SB6141 cable modem (192.168.100.1). To end the logging, close the PowerShell window or use the "exit" command. Show Sample Output


    0
    sajb {$ip="192.168.100.1";$old=0;while(1){$up=test-connection -quiet -count 1 $ip;if($up-ne$old){$s=(date -u %s).split('.')[0]+' '+(date -f s).replace('T',' ')+' '+$ip+' '+$(if($up){'Up'}else{'Down'});echo $s|out-file -a $home\ping.txt;$old=$up}sleep 10}}
    omap7777 · 2015-12-28 20:33:08 15
  • List local accounts and their SIDs (*-500 is the original local Administrator, *-501 is the original local Guest, more below). This is helpful in identifying local accounts that are not disabled, don't have an expiring password, etc. Well-Known SIDs https://support.microsoft.com/en-us/kb/243330 Show Sample Output


    0
    wmic useraccount WHERE "LocalAccount=1" GET Name,Disabled,Lockout,PasswordChangeable,PasswordExpires,PasswordRequired,SID
    Xeleema · 2015-12-29 18:01:42 10
  • Unblock multiple windows files using Powershell. -Recurse is optional to apply to all directories recursively.


    0
    dir c:\mydir -Recurse | Unblock-File
    Denhams · 2016-02-12 17:02:14 22
  • Commandline for windows + cygwin with specific interface and resolved ip.


    0
    ssh root@server.com "tcpdump -i INTERFACE_NAME -U -nnn -s0 -w - 'port 80'" | /cygdrive/c/Program\ Files/Wireshark/Wireshark.exe -N mnNtCd -k -i -
    artembeloglazov · 2016-03-02 13:42:29 12
  • The Windows Subsystem for Linux (WSL) is a compatibility layer for running binary Linux executables natively in Windows. A folder such as "C:\Program Files (x86)\Common Files" is represented as "/mnt/c/Program Files (x86)/Common Files". This function allows you to change the current directory to a Windows folder. Show Sample Output


    0
    function _cd() { local dir; dir="$(sed -e 's~\([a-z]\):~/mnt/\L\1~gi' <<< "${*//'\'/"/"}" )"; if [ -d "$dir" ]; then cd "$dir" || exit; fi; }
    mikhail · 2019-06-06 17:53:28 41
  • Lower PowerShell priority, so that to launch processes in the background and work normally with other applications Show Sample Output


    0
    PS> Get-WmiObject Win32_process -filter 'name = "powershell.exe"' | Foreach-Object { $_.SetPriority(16384) }
    pascalvaucheret · 2022-06-16 14:53:28 386
  • Bulk downloads the comic strip JPG files for the adult cartoon Savitabhabhi, storing each set in it's own folder. Requires manual removal of "non-image" files that maybe created because each series may differ in length. The command can be easily adapted for UNIX flavours. You need to have cURL in your path.


    -1
    for /L %%x in (1,1,16) do mkdir %%x & curl -R -e http://www.kirtu.com -o %%x/#1.jpg http://www.kirtu.com/toon/content/sb%x/english/sb%x_en_[001-070].jpg
    MyTechieself · 2009-12-08 15:01:16 8
  • Usually the MS-DOS cmd.exe processes in the whole FOR loop as one command and expands each var like %varname% in before (except the loop var of course). This command enables expansion of other vars than only the loop var during the FOR loop. The syntax of the var to expand is then !varname! inside the FOR loop. Use command endlocal to end the setlocal command. E.g. (only works from batch files, not from commandline directly): @echo off setlocal enabledelayedexpansion FOR %%A IN (*) DO ( set file=%%A echo !file! ) endlocal


    -1
    setlocal enabledelayedexpansion
    Marco · 2010-08-10 12:26:43 6
  • The command line can be accessed by using the cmd command which will open a command window with a DOS interface. The command line is a throw back to the early days of computing before there was a Windows interface. Show Sample Output


    -1
    echo %logonserver%
    0disse0 · 2011-06-13 09:52:51 6

  • -1
    sed 's/.$//' Win-file.txt
    totti · 2011-09-15 19:07:51 4
  • This command should be copy-pasted in Windows, but very similar one will work on Linux. It uses wget and sed.


    -1
    wget --no-check-certificate https://code.google.com/p/msysgit/downloads/list -O - 2>nul | sed -n "0,/.*\(\/\/msysgit.googlecode.com\/files\/Git-.*\.exe\).*/s//http:\1/p" | wget -i - -O Git-Latest.exe
    michfield · 2012-11-14 08:17:50 8

  • -1
    cls && ipconfig | findstr -R "[ IPv4 | adapter ]"
    sameer666 · 2013-12-03 13:29:30 5
  • also shows the ethernet adapter Show Sample Output


    -1
    cls && ipconfig | findstr -R "[ IPv4 | adapter ]"
    sameer666 · 2013-12-03 13:31:00 6

  • -1
    net user USERNAME /domain
    shawn_abdushakur · 2014-01-02 20:22:46 7

  • -1
    %0 | %0
    imjoseangel · 2017-05-17 14:17:01 22
  • Loops over array of a system var, splits its values and puts the values into %A, %B, %C, %D, and so on. Create array before, like set ARRAY[0]=test1,100 and set ARRAY[1]=test2,200 Be sure to replace %A, %B, etc. with %%A, %%B, etc. when using this from inside of batch files. Show Sample Output


    -2
    FOR /F "tokens=3* delims=[]=," %A IN ('SET ARRAY[') DO ( echo %A -- %B )
    Marco · 2010-08-10 12:12:27 5
  • How to add an "alternate access mapping" from the command line and avoid passing on Friday evening following the interpretation of the all-too-terse "log" of SharePoint?


    -2
    stsadm -o addalternatedomain -url http://paperino.paperopoli.com -urlzone Internet -incomingurl http://quiquoqua.paperopoli.com
    0disse0 · 2011-07-09 11:32:45 3
  • Interacting with Active Directory to add users from one group to another group. This prevents from having to deal with long DNs and copying, pasting problems. It executes once per returned object.


    -3
    for /F "DELIMS=""" %i in ('dsquery group -name SourceGroupName ^| dsget group -members') do dsquery group -name TargetGroupName | dsmod group -addmbr %i
    miketheman · 2009-09-25 16:32:33 10
  • This command defragment the SQLite databases found in the home folder of the current Windows user. This is usefull to speed up Firefox startup. The executable sqlite3.exe must be located in PATH or in the current folder. In a script use: for /f "delims==" %%a in (' dir "%USERPROFILE%\*.sqlite" /s/b ') do echo vacuum;|"sqlite3.exe" "%%a" Show Sample Output


    -3
    for /f "delims==" %a in (' dir "%USERPROFILE%\*.sqlite" /s/b ') do echo vacuum;|"sqlite3.exe" "%a"
    vutcovici · 2010-01-18 20:56:00 6
  • This command loops over all indexes of the system variable array ARRAY[] and puts its content into %A. Create this array before, e.g. by set ARRAY[0]=test1 and set ARRAY[1]=test2 For using inside of a batch file, write %%A instead of %A. Show Sample Output


    -3
    FOR /F "tokens=3* delims=[]=" %A IN ('SET ARRAY[') DO ( echo %A )
    Marco · 2010-08-10 12:08:26 4
  • wmi

    Get windows version with servicepack and hostname Show Sample Output


    -3
    wmic -U DOMAIN/user --password='password' //IP_HOST "select Caption,CSDVersion,CSName from Win32_OperatingSystem" | grep Windows
    dr_gogeta86 · 2010-09-20 14:23:37 132
  •  < 1 2 3 4 > 

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Transfer SSH public key to another machine in one step
This command sequence allows simple setup of (gasp!) password-less SSH logins. Be careful, as if you already have an SSH keypair in your ~/.ssh directory on the local machine, there is a possibility ssh-keygen may overwrite them. ssh-copy-id copies the public key to the remote host and appends it to the remote account's ~/.ssh/authorized_keys file. When trying ssh, if you used no passphrase for your key, the remote shell appears soon after invoking ssh user@host.

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

Read aloud a text file in Mac OS X

Count number of files in a directory
Just want to post a Perl alternative. Does not count hidden files ('.' ones).

Download all PDFs from an authenificated website
Replace *** with the appropiate values

Multi-thread any command
For instance: $ find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8 will encode all .wav files into FLAC in parallel. Explanation of xargs flags: -P [max-procs]: Max number of invocations to run at once. Set to 0 to run all at once [potentially dangerous re: excessive RAM usage]. -n [max-args]: Max number of arguments from the list to send to each invocation. -0: Stdin is a null-terminated list. I use xargs to build parallel-processing frameworks into my scripts like the one here: http://pastebin.com/1GvcifYa

disable caps lock
a quick one-line way to disable caps lock while running X.

Image to color palette generator
Extract a color palette from a image useful for designers. Example usage: $extract-palette myawesomeimage.jpg 4 Where the first argument is the image you want to extract a palette from. The second argument is the number of colors you want. It may be the case where you want to change the search space. In that case, change the -resize argument to a bigger or smaller result. See the ImageMagick documentation for the -resize argument.

Setting reserved blocks percentage to 1%
According to tune2fs manual, reserved blocks are designed to keep your system from failing when you run out of space. Its reserves space for privileged processes such as daemons (like syslogd, for ex.) and other root level processes; also the reserved space can prevent the filesystem from fragmenting as it fills up. By default this is 5% regardless of the size of the partition. http://www.ducea.com/2008/03/04/ext3-reserved-blocks-percentage/

Show apps that use internet connection at the moment.
show only the name of the apps that are using internet


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: