Skip to main content

Command Palette

Search for a command to run...

Linux Shell 101: A Quick Guide to Shell Navigation

Updated
•3 min read•View as Markdown
Linux Shell 101: A Quick Guide to Shell Navigation
R

A coding civil engineer!

The Linux shell is a powerful interface that allows users to interact with the operating system through commands.

Shell navigation commands enables users to move seamlessly through directories, manage files, and perform fundamental tasks from the command line.

Whether you're a Linux beginner or looking to brush up your command-line skills, this quick guide will equip you with the basics needed to navigate the Linux shell with confidence.

Let's dive in and discover the key commands that will help you navigate, create, and manage files and directories in the Linux environment.

1. Opening the Terminal:

  • On most Linux distributions, you can open the terminal by pressing Ctrl + Alt + T or searching for "Terminal" in the application menu.

2. Basic Commands:

  • pwd (Print Working Directory):

    This command displays the current working directory, or the directory in the file system that you are currently working "in" or "within".

pwd
  • ls (List): Lists the files and directories in the current directory.
ls

3. Navigating Directories:

  • cd (Change Directory): Moves or changes your directory as specified.
cd /path/to/directory
  • cd ..: Takes you back to your previous working directory. I.e., if you were working on ./root/dir1/dir2, the command will move you to ./root/dir1.
cd ..
  • cd ~ or cd: Takes you to your home directory.
cd ~

4. Creating and Removing Directories:

  • mkdir (Make Directory): Creates a new directory.
mkdir new_directory
  • rmdir (Remove Directory): Removes an empty directory.
rmdir directory_to_remove
  • rm -r (Remove Recursive): Removes a directory and its contents.
rm -r directory_to_remove

5. Working with Files:

  • touch: Creates an empty file.
touch filename
  • cp (Copy): Copies files or directories.
cp source_file destination
  • mv (Move): Moves files or directories.
mv source destination
  • rm (Remove): Removes files.
rm filename

6. Viewing File Content:

  • cat: Displays the entire content of a file.
cat filename
  • less or more: Allows you to view large files one screen at a time.
less filename

7. Wildcard Characters:

  • (Asterisk): Matches any sequence of characters. For example, the command below will list all files of type .txt or ending with the extension .txt.
ls *.txt
  • ? (Question mark): Matches any single character.
ls file?.txt

8. Getting Help:

  • man (Manual): Displays the manual page for a command.
man command_name
  • --help: Shows the help information for a command.
command_name --help

9. Keyboard Shortcuts:

  • Ctrl + C: Interrupts the currently running command.

  • Ctrl + D: Exits the current shell session.

  • Tab: Auto-completes commands and file/directory names.

This tutorial covers a nick of fundamental Linux shell commands. There are many more you can find from various sources, such as books, manuals, or simply typing "man" followed by the command name in the terminal. A ton more commands will show up. But don't worry, most of the time you'll use a handful of them.

A good way of grasping these commands is practicing them. This will enhance your proficiency in navigating and managing files and directories in the Linux operating system.