Sebagian besar dari kita mengandalkan Antarmuka Pengguna Grafis (GUI) karena lebih nyaman daripada menghafal baris perintah tradisional. Namun satu hal yang pasti—Anda tidak dapat melakukan setiap tugas di Windows GUI, dan saat itulah Command Prompt dapat melayani Anda.

Antarmuka baris perintah bawaan ini dapat menghasilkan keluaran langsung menggunakan perintah sederhana dengan sumber daya komputer yang lebih sedikit. Dengan cara ini, Anda tidak perlu menavigasi melalui jendela yang berbeda hanya untuk menyelesaikan satu tugas. Dengan program ini, Anda dapat menjalankan fungsi administratif tingkat lanjut atau memecahkan berbagai masalah Windows sendiri!

Dalam artikel ini, saya akan membahas 50 perintah yang harus Anda ketahui untuk menguasai Command Prompt. Namun jika Anda relatif baru dengan utilitas ini, sebaiknya periksa panduan pemula kami terlebih dahulu.

Perintah Dasar

Sebelum mendalami perintah utama, saya akan mulai dengan perintah dasar. Apakah Anda berencana untuk menggunakan Command Prompt secara ekstensif atau hanya untuk tujuan umum, ini akan berguna.

CommandFungsiclsMenghapus Command Prompt screenexitQuits Command PrompthelpMenyediakan bantuan dengan perintah tertentucdMemindahkan Anda dari satu direktori/drive ke klip lainMenyalin konten ke Windows ClipboardverMenampilkan versi Windows Anda saat ini

CLS

Perintah ini cukup menghapus layar Command Prompt. Jika Anda ingin mengosongkan ruang kerja setelah menjalankan terlalu banyak perintah, ini bisa sangat membantu. Yang harus Anda lakukan adalah mengetik cls dan tekan Enter.

Sintaks: cls

Keluar

Jika Anda berencana untuk menutup aplikasi Command Prompt, Anda tidak perlu memindahkan kursor untuk menekan tombol Tutup. Cukup jalankan perintah keluar dan program berhenti.

Anda juga dapat menggunakan parameter/b untuk keluar dari skrip kumpulan yang dimuat. Dengan cara ini, jendela utama tetap terbuka dan hanya file batch yang keluar. Namun, jika Anda menggunakan parameter di luar skrip, aplikasi CMD akan ditutup.

Sintaks: exit/b [kode kesalahan]
di mana kode kesalahan menentukan kode tertentu nomor

Bantuan

Perintah ini masuk berguna jika Anda menemukan perintah apa pun dan ingin mengetahui fungsinya. Ini memberi Anda sintaks bersama dengan parameter yang berbeda (sakelar).

Jika Anda hanya menjalankan bantuan, ini akan menampilkan daftar perintah umum yang digunakan di Prompt Perintah.

Sintaks: bantuan

Namun, tidak semua perintah mendukung utilitas ini. Dalam hal ini, Anda dapat menggunakan/? parameter dan ini harus bekerja untuk setiap perintah.

Sintaks:/?

CD atau CHDIR

Artinya’Ubah Direktori’dan seperti namanya, mengalihkan Anda dari direktori saat ini berdasarkan jalur yang ditentukan.

Jika Anda hanya menjalankan cd, itu hanya akan menampilkan nama direktori Anda saat ini. Oleh karena itu, penting untuk mempelajari berbagai parameter beserta fungsi dan sintaksnya:

ParameterFungsiSintaks:Menampilkan drive beserta direktori terakhir locationcd ::Membawa Anda ke direktori sesuai lokasi yang ditentukancd :/dMengubah directorycd/d [drivename]:..Membawa Anda ke direktori sebelumnya/root directorycd..

Catatan: perintah chdir dan cd melakukan tindakan yang sama. Jadi, Anda dapat mengubah direktori menggunakan opsi apa pun yang disukai.

Klip

Perintah ini menyalin keluaran yang dijalankan dari perintah tertentu ke papan klip Windows. Dengan cara ini, Anda dapat langsung menyalin data ke program lain mana pun.

Sangat berguna untuk langsung menyalin file teks atau skrip tanpa membukanya. Berikut adalah parameter yang terkait dengannya:

ParameterFungsiSintaksMenyalin output dari perintah tertentu ke papan klip Windows | clipMenyalin konten dari klip file tertentu

Ver

Prompt Perintah menawarkan cara tercepat untuk melihat nomor versi Windows menggunakan perintah sederhana. Dengan cara ini, Anda dapat menentukan apakah versi Windows terbaru diinstal di komputer Anda.

