ipconfig.co.uk

Opening a command line and running your first network command

Every guide on this site assumes you have a prompt in front of you. If you have never opened one, or you typed ipconfig into the Start menu and a black window vanished before you could read it, start here.

Windows

Open a Command Prompt

  • Fastest: press Win+R, type cmd, press Enter.
  • From Start: press Win, type cmd or Command Prompt, press Enter.
  • Windows Terminal (Windows 11, and Windows 10 with the Store app): press Win+X then I. It opens PowerShell by default; the dropdown arrow on the tab bar offers Command Prompt.
  • In a folder: in File Explorer click the address bar, type cmd, press Enter. The prompt opens in that folder, which is handy for saving output there.
  • PowerShell: Win+X then I, or Start › type PowerShell. Everything on this site written for Command Prompt also works in PowerShell, because ipconfig, netsh, ping and friends are ordinary programs.

Run as administrator

Commands that change things (ipconfig /release, /renew, netsh setters, route add) need an elevated prompt. Any of these gives you one:

  • Win+X then A (Terminal or PowerShell as Admin).
  • Start › type cmd › press Ctrl+Shift+Enter instead of Enter.
  • Right-click the Start button › Terminal (Admin).
  • In an existing PowerShell: Start-Process cmd -Verb RunAs.

Accept the User Account Control prompt. The title bar then says Administrator:. If you are not an administrator on the machine, you will be asked for an administrator's password, and without one the elevated commands are simply unavailable to you.

The window that flashes and disappears

If you type ipconfig into the Run dialog or the Start search, Windows runs it in a new window that closes the instant it finishes. Open a prompt first and type the command inside it, or run cmd /k ipconfig /all from the Run dialog: /k keeps the window open.

Copying and saving output

Windows · Command Prompt
ipconfig /all | clip                       # copy to the clipboard, then paste anywhere
ipconfig /all > %USERPROFILE%\Desktop\ipconfig.txt   # save to a file on the Desktop
ipconfig /all >> log.txt                   # append to a file
ipconfig /all | more                       # page through long output; space for next page, q to quit
ipconfig /all | findstr /i "ipv4 gateway"  # show only matching lines

To copy by mouse in Command Prompt: drag to select, then press Enter or right-click (QuickEdit mode is on by default in Windows 10 and 11). In Windows Terminal, selecting text copies it automatically and right-click pastes. Ctrl+C copies in Windows Terminal but interrupts a running command in a classic Command Prompt with nothing selected.

macOS

Open Terminal

  • Press Cmd+Space, type Terminal, press Return.
  • Or Finder › Applications › Utilities › Terminal.
  • Or Launchpad › Other › Terminal.

The prompt ends in % (zsh, the default since macOS 10.15) or $ (bash on older systems). Either is fine for everything here.

Administrator commands: sudo

Prefix a command with sudo and enter your login password when asked. Nothing appears as you type the password; that is normal. Your account must be an administrator (System Settings › Users & Groups). The first time, macOS prints a short lecture about responsibility. A sudo session lasts five minutes before it asks again.

macOS · Terminal
sudo ipconfig set en0 DHCP
sudo -i        # a root shell, when you have several commands to run; type exit to leave

Copying and saving output

macOS · Terminal
ifconfig | pbcopy                    # copy to the clipboard
ifconfig > ~/Desktop/ifconfig.txt    # save to the Desktop
ifconfig | less                      # page; q to quit
ifconfig | grep inet                 # filter
ifconfig 2>&1 | tee ~/Desktop/out.txt   # show and save at the same time

Cmd+C and Cmd+V work normally in Terminal. Ctrl+C stops a running command such as ping.

Linux

Open a terminal

  • Ctrl+Alt+T on Ubuntu, Mint, Pop!_OS, Fedora GNOME (many desktops honour this).
  • Press Super and type terminal, konsole (KDE) or xterm.
  • Right-click on the desktop or in a file manager folder › Open in Terminal.
  • No desktop, or the desktop is broken: Ctrl+Alt+F3 switches to a text console; Ctrl+Alt+F1 or F2 returns.
  • Over the network: ssh user@hostname from any other machine, including Windows 10 and 11, which have an SSH client built in.

Root commands: sudo

Same as macOS: prefix with sudo. On Ubuntu and most desktop distributions the first user created is a sudoer. On Debian, Alpine and some servers you may need su - and the root password instead. user is not in the sudoers file means your account has not been granted sudo.

Copying and saving output

Linux · Terminal
ip addr > ~/ipaddr.txt
ip addr | less
ip addr | grep inet
ip addr | xclip -selection clipboard    # X11, if xclip is installed
ip addr | wl-copy                       # Wayland, if wl-clipboard is installed
sudo ip link set eth0 up 2>&1 | tee -a ~/netlog.txt

In most Linux terminals copy is Ctrl+Shift+C and paste is Ctrl+Shift+V, because plain Ctrl+C interrupts the running command. Selecting text with the mouse also copies it to the "primary" selection, pasted with the middle mouse button.

Shell habits that save time

HabitWindowsmacOS / Linux
Repeat the last command then Enter; F7 shows history in cmd; history; Ctrl+R to search
Complete a nameTabTab
Stop a running commandCtrl+CCtrl+C
Clear the screenclsclear or Ctrl+L
Built-in helpipconfig /?, netsh /?, helpman ip, ip help, ifconfig -h, command --help
Run two commands in sequenceipconfig /release && ipconfig /renewsudo ip link set eth0 down && sudo ip link set eth0 up
Which shell am I in?echo %COMSPEC% (cmd) or $PSVersionTable (PowerShell)echo $SHELL, echo $0
Where am I?cd with no argumentspwd
Which user am I?whoamiwhoami, id
Case sensitivityCommands and switches are not case-sensitiveEverything is case-sensitive: ip Addr fails

Things that trip people up

  • Slashes and dashes. Windows switches use / (ipconfig /all); Unix options use - (ifconfig -a). Windows also accepts -all; Unix never accepts /a.
  • Quotes. Adapter and service names with spaces must be quoted: ipconfig /renew "Local Area Connection", networksetup -getinfo "Wi-Fi".
  • The prompt is part of the example, not the command. If a guide shows C:\> ipconfig, $ ip addr or % ifconfig, type only what follows the prompt. On this site the copyable blocks never include prompts.
  • PowerShell aliases. In PowerShell, ls, cat and curl are aliases for PowerShell cmdlets and behave differently from their Unix namesakes. curl.exe forces the real program.
  • Typing a password. sudo shows nothing while you type. Press Enter when done.
  • Nothing happened? Many Unix commands print nothing on success (ip link set eth0 up). Check with echo $?: 0 means it worked.
  • Windows 10 vs 11 menus. Menu names in Settings differ between versions and between Home and Pro editions; the commands do not, which is the point of learning them.

Next steps

Last reviewed . Command syntax verified against Windows 11, Ubuntu 24.04, macOS 15 and FreeBSD 14 unless noted otherwise.

Spotted a mistake or a switch we have missed? Every page on this site is written to be checked against real output, so please test on your own machine and compare.