Основные команды Windows
Основные команды Windows
Важнейшие команды командной строки
| Команда в CMD | Команда в PowerShell | Назначение |
|---|---|---|
| dir | Get-ChildItem | Список файлов и папок |
| cd | Set-Location | Перейти в другую директорию |
| cd | Get-Location | Показать текущую директорию |
| md, mkdir | New-Item -ItemType Directory | Создать директорию |
| rd /s /q | Remove-Item -Recurse -Force | Удалить папку рекурсивно |
| copy | Copy-Item | Копировать файлы |
| move | Move-Item | Переместить файлы |
| type | Get-Content | Прочитать содержимое файла |
| findstr "text" file.txt | Select-String "text" file.txt | Искать текст в файле |
| — | icacls file.txt /grant user:F | Изменить права доступа |
| wmic logicaldisk get size,freespace,caption | Get-PSDrive | Показать информацию о дисках |
| tasklist | Get-Process | Список активных процессов |
| taskkill /PID PID /F | Stop-Process -Id PID | Остановить процесс |
| ping google.com | Test-Connection google.com | Проверить связь с сервером |
| curl https://example.com | Invoke-WebRequest https://example.com | Загрузить данные |
| bitsadmin /transfer job /download /priority normal https://example.com/file.txt C:\file.txt | Invoke-WebRequest https://example.com/file.txt -OutFile file.txt | Скачать файл |
| shutdown /s /t 0 | Stop-Computer | Выключить компьютер |
| shutdown /r /t 0 | Restart-Computer | Перезагрузить компьютер |
| set | Get-ChildItem Env: | Показать переменные окружения |
| set MY_VAR=123 | $env:MY_VAR = "123" | Установить переменную окружения |
| doskey /history | Get-History | Показать историю команд |
| — | Get-Help Get-ChildItem | Получить помощь по команде |
| dir /s *.txt | Get-ChildItem -Recurse *.txt | Поиск файлов |
| cls | Clear-Host | Очистить терминал |
| type nul > file.txt | New-Item file.txt | Создать пустой файл |
| mklink link source | New-Item -ItemType SymbolicLink -Path "link" -Target "source" | Создать символическую ссылку |
| — | Expand-Archive archive.zip -DestinationPath . | Распаковать архив |
| — | winget install package, Install-Package | Установить программу |
| — | Start-Process cmd -Verb RunAs | Выполнить от администратора |
| whoami | whoami | Показать имя текущего пользователя |
| net user %username% | — | Показать группы пользователя |
| net start service | Start-Service service | Запустить службу |
| eventvwr | Get-EventLog -LogName System | Просмотр логов системы |
| date | Get-Date | Показать текущую дату и время |
Работа с файловой системой
dir / Get-ChildItem — просмотр содержимого каталога
CMD
C:\Users\Timur> dir
Volume in drive C has no label.
Volume Serial Number is A1B2-C3D4
Directory of C:\Users\Timur
03/12/2026 10:00 <DIR> Documents
03/12/2026 11:05 <DIR> Downloads
03/12/2026 09:15 128 notes.txt
1 File(s) 128 bytes
2 Dir(s) 20,000,000,000 bytes free
PowerShell
PS C:\Users\Timur> Get-ChildItem
Directory: C:\Users\Timur
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 3/12/2026 10:00 AM Documents
d----- 3/12/2026 11:05 AM Downloads
-a---- 3/12/2026 9:15 AM 128 notes.txt
cd / Set-Location — переход между каталогами
CMD
C:\> cd Users\Timur
C:\Users\Timur>
PowerShell
PS C:\> Set-Location -Path "C:\Users\Timur"
PS C:\Users\Timur>
Краткая форма:
PS C:\> cd C:\Users\Timur
md, mkdir / New-Item -ItemType Directory — создание папки
CMD
C:\Users\Timur> mkdir my_project
C:\Users\Timur> dir
...
<DIR> my_project
PowerShell
PS C:\Users\Timur> New-Item -ItemType Directory -Name "my_project"
copy / Copy-Item — копирование файлов
CMD
C:\Users\Timur> copy notes.txt backup_notes.txt
1 file(s) copied.
PowerShell
PS C:\Users\Timur> Copy-Item -Path "notes.txt" -Destination "backup_notes.txt"
move / Move-Item — перемещение или переименование
CMD
C:\Users\Timur> move old_name.txt new_name.txt
1 file(s) moved.
PowerShell
PS C:\Users\Timur> Move-Item -Path "old_name.txt" -Destination "new_name.txt"
rd /s /q / Remove-Item -Recurse -Force — удаление папки со всем содержимым
CMD
C:\Users\Timur> rd /s /q old_project
PowerShell
PS C:\Users\Timur> Remove-Item -Path "old_project" -Recurse -Force
⚠️ Важно: эти команды необратимы. Удалённые данные нельзя восстановить стандартными средствами.
type / Get-Content — вывод содержимого файла
CMD
C:\Users\Timur> type config.json
{
"port": 8080,
"debug": true
}
PowerShell
PS C:\Users\Timur> Get-Content -Path "config.json"
{
"port": 8080,
"debug": true
}
Поиск и фильтрация
findstr / Select-String — поиск текста в файле
CMD
C:\Users\Timur> findstr "error" app.log
2026-03-10 14:22:01 ERROR Connection timeout
2026-03-11 09:15:33 ERROR Invalid token
PowerShell
PS C:\Users\Timur> Select-String -Pattern "error" -Path "app.log"
Переменные окружения
set / Get-ChildItem Env: — просмотр переменных
CMD
C:\> set
...
USERPROFILE=C:\Users\Timur
USERNAME=Timur
...
PowerShell
PS C:\> Get-ChildItem Env:
Установка переменной
CMD
C:\> set API_KEY=secret123
C:\> echo %API_KEY%
secret123
PowerShell
PS C:\> $env:API_KEY = "secret123"
PS C:\> $env:API_KEY
secret123
Процессы и служебные команды
tasklist / Get-Process — список процессов
CMD
C:\> tasklist | findstr python
python.exe 1234 Console 1 12,345 K
PowerShell
PS C:\> Get-Process -Name python
taskkill / Stop-Process — завершение процесса
CMD
C:\> taskkill /PID 1234 /F
SUCCESS: The process with PID 1234 has been terminated.
PowerShell
PS C:\> Stop-Process -Id 1234 -Force
net user %username% — группы пользователя (только CMD)
C:\> net user Timur
User name Timur
Full Name
Comment
User's comment
Country/region code 000 (System Default)
Account active Yes
Account expires Never
...
Local Group Memberships *Administrators *Users
net start / Start-Service — управление службами
CMD
C:\> net start Spooler
The Print Spooler service is starting.
The Print Spooler service was started successfully.
PowerShell
PS C:\> Start-Service -Name "Spooler"
Сетевые команды
ping / Test-Connection — проверка доступности хоста
CMD
C:\> ping -n 4 google.com
Pinging google.com [142.250.180.78] with 32 bytes of data:
Reply from 142.250.180.78: bytes=32 time=24ms TTL=117
...
PowerShell
PS C:\> Test-Connection -ComputerName google.com -Count 4
curl / Invoke-WebRequest — получение данных из сети
CMD
C:\> curl https://httpbin.org/ip
{
"origin": "192.0.2.1"
}
PowerShell
PS C:\> Invoke-WebRequest -Uri "https://httpbin.org/ip"
Для получения только тела ответа:
PS C:\> (Invoke-WebRequest -Uri "https://httpbin.org/ip").Content
bitsadmin / Invoke-WebRequest -OutFile — загрузка файла
CMD
C:\> bitsadmin /transfer myJob /download /priority normal https://example.com/file.txt C:\file.txt
PowerShell
PS C:\> Invoke-WebRequest -Uri "https://example.com/file.txt" -OutFile "C:\file.txt"
Системные действия
shutdown /s /t 0 / Stop-Computer — выключение
CMD
C:\> shutdown /s /t 0
PowerShell
PS C:\> Stop-Computer
Требует прав администратора.
shutdown /r /t 0 / Restart-Computer — перезагрузка
CMD
C:\> shutdown /r /t 0
PowerShell
PS C:\> Restart-Computer
Архивация и установка ПО
Распаковка архива (PowerShell)
PS C:\> Expand-Archive -Path "archive.zip" -DestinationPath "."
Установка программ (PowerShell)
Через winget:
PS C:\> winget install Git.Git
Через PackageManagement:
PS C:\> Install-Package -Name git -ProviderName winget
Запуск от имени администратора
PowerShell
PS C:\> Start-Process powershell -Verb RunAs
Откроется новое окно PowerShell с повышенными привилегиями.
Логи и диагностика
eventvwr — графический просмотрщик событий (CMD)
C:\> eventvwr
Запускает приложение «Просмотр событий».
Аналог в PowerShell:
PS C:\> Get-EventLog -LogName System -Newest 10
Покажет последние 10 записей из системного журнала.
Работа с дисками и хранилищем
Информация о дисках
CMD (через WMIC)
C:\> wmic logicaldisk get caption, freespace, size
Caption FreeSpace Size
C: 21474836480 53687091200
D: 107374182400 107374182400
Значения указаны в байтах.
PowerShell
PS C:\> Get-PSDrive -PSProvider FileSystem
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
C 32.00 20.00 FileSystem C:\
D 0.00 100.00 FileSystem D:\
Управление правами доступа
icacls — настройка ACL (только CMD)
Предоставить полный доступ пользователю:
C:\> icacls "C:\secure\file.txt" /grant Timur:F
processed file: C:\secure\file.txt
Successfully processed 1 files
F— полный доступ (Full control);- Можно указать группу:
Users:(R)— право на чтение.
Просмотр текущих прав:
C:\> icacls "C:\secure\file.txt"
C:\secure\file.txt NT AUTHORITY\SYSTEM:(F)
BUILTIN\Administrators:(F)
Timur:(F)
Символические ссылки и точки соединения
Создание символической ссылки
CMD
C:\> mklink shortcut.txt original.txt
symbolic link created for shortcut.txt <<===>> original.txt
Для каталогов:
C:\> mklink /D my_docs C:\Users\Timur\Documents
PowerShell
PS C:\> New-Item -ItemType SymbolicLink -Path "shortcut.txt" -Target "original.txt"
Для папок:
PS C:\> New-Item -ItemType Junction -Path "my_docs" -Target "C:\Users\Timur\Documents"
Требуются права администратора при создании ссылок на системные ресурсы или в защищённых каталогах.
Дата, время и локаль
Текущая дата и время
CMD
C:\> date
The current date is: 03/12/2026
Enter the new date: (mm-dd-yy)
C:\> time
The current time is: 14:30:45.12
Enter the new time:
PowerShell
PS C:\> Get-Date
Thursday, March 12, 2026 14:30:45
PS C:\> Get-TimeZone
Id : Russian Standard Time
DisplayName : (UTC+03:00) Moscow, St. Petersburg, Volgograd
BaseUtcOffset : 03:00:00
Изменение времени (требует прав администратора):
PS C:\> Set-Date -Date "2026-03-12 15:00:00"
Поиск файлов
Рекурсивный поиск по маске
CMD
C:\> dir /s *.log
Volume in drive C has no label.
Directory of C:\logs
03/12/2026 10:00 1024 app.log
...
PowerShell
PS C:\> Get-ChildItem -Path "C:\" -Recurse -Include "*.log" -ErrorAction SilentlyContinue
Флаг -ErrorAction SilentlyContinue подавляет ошибки доступа к защищённым каталогам.
История команд
Просмотр истории
CMD
C:\> doskey /history
dir
cd Projects
git status
PowerShell
PS C:\> Get-History
Id CommandLine
-- -----------
1 dir
2 cd Projects
3 git status
Выполнение по ID:
PS C:\> Invoke-History -Id 2
# эквивалентно: cd Projects
Пустые файлы и очистка экрана
Создание пустого файла
CMD
C:\> type nul > empty.txt
PowerShell
PS C:\> New-Item -Path "empty.txt" -ItemType File
Очистка терминала
CMD
C:\> cls
PowerShell
PS C:\> Clear-Host
# или сокращённо:
PS C:\> cls
Запуск служб и проверка их состояния
Проверка статуса службы
PowerShell
PS C:\> Get-Service -Name "Spooler"
Status Name DisplayName
------ ---- -----------
Running Spooler Print Spooler
Остановка:
PS C:\> Stop-Service -Name "Spooler"
Диагностика сети
Просмотр сетевых интерфейсов
CMD
C:\> ipconfig
Windows IP Configuration
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . : home
IPv4 Address. . . . . . . . . . . : 192.168.1.10
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
PowerShell
PS C:\> Get-NetIPConfiguration
Просмотр открытых портов
CMD
C:\> netstat -ano | findstr :80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4567
PID 4567 можно использовать с tasklist для определения процесса.
PowerShell
PS C:\> Get-NetTCPConnection -LocalPort 80
Обновление переменных окружения в сессии
Иногда после установки ПО нужно обновить PATH без перезапуска терминала.
PowerShell
PS C:\> $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Теперь новые пути из системных и пользовательских переменных доступны в текущей сессии.