Sintaks: ver

Perintah Sistem

Apakah Anda mencoba mempelajari komputer Anda atau melakukan beberapa tugas terkait sistem , perintah berikut dapat berguna:

CommandFunctionpowercfgMengontrol pengaturan sistem dayashutdownLog off, restart, atau shutdown komputer Anda nama info sistem host komputerMenampilkan informasi mendetail tentang sistem Anda

Powercfg

Utilitas Prompt Perintah ini memungkinkan Anda untuk mengontrol pengaturan daya keseluruhan komputer Anda. Perhatikan bahwa jika Anda menggunakannya tanpa parameter yang sesuai, Anda akan menemukan kesalahan”Parameter tidak valid”. 

Meskipun ada banyak parameter yang tersedia, saya hanya akan membahas yang paling umum di bawah ini. Jika Anda ingin mempelajari lebih lanjut, cukup jalankan powercfg/?. 

ParameterFungsiSintaks/daftar atau/lMenampilkan semua skema daya yang tersediapowercfg/daftar atau powercfg/l/deletesettingHapus pengaturan daya tertentupowercfg/deletesetting /setactiveMembuat skema aktifpowercfg/setaktif /getactiveschemeMengambil skema daya Anda saat inipowercfg/getactivescheme/hibernasi atau/hDigunakan untuk mengaktifkan/nonaktifkan hibernationpowercfg/hibernate [parameter]/availablesleepstates atau/aMenampilkan status tidur yang tersedia di komputer Andapowercfg/availablesleepstates atau powercfg/a/devicequeryMenampilkan perangkat yang memenuhi kriteria yang ditentukan (tanda permintaan)powercfg/devicequery /deviceenablewakeMemungkinkan perangkat yang ditentukan untuk membangunkan komputer dari sleeppowercfg/deviceenablewake /devicedisablewakeMenonaktifkan perangkat untuk membangunkan komputer dari sleeppowercfg/devicedisablewake /lastwakeMenampilkan aktivitas yang terakhir membangunkan sistem Anda dari sleeppowercfg/lastwake

Untuk mempelajari perintah di atas secara detail, saya sarankan untuk menjalankan powercfg/? perintah .

Misalnya, jika Anda ingin mengetahui lebih banyak tentang parameter/list, Anda dapat menjalankan powercfg/list.

Shutdown

Menariknya, Anda dapat mematikan komputer menggunakan satu perintah di Command Prompt. Juga, dimungkinkan untuk menjadwalkan proses shutdown sesuai keinginan Anda.

Berikut beberapa parameter umum yang mungkin berguna:

ParameterFungsiSintaks/iOpens naikkan dialog Remote Shutdownshutdown/i/lLogs Anda outshutdown/l/rRestart komputer Andashutdown/r/aMembatalkan operasi shutdownshutdown/a/hHibernasi komputer Andashutdown/h/t xxxMenyetel periode batas waktu sebelum shutdownshutdown/r/t xxx/fEnds semua aplikasi dan keluar dari komputer Anda menutup/f

Catatan: Menjalankan shutdown tanpa parameter akan menjalankan bantuan atau/? untuk perintah matikan.

Driverquery

Lanjutkan, driver perangkat merupakan komponen integral dari sebuah komputer. Jika Anda mencari informasi tentangnya, kami telah memiliki utilitas Pengelola Perangkat di Windows GUI.

Namun, jika Anda ingin menampilkan informasi driver terperinci saat bekerja pada antarmuka baris perintah, Anda cukup mengetikkan driverquery dan tekan Enter.

Bersamaan dengan itu, Anda dapat menggunakan parameter berikut yang masing-masing memiliki fungsi tersendiri:

ParameterFungsiSintaks/s Menentukan nama dan alamat IP komputerdriverquery Anda/s [sistem]/u Menentukan kredensial pengguna dan hanya dapat digunakan setelah/s ditentukandriverquery/s [sistem]/u [nama pengguna]/p Menentukan kata sandi pengguna dan hanya dapat digunakan setelah/u ditentukandriverquery/s [sistem]/u [nama pengguna]/p [kata sandi]/foMenampilkan keluaran dalam format yang ditentukan–tabel, daftar , atau csv/fo [table “”not found/]
/nh“No header”, artinya header tidak ditampilkan (tidak berfungsi untuk/fo list)driverquery/fo [table “”not found/]
/nh/siDisplays signed driverdriverquery/si/vMenampilkan keluaran verbose (tidak berfungsi untuk driver bertanda tangan)driverquery/v

Hostname

