cd .. because .. is a directory name, not a command or filename prefix that triggers completion. To navigate up one level, you must type the full command cd .. and press Enter. Autocomplete is designed to fill in partial paths or commands, but since .. is a standard relative path component, it requires explicit entry rather than tab-completion.
Understanding How Tab Completion Works
Bash uses a powerful readline library to handle command-line editing and completion. When you press Tab, the shell attempts to match the characters you have typed so far against available commands, filenames, or options. The key distinction here is between completing a command and completing a path argument. When you type cd .., the shell sees cd as the command and .. as an argument. Since .. is not a partial string of a command name, nor is it a partial filename in the current directory (unless there is a file literally named starting with dots), the completion engine has nothing to expand.
This behavior is intentional. If you were in a directory containing files like ..hidden or ...config, typing cd . followed by Tab might trigger completion for those specific files. However, the double-dot notation is a special syntactic element in Unix-like systems representing the parent directory. It is not treated as a wildcard or a prefix for completion in the same way a filename like doc would be expanded to documents/.
Demonstrating Path Completion
To see how completion actually works with directories, try this experiment. Navigate to your home directory and create a test folder:
mkdir -p ~/testdir/subdir
cd ~/testdir
Now, type cd s and press Tab. Bash will complete this to cd subdir/. This happens because s matches the start of the directory name subdir. Contrast this with typing cd ... There is no directory named .. that starts with a different character; .. is the literal target. Therefore, pressing Tab while the cursor is after .. often results in no change or, if there are multiple matches in the parent directory, it might list them, but it will not "complete" the concept of going up a level.
Correct Ways to Navigate Up One Level
Since autocomplete cannot magically insert the two dots for you, you need to rely on direct input or alternative navigation methods. Here are the most efficient ways to move up the directory tree in WSL2.
- Type the full command: Simply type
cd ..and pressEnter. This is the standard, POSIX-compliant method and works in every Linux environment. - Use tilde expansion: If you want to go to your home directory, use
cd ~or justcd. This is a common shortcut that many users prefer over navigating back from deep subdirectories. - Navigate to the root: Use
cd /to jump directly to the filesystem root.
For users coming from Windows Command Prompt or PowerShell, where cd .. is also required but sometimes feels less intuitive due to different history handling, the transition to Bash can feel slightly slower initially. However, mastering these explicit commands improves precision.
Configuring Bash for Better Experience
If you find yourself typing cd .. frequently, you can customize your Bash environment to make navigation smoother. While you cannot make Tab complete .. automatically, you can set up aliases or functions to reduce keystrokes.
One popular technique is to add a function to your ~/.bashrc file that allows you to navigate up multiple levels easily. For example, adding the following snippet to your configuration file creates a command up that takes a number as an argument:
up() {
local dir=""
for i in $(seq "$1"); do
dir="../$dir"
done
cd "$dir"
}
After adding this to ~/.bashrc and sourcing it with source ~/.bashrc, you can type up 2 to go up two levels. This reduces the cognitive load of remembering to type cd ../...
Additionally, ensure that your ~/.inputrc file is configured correctly for readline settings. Sometimes, users accidentally disable completion features. Check that set show-all-if-ambiguous on is not commented out if you want more aggressive completion behavior, though this still won't help with the specific cd .. scenario.
Common Misconceptions About Terminal Shortcuts
New Linux users often expect terminals to behave like modern GUI file explorers, where clicking "Up" or using a single shortcut moves you back. In the terminal, every action is explicit. This design choice provides consistency across all tools and scripts. You cannot assume that a shortcut will work unless it is documented.
Another misconception is that cd without arguments goes up a level. It does not; it returns you to your home directory. This is why knowing the difference between cd .. (parent) and cd (home) is crucial. Confusing these two can lead to frustration when trying to locate files.
For those interested in further customizing their terminal experience, understanding prompt variables can help make navigation cues clearer. See our guide on creating PS1 variables to customize your bash terminal for tips on displaying the current path more prominently.
Frequently Asked Questions
Why doesn't Tab complete 'cd .'?
Typing cd . followed by Tab may complete to other files or directories starting with a dot if they exist, but it won't "complete" the current directory itself because . is already a valid reference. The shell completes partial strings, and . is a complete token for the current directory.
Can I map a key to go up one directory?
You can create a custom key binding in your ~/.inputrc file or use a tool like bind to assign a sequence to the cd .. command. However, this is advanced configuration and may interfere with other shortcuts. Typing cd .. remains the most reliable method.
Does WSL2 change how Bash completion works?
No, WSL2 runs a full Linux kernel and uses standard Bash installations identical to native Linux distributions. The completion behavior you observe is standard Bash behavior, not a quirk of Windows Subsystem for Linux.
What if I accidentally delete '..'?
You cannot delete the .. directory entry because it is a virtual link maintained by the filesystem structure. It always points to the parent directory. Trying to remove it with rm .. will result in an error saying it is a directory or a special file.
How do I navigate down multiple levels quickly?
You can use tab completion to navigate down. Type cd folder1/folder2/ and press Tab after each slash to auto-complete the names. Alternatively, use the up function mentioned earlier to go up, and standard typing to go down.