The Windows Command Line
Your command line (also called a terminal or shell) is a text-based interface that allows you to interact directly with your computer’s operating system.
While most HPC systems run Linux, many users perform preliminary analysis and data management on Windows machines. Windows provides command-line environments such as:
- Command Prompt (cmd)
- PowerShell (modern default)
Both allow you to navigate the filesystem, manipulate files, and run software from the command line.
Even if most of your analysis is performed using Python or R, basic command-line skills are extremely useful when organizing files, running pipelines, or transferring data to an HPC system.
Command Structure
Regardless of your operating system or command-line interpreter, a command has the same general structure:
command [options] [arguments]For example, a standard kb-python command might look like:
kb -x 10XV4 read1.fastq.gz read2.fastq.gzIn this case:
kbis the command (the program being executed)-x 10XV4is an option (or flag) modifying how the program runsread1.fastq.gzandread2.fastq.gzare inputs specifying file paths
Understanding Paths and the Windows Filesystem
A file path specifies the location of a file or directory within the filesystem.
Windows organizes files using drive letters such as:
C:\
D:\Most user files are stored in the Users directory:
C:\Users\usernameAbsolute vs Relative Paths
There are two types of paths: absolute and relative.
Absolute paths
An absolute path specifies the complete location of a file from the root of the drive.
C:\Users\user\project\data\file.txtRelative paths
A relative path specifies a file relative to your current directory.
For example, if your current directory is:
C:\Users\user\projectyou could reference the same file as:
data\file.txtAbsolute paths are always unambiguous, while relative paths depend on your current working directory.
Essential Windows Command Line Commands
If you plan to work from the command line, here are the most important commands to know.
Managing Files
copy file destination— Copy a filemove file destination— Move or rename a filedel file— Delete a filemkdir new_directory— Create a directoryrmdir directory_name— Remove a directory
For example, to create a directory project within your current directory and move a file called data.txt from your current directory to project:
mkdir project
move data.txt projectViewing Files
Omics datasets can be extremely large. You should avoid opening large files in graphical editors.
Instead, use command-line tools to inspect them.
type file.txt— Print the contents of a filemore file.txt— Scroll through a file page-by-page
In PowerShell, you can also use:
Get-Content file.txt
This allows you to inspect files such as configuration files, logs, or small metadata tables.
Viewing the Beginning or End of Files (PowerShell)
To view the first lines of a file:
Get-Content file.txt -Head 10To view the last lines:
Get-Content file.txt -Tail 10These are useful for quickly checking large output files or logs.
Omics datasets are often stored in compressed formats to reduce storage requirements. These commonly include files ending in:
.gz
.zip
.tar.gzWindows can extract many compressed formats using built-in tools or utilities such as 7-Zip.
For example, to extract a ZIP archive using the command line:
Expand-Archive file.zipWhen working with large sequencing files, it is often best to inspect them on a Linux or HPC system, where tools like zcat and less allow compressed files to be streamed without full decompression.
Creating and Editing Files
Windows command lines are not ideal for editing large files, but you can create or open files using simple programs.
To open a file in Notepad:
notepad filename.txtIf the file does not exist, Notepad will prompt you to create it.
Displaying Text
You can print text to the terminal using:
echo Hello World
This is often used to verify commands or display messages.