Perintah ini mencetak nama perangkat. Jika Anda tidak yakin dengan komputer Anda atau mencoba mengidentifikasinya di komputer lain, cukup ketik nama host dan tekan Enter di Command Prompt akan menampilkan hasilnya.

Sintaks: nama host

Info sistem

Tidak seperti perintah hostname , ini akan mencetak informasi terperinci tentang komputer Anda. Pada dasarnya, ini seperti meluncurkan aplikasi Informasi Sistem untuk memeriksa spesifikasi PC Anda.

Selain itu, Anda dapat menggunakan parameter yang sama yang digunakan dalam devicequery (/s,/u,/p,/fo,/nh,/si, dan/v) untuk mencetak keluaran dalam format yang Anda inginkan.

Sintaks: systeminfo [parameter]

Perintah Pemecahan Masalah Windows

Jika Anda menghadapi masalah terkait Windows, mungkin ada ada beberapa penyebabnya—drive rusak, file sistem, image, atau lainnya. Biasanya, menjalankan pemecah masalah dan perintah yang berguna dapat memperbaiki masalah, dan itulah yang akan saya bahas di bagian ini.

PerintahFungsichkdskMemeriksa drive disk Anda untuk mengidentifikasi dan memperbaiki kemungkinan kesalahan atau bad sectorsfcMemindai file sistem untuk menentukan file yang rusak dan menggantinya dengan copydism yang di-cacheMengelola imagemsdt.exe Windows-id DeviceDiagnosticStarts Pemecah masalah Perangkat Keras dan Perangkat

CHKDSK

Perintah ini memeriksa disk lokal di komputer dan memberi tahu pengguna tentang kesalahan logis dan fisik . Perhatikan bahwa memperbaiki kesalahan hanya mungkin jika Anda menggunakan parameter berikut dengan bijak.

Di sini, saya hanya membahas yang umum. Namun jika ingin mempelajari lebih lanjut, berikut panduan lengkap cara menjalankan CHKDSK untuk memperbaiki dan memperbaiki harddisk.

ParameterFungsiSintaksMemindai volume yang ditentukanchkdsk :/fMemperbaiki kesalahan pada disk yang terkunci (jika tidak, ini pertama-tama meminta Anda untuk melepaskan volume dan menyelesaikan pemindaian setelah Anda me-restart PC Anda)chkdsk/f/vMenampilkan jalur dan nama setiap file untuk disk FAT/FAT32 dan pesan pembersihan pada NTFSchkdsk/v/rMemperbaiki kesalahan disk fisik dan melakukan semua operasi yang parameter/f melakukanchkdsk/r/xMemaksa volume untuk dilepas sebelum melakukan scanchkdsk/x/iA cara yang lebih cepat untuk memindai kesalahan disk untuk NTFS driveschkdsk/i/offlinescanandfixMelakukan pemindaian offline untuk memperbaiki kesalahan diskchkdsk/offlinescanandfix

SFC

Pemeriksa File Sistem Windows (SFC) membantu Anda memperbaiki file Windows yang rusak. Ini bekerja dengan mengganti file yang rusak dengan salinan yang di-cache, yang bahkan dapat mengoptimalkan kinerja komputer.

Berikut adalah beberapa perintah SFC yang paling sering digunakan:

ParameterFungsiSintaks/scannowAll file sistem dipindai dan diperbaikisfc/scannow/verifyonlySemua file sistem dipindai (tidak ada perbaikan)sfc/verifyonly/scanfileFile sistem yang ditentukan pengguna dipindai dan diperbaikisfc/scanfile=[path file]/verifyfilePengguna-file sistem yang ditentukan dipindai (tidak ada perbaikan) sfc/verifyfile=[jalur file]

DISM

Perintah ini memulai alat Layanan dan Pengelolaan Gambar Penerapan untuk mengonfigurasi fitur dan paket gambar Windows. Ada banyak perintah DISM untuk digunakan saat memecahkan masalah Windows, termasuk FFU, WIM, Imaging, dan lainnya. Tapi saya hanya akan membahas parameter umum.

Demi kenyamanan Anda, kami telah menyediakan panduan mendetail untuk menjalankan berbagai perintah DISM.

ParameterFungsi Sintaks/onlineTargets menjalankan OS dism.exe/online [parameter]/imageMenentukan jalur imagedism.exe Windows offline/image:/list-imageMenampilkan semua file dan folder di imagedism.exe Windows yang ditentukan/list-image ImageFile:/delete-imageMenghapus gambar Windows yang ditentukan dari WIM filingism.exe/delete-image/ImageFile:

Kiat Tambahan: Untuk mempelajari lebih lanjut tentang perintah individual, Anda dapat menjalankan perintah/? parameter di akhir. Misalnya, jika Anda ingin mengetahui lebih lanjut tentang/image, cukup jalankan dism.exe/image/?.

msdt.exe-id DeviceDiagnostic

Pemecah masalah Perangkat Keras dan Perangkat tidak lagi tersedia dengan pemecah masalah lain di Pengaturan Windows. Namun, utilitas dapat menemukan dan memperbaiki masalah terkait dengan semua komponen perangkat keras.

Di Windows 11, Anda dapat meluncurkannya menggunakan perintah msdt.exe-id DeviceDiagnostic di Command Prompt.

Perintah Manajemen File dan Direktori

Mengelola file dan direktori di Command Prompt bisa sedikit rumit. Namun demikian, berikut adalah beberapa perintah dasar yang dapat membuat tugas Anda jauh lebih mudah.

CommandFunctiondirMenampilkan semua file dan folder di dalam direktoricopyCopies file dalam direktori atau dari satu direktori ke direktori lainmemindahkan file dari satu direktori ke direktori laindelMenghapus file atau direktorimkdirMembuat direktori baruMengubah nama filermdirMenghapus direktori yang adatypeMenampilkan konten file teksassocModify file typefcMembandingkan dua file dan menampilkan perbedaannyaattribMengubah atribut direktoritreeRepresentasi grafis dari struktur direktori dari jalur tertentu

DIR

Ini perintah menampilkan semua file dan direktori/subdirektori dari drive/direktori yang ditentukan.

Sebagian besar pengguna menggunakan perintah ini untuk membuat daftar file dan direktori. Ini dimungkinkan dengan hanya menjalankan perintah dir. Bersamaan dengan daftar, itu juga menampilkan label volume, nomor seri, dan jumlah total file dan direktori.

Selain itu, Anda juga dapat menggunakan parameter berikut:

ParameterFungsiSintaksMenampilkan file di dalam drivedir [drive] yang ditentukan:Menampilkan file dari locationdir [path] yang ditentukan:/bMenampilkan daftar item saja tanpa informasi tambahandir/b/sMenampilkan semua file di dalam direktori, subdirektorinya, dan filesdir/s/wMencantumkan semua file dalam format lebardir/w/dSama dengan/w tetapi mengurutkannya berdasarkan columndir/d

Copy

Seperti namanya, perintah ini menyalin file dari satu lokasi ke lokasi lain. Perhatikan bahwa itu hanya akan membuat duplikat alih-alih memindahkannya.

Sintaks: salin [nama file] [jalur]

Misalnya, untuk menyalin file example.txt dari drive D ke folder Contoh di drive yang sama, berikut perintah saya akan menggunakan:

copy example.txt Contoh

Move

Perintah ini berfungsi dengan cara yang sama seperti copy. Namun, perbedaannya adalah sebenarnya memindahkan file dari satu lokasi ke lokasi lain. Ini pada dasarnya adalah teknik potong dan tempel yang kami gunakan di Windows GUI.

Sintaks: pindahkan [nama file] [jalur]

Misalnya, untuk memindahkan file example.txt dari drive D ke folder Contoh di drive yang sama, berikut adalah perintah yang akan saya gunakan:

move example.txt Contoh 

Del atau Erase

Perintah Del dan Erase dapat digunakan untuk menghapus secara permanen file. Artinya, Anda tidak dapat mengambil file kembali dari Recycle Bin.

Sintaks: del [nama file]

Misalnya, untuk menghapus file example.txt secara permanen, berikut perintah yang akan saya jalankan:

del example.txt

Catatan: Meskipun kami belum menentukan parameter dan atribut untuk salin, pindahkan, dan del, Anda dapat mengujinya sendiri menggunakan bantuan atau/? parameter.

MKDIR atau MD

Perintah MKDIR dan MD digunakan untuk membuat direktori (folder) baru. Anda dapat melakukan ini di direktori saat ini atau bahkan di direktori lain secara langsung, artinya Anda tidak perlu pindah ke drive/direktori tertentu untuk membuatnya.

Sintaks: mkdir [path ]\[nama_direktori]

Misalnya, jika saya masuk D drive dan ingin membuat direktori baru, inilah perintah yang akan saya gunakan:

mkdir MyDirectory

Tetapi jika ingin membuat direktori baru di jalur tertentu, inilah yang akan saya jalankan:

mkdir C:\Users\bishu\Desktop\MyDirectory

Rename atau Ren

Perintah Ren atau Rename hanya mengonfigurasi ulang nama file atau direktori. Saat melakukannya, pastikan Anda tidak menduplikasi nama dengan file/direktori lain.

Sintaks: ren [path]/[filename] [new_filename]

Mengambil contoh yang sama seperti di atas, inilah cara saya akan mengganti nama dua file yang telah saya buat sebelumnya:

ren MyDirectory MyDir

ren C:\Users\bishu\Desktop\MyDirectory MyDir

RMDIR atau RD

Itu singkatan dari ‘Hapus Direktori’ dan itulah yang dilakukan oleh perintah. Anda juga dapat menggunakan perintah yang lebih singkat yang melakukan tindakan yang sama–RD.

Berikut adalah semua parameter untuk perintah RMDIR:

ParameterFungsiSintaks\Menghapus direktori sesuai dengan pathrmdir [path]\[dir_name]/sMenghapus direktori beserta semua file di dalamnya (meminta konfirmasi)rmdir/s [path]\[dir_name]/qMenghapus direktori bersama dengan semua file di dalamnya (tidak meminta konfirmasi) rmdir/q [path]\[dir_name]

Sebagai contoh, saya akan menunjukkan cara menghapus file MyDirectory yang Saya buat sebelumnya:

rmdir MyDir

rmdir C:\Users\bishu\Desktop\MyDir

Ketik

Perintah ini digunakan untuk menampilkan konten file teks di Command Prompt. Dengan cara ini, Anda tidak perlu menavigasi ke lokasi tertentu, membuka file, dan menutupnya lagi jika tidak perlu.

Sintaks: ketik [path] [nama file]
Anda dapat melewati [path] jika Anda berada di direktori yang sama dengan file teks.

Asosiasi

Perintah ini digunakan untuk menampilkan atau mengelola asosiasi ekstensi nama file yang berbeda. Perhatikan bahwa Anda memerlukan hak administratif untuk mengubah asosiasi.

Jika Anda hanya menjalankan perintah assoc, utilitas baris perintah mencantumkan semua ekstensi bersama dengan jenis file yang terkait.

Sintaks: assoc

Juga, Anda dapat memeriksa ekstensi file mana yang terkait dengan jenis file individual. Misalnya, Anda dapat mengetahui semua ekstensi yang terkait dengan’sysfile’seperti yang ditunjukkan pada contoh di bawah ini.

Sintaks: assoc | find “[filetype]”

Contoh:assoc | find “sysfile”

Asosiasi juga dapat dimodifikasi. Anda dapat mengaitkan ekstensi file apa pun dengan jenis file apa pun yang Anda inginkan.

Sintaks: assoc=

Contoh: assoc.abc=sysfile

Terakhir, Anda bahkan dapat menghapus asosiasi. Namun, Anda harus me-restart komputer Anda untuk menerapkan perubahan.

Sintaks: assoc [ekstensi]=

Contoh: assoc.abc=

FC

FC adalah singkatan dari “File Compare”dan kedengarannya, ini digunakan untuk membandingkan dua file sehingga Anda dapat mempelajari tentang perbedaan mereka. Seperti yang ditunjukkan dalam demonstrasi di atas, saya telah membandingkan dua file teks untuk mengetahui perbedaan item di dalamnya.

Sintaks: fc [file1] [file2]

Berikut adalah beberapa parameter yang berguna untuk perintah FC:

ParameterFungsiSintaks/bComparison dalam mode biner fc /b/cMengabaikan huruf besar-kecil selama perbandinganfc /c/nMenampilkan nomor barisfc /n/uPerbandingan teks Unicode filesfc /u/wMengabaikan spasi berurutan saat membandingkanfc /w

Attrib

Perintah ini mengelola atribut untuk file dan folder. Anda dapat mengatur atribut apa pun yang Anda inginkan—Hidden, Read-Only, System, dan lainnya. Untuk menyetel atribut, gunakan’+’dan untuk menghapus, gunakan’-‘.

Sintaks: attrib [+/-][attribute_value] [nama file/folder]

Nilai AtributDeskripsiHHiddenRRead-onlyAArchiveSSystemOOfflineINon konten IndexedXNo scrubVIntegrityPPinnedUUnpinnedBSMR Blob

Catatan: Saya belum menyebutkan parameter untuk attrib (/s,/d, dan/l). Anda dapat menggunakan/? beralih untuk mempelajari lebih lanjut tentang mereka.

Pohon

Jika Anda ingin untuk melihat subdirektori di dalam direktori atau drive, perintah pohon akan membuatnya terlihat menyenangkan secara grafis. Ini menyusun dokumen dalam format yang mudah dilihat. Yang harus Anda lakukan adalah menjalankan perintah pohon dan menentukan jalur jika diperlukan.

Sintaks: tree [path]

Di bawah ini adalah dua parameter yang dapat Anda adopsi dengan perintah tree:

ParameterFungsiSintaks/aMenampilkan baris menggunakan karakter teks, bukan representasi grafistree /a/fMenampilkan semua item di drive/directorytree /f

Perintah Manajemen Disk/Drive

Seiring dengan manajemen file dan direktori, Anda juga dapat mengonfigurasi disk dan drive di Command Prompt.

Berikut adalah 7 perintah yang paling sering digunakan untuk tujuan ini:

PerintahFungsivolMenampilkan label volume disk dan format nomor seriFormat a drive tertentu dalam sistem file yang ditentukandiskpartMengelola partisi drive penyimpanandefragMendefragmentasi hard drive tertentudiskusageMenampilkan jumlah ruang kosong dan terpakai yang tersedia pada disk tertentu

Vol

Ini adalah perintah untuk memeriksa nama volume atau nomor seri dengan cepat. Yang harus Anda lakukan adalah mengeksekusi vol dengan huruf drive.

Sintaks: vol [dirve_letter]:

Format

While there already exists easy-to-use GUI applications for formatting your disk drives, it’s never a bad idea to learn this on Command Prompt.

If you want to format a hard drive having just one partition, the format command should work out for you. However, the better option would be using diskpart, which I shall discuss below.

Here, I’ll only mention the common parameters. Nonetheless, you can go through the other guide that should help you format a hard drive from CMD in detail.

ParametersFunctionsSyntax/vSpecifies the volume label of the drive you’re trying to formatformat/v:

Diskpart

This is a command-line interpreter that offers disk management features on Command Prompt. With this utility, you can assign drive letters, manage the drive attributes, configure partitions, display disk information, format a drive, and much more.

Type diskpart and this should launch the interpreter. However, you require administrative privilege to use it.

In the table below, I have mentioned the most used commands in Diskpart. If you wish to learn more about disk partitions using the diskpart command, you can check out our dedicated guides for both HDD and SSD.

CommandFunctionsSyntaxlistDisplays the volumes, disks, partitions, or virtual disks based on the parameter specifiedlist selectSelects a volume, disk, partition, or virtual disk based on the parameter specifiedselect createCreates a volume, partition, or virtual disk file based on the parameter specifiedcreate assignAssign a drive letter or mount point to the selected volumeassign formatFormats a diskformat exitExits the Diskpart interpreterexit

Defrag

Defragmentation simply means reorganizing the data inside an HDD to achieve better performance (not recommended on SSD).

Like any other action, Windows already offers a dedicated utility.

However, if you wish to know this in detail, Command Prompt offers tons of parameters that should help you out. Note that this command requires administrative privilege.

ParametersFunctionsSyntax:Defrags the specified drive (traditional defragmentation, default parameter is set to/d)defrag :/aAnalyzes the selected drivedefrag :/a/bPerforms boot optimization on the selected drivedefrag :/b/cRuns operations on all the volumesdefrag :/c/hRuns operations in normal prioritydefrag :/h/uPrints the progressdefrag :/u

Diskusage

This might not be the most used command but is definitely worth it. You can get the summarized details on the selected disk’s usage in no time.

Simply executing the diskusage command should do the job (note that you need to open CMD as an administrator). Along with that, you can take a look at the following parameters that might be beneficial:

ParametersFunctionsSyntax/cDisplays the result in CSV formatdiskusage/c :/hDisplays the result in human-readable formatdiskusage/h :/s Displays size for system files onlydiskusage/s :

Networking Commands

Unlike others, networking commands are widely used mainly for troubleshooting purposes. In fact, fetching IP addresses or configuring network settings is much easier on Command Prompt than using GUI components.

If you’re a networking enthusiast, here are the commands that you need to focus on: 

CommandFunctionnetManage network and its settingsipconfigDisplays detailed information about your network configurationnetshStarts the Netsh prompt that lets you manage network configurationsnetstatDisplays active network connectionspingVerifies IP-level connectivity and reachabilitytracertChecks the computer’s path to connect to the networkpathpingTraces the route to the target and also displays the statistics (combination of ping and tracert)getmacDisplays the MAC addressnslookupDisplays the information about domain names and IP addresses

Net

You can use this command to manage different networking services. It comes with multiple options each performing a specialized task.

Here, I’ve only mentioned the most common ones. You can execute the net command without a parameter to get more.

OptionFunctionaccountsConfigures login requirementscomputerManages computers in the domaincontinueRestarts a servicestartStarts a networking servicestopStops a networking serviceviewDisplays all the devices in a networkstatisticsDisplays network statistics

Ipconfig

This command is for network configuration and management. You can view the detailed Windows TCP/IP information, release/renew IP addresses, flush the DNS cache, and much more.

Executing ipconfig without parameters displays the IPv4, IPv6, subnet mask, and default gateway for every adapter. For other purposes, you can adopt the following parameters:

ParametersFunctionsSyntax/allDisplays TCP/IP configuration for all adaptersipconfig/all/flushdnsFlushses the DNS client resolver cacheipconfig/flushdns/release Releases the DHCP configuration for the specified adapter (you can simply execute the/release parameter to release the configuration for all the adapters at once)ipconfig/release /renew Renews DHCP configuration for the specified adapter (if not specified, renews for all the adapters)ipconfig/renew

Netsh

This is another essential networking command used for managing network configurations. You can execute netsh to launch the dedicated shell. After that, you can perform desired networking operations using some of the well-known parameters from the below table:

CommandsFunctionsdhcpclientManages the DHCP client servicednsclientManages DNS client settingsfirewallManages the Windows firewall serviceinterfaceManages physical or virtual network adapterslanManages LAN settings on your computerwlanManages wireless network settings on your computernamespaceManages namespace configurationsofflineSets the mode to offlineonlineSets the mode to onlinequit/exit/byeExits the Netsh shellwinsockManages Winsock settings

Additional Tip: You can further learn about each of the above command’s arguments using ? in the netsh shell or use the/? parameter with the netsh command.

Netstat

This command lists the active connections on your computer. It displays the protocol, local as well as foreign address, and the current state. Just executing the netstat command will list the active TCP connections.

To display other protocols, here are some parameters you can use:

ParametersFunctionsSyntax-aDisplays all the active TCP and UDP connections netstat-a-bDisplays all active connections along with each process (requires admin privilege)netstat-b-eDisplays the interface statisticsnetstat-e

Ping

This command is widely used for testing host-server reachability and internet connectivity. Executing ping displays the IP address statistics and the approximate round trips in milliseconds.

Here are a few parameters that I recommend trying out: 

ParametersFunctionsSyntax-tContinues displaying stats until interrupted by pressing CTRL+Cping-t -nDisplays stats based on the specified number of echo Request messagesping-n -lDisplays stats based on the specified lengthping-l

Tracert

This command traces the route to a certain IP or domain by sending ICMP or ICMPv6 messages with increasing TTL values. It’s extremely useful during network troubleshooting as it informs users about the routing issues and validates the network paths.

Implementing the tracert command without a parameter traces the route of the specified domain/IP over a maximum of 30 hops.

Nevertheless, you could make use of the following parameters to gain additional networking information:

ParametersFunctionsSyntax-hDisplays results in ‘n’ no. of maximum hops specifiedtracert-h -dDoesn’t resolve IP address making the results appear much fastertracert-d -wSpecifies the maximum time to wait for echo Reply message (if not, displays *)tracert-w -4Uses IPv4 to trace the routetracert-4 -6Uses IPv6 to trace the routetracert-6

Pathping

This command is a combination of Tracert and Ping. When executed without a parameter, it traces the route to the target over a maximum of 30 hops and computes statistics for 125 seconds (by default).

Here are some of the most used pathping parameters:

ParametersFunctionsSyntax-hDisplays results based on the maximum hops specifiedpathping-h -pWaits between consecutive pings before displaying the statspathping-p -wSpecifies the maximum time to wait for each replypathping-w -4Only uses IPv4pathping-4 -6Only uses IPv6pathping-6

Getmac

If you wish to get the MAC address of your computer, you can execute the getmac command and this will display the result in no time. The result includes both the physical address and the transport name.

Along with that, I highly recommend trying out the following parameters:

ParametersFunctionsSyntax/s Displays the results for the specified computer name of IP addressgetmac/s /fo

Displays in the specified formatgetmac/fo

/nhDisplays in the table or CSV format excluding the column headergetmac/nh

NSLookUp

This is yet another command-line utility that includes numerous commands to obtain domain name or IP address information. To start the prompt, simply type nslookup in the Command Prompt and hit Enter.

While there are countless parameters for nslookup, I’m only going to focus on a few common ones in the table below:

CommandsFunctionsfingerConnection with finger serverlsDisplays DNS domain informationlserverChanges default server to the specified DNS using current serverserverChanges server to the specified DNS using default serversetDifferent parameters (all, class, d2, etc.) are used to set various DNS-related settings

Miscellaneous

If you have implemented each of the commands I’ve discussed, you should now be proficient enough to use Command Prompt. However, the aforementioned commands are not enough to master this Windows command-line interface.

There are thousands more, and it’s impossible for me to include all of them in this single post.

For now, I would recommend trying out the following commands that could come in handy while you’re on the way to mastering Command Prompt:

CommandFunctiontasklistDisplays all the currently running processestaskkillKills a processpowershellStarts Windows PowerShell sessionsetManages Windows environment variablesstartRuns the specified programbcdbootRepairs the boot environmentdateDisplays today’s datepromptChanges the cmd textcolorCustomizes foreground and background color

Tasklist

You can use this command to display the currently running processes on your computer. Executing tasklist lists down the name of the process, its PID, session name, session number, and memory usage. Also, you can try out the following parameters:

ParametersFunctionsSyntax/s Displays all the processes of the specified computer name or IP addresstasklist/s /mDisplays all the modules of currently running processestasklist/m/fo

Displays the results in a specified formattasklist/fo

/nhDisplays the results in table or CSV format without the header columntasklist/nh/svcDisplays all the services associated with the currently running processestasklist/svc

Taskkill

While the tasklist command displays the processes, taskkill kills/ends them. You can use either process ID or image name to do this task. Therefore, you need to utilize any of the following common parameters:

ParametersFunctionsSyntax/pid Kills the process as per the specified process IDtaskkill/pid /im Kills the process as per the specified image nametaskkill/im /fEnds the process forcefullytaskkill/f /tEnds the process along with all the child processestaskkill/t

Powershell

If you prefer Windows PowerShell over CMD, you can actually run the Command Prompt as a Powershell window. Just type powershell and hit Enter. You’ll likely get the PS prefix indicating that you can now run all the Powershell cmdlets here.

Syntax: powershell

Set

This command is used for configuring the Windows environment variables. To display all the available ones, you can use the set command without any parameters. In order to set a new environment variable, you can use a variable name and provide the necessary value.

Syntax: set [variable_name]=[value]

Likewise, it’s possible to delete any environment variable too. Below is the syntax that should clear your doubt.

Syntax: set [variable_name]=

The set command on Command Prompt has the following two parameters with individual functionality:

ParametersFunctionsSyntax/aSets the variable name as a line of inputset/a =/pSets the value as a numerical expressionset/p =

Start

You can use this command to launch a new Command Prompt window. Without the use of any parameter, it will simply launch the new prompt. However, utilizing the following parameters can help you perform just more than that:

ParametersFunctionsSyntax“title”Launches the CMD window with the specified titlestart ““/d Starts the CMD window with the specified pathstart/d or Launches the CMD windows in restored or maximized windowstart /waitStarts the application and waits for it to end (meaning you cannot execute further commands in the main prompt)start/wait

BCDBoot

Most users utilize this command to repair the boot environment from the Windows Recovery Environment. It works by copying the Windows installation files to a system partition. You need to execute bcdboot with the following parameters:

ParametersFunctionsSyntax/lSpecifies an optional language during BCD store initializationbcdboot/l  /sSpecifies the system partition’s label where the BCD files will be copied tobcdboot/s /dPreserves the existing default windows boot entrybcdboot/d /bcdcleanCleans the BCD storebcdboot/bcdclean

Date

This is another useful command to quickly check the current date. You can display or set a new date as per your requirement. If you execute just the date command, the prompt displays the date and asks you to set a new one. But if you quickly want to check the date, use the/t parameter.

Syntax: date/t

Prompt

This command offers customization of the text that appears in front of the cursor (by default, it’s the current directory path).

You can change this to any character string of your choice or predefined characters (like current date, drive, path, times, windows version, etc.) using special codes. You can check using the/? Parameter. To switch back to the normal format, execute the prompt without any parameters.

Syntax: prompt [text/special_code]

Color

Certainly, you have thought of customizing the Command Prompt. To your surprise, it’s possible to tweak the default black (background) and white (foreground/text) combination. For this, you require specifying two hex digits—the first representing the background and the second corresponding to the text.

Syntax: color [hexcode]

Hex DigitColor0Black1Blue2Green3Aqua4Red5Purple6Yellow7White8Grey9Light BlueALight GreenBLight AquaCLight RedDLight PurpleELight YellowFBright White

As per the above table, let’s say you want a red background with light blue text. So, you’ll have to execute the following command:
color 49

While you’re at it, note that you cannot set the same background and foreground colors. Even if you do it, the command will not execute and you’ll be left with the existing combination.

To switch back to default, run the color command without any parameter.

Categories: IT Info