Linux Command Line Tutorial: Manipulate Terminal with CD Commands

โšก Smart Summary

Linux command line file management uses the terminal to create, move, and delete files faster than a graphical manager. The cd and pwd commands navigate directories through absolute and relative paths across the file system.

  • ๐Ÿ–ฅ๏ธ CLI vs GUI: The terminal is faster and scriptable; the file manager is visual.
  • ๐Ÿ“ pwd: Prints the present working directory you are currently browsing.
  • ๐Ÿ“‚ cd: Changes directory; cd or cd ~ returns home, cd / goes to root.
  • โฌ†๏ธ cd ..: Moves up one directory level toward the root.
  • ๐Ÿงญ Paths: Absolute paths start from root; relative paths start from the current directory.
  • ๐Ÿค– AI Assistance: AI tools explain, generate, and correct Linux commands on request.

Linux Command Line Tutorial

The most frequent tasks that you perform on your PC are creating, moving, or deleting files. To manage your files, you can use either the Terminal (Command Line Interface, CLI) or a File manager (Graphical User Interface, GUI). This article focuses on the CLI and the cd commands used to move around the file system.

Why Learn the Command Line Interface?

Even though the world is moving to GUI-based systems, the CLI has specific uses and is widely used in scripting and server administration. Here are some compelling reasons to learn it:

  • Commands offer more options and are flexible. Piping and stdin/stdout are immensely powerful and are not available in a GUI.
  • Some configurations are up to five screens deep in a GUI, while in a CLI they are a single command.
  • Moving or renaming thousands of files in a GUI is time-consuming, while in the CLI a regular expression does the same task with a single command.
  • The CLI loads fast and consumes little RAM compared to a GUI. In crunch scenarios this matters.

Both interfaces have their uses. In a GUI, performance-monitoring graphs give instant visual feedback on system health, while reading hundreds of lines of logs in a CLI is an eyesore. The GUI of a Linux based OS is similar to any other OS, so this guide focuses on the CLI.

Launching the CLI on Ubuntu

There are two ways to launch the terminal:

  1. Go to the Dash and type terminal.
  2. Or press CTRL + Alt + T to launch the terminal.

Launching the terminal on Ubuntu

Once you launch the CLI, you will see a prompt such as guru99@VirtualBox. Reading it left to right:

  • The first part is the name of the user (for example bob, tom, or ubuntu).
  • The second part is the computer or host name, which helps identify a computer over the network and becomes important in a server environment.
  • The : is a simple separator.
  • The tilde ~ sign shows that the user is working in the home directory. If you change the directory, this sign disappears.
  • The $ sign means you are working as a regular user; while working as the root user, # is displayed.

Present Working Directory

The directory you are currently browsing is called the present working directory. You log on to the home directory when you boot your PC. To determine the directory you are presently working in, use the command:

pwd

The pwd command stands for print working directory. For example, it may show that /home/guru99 is the directory you are currently working in.

Changing Directories

If you want to change your current directory, use the cd command:

cd /tmp

For example, you can move from directory /tmp to /bin to /usr and then back to /tmp.

Navigating to the Home Directory

To navigate to the home directory, type cd on its own, or use cd ~:

cd
cd ~

Moving to the Root Directory

The root of the file system in Linux is denoted by /, similar to c:\ in Windows. Note that Windows uses a backward slash “\” while UNIX/Linux uses a forward slash “/”. Type cd / to move to the root directory:

cd /

TIP: Do not forget the space between cd and /, otherwise you will get an error.

Navigating Through Multiple Directories

You can navigate through multiple directories at once by specifying the complete path. For example, to move to the /cpu directory under /dev, you do not need to split the operation into two parts; type the full path directly:

cd /dev/cpu

Moving Up One Directory Level

To navigate up one directory level, use:

cd ..

For example, cd .. moves up one directory from /dev/cpu to /dev. Using the same command again jumps from /dev to the / root directory.

Relative and Absolute Paths

A path in computing is the address of a file or folder. In Windows a path looks like C:\documents and settings\user\downloads, and in Linux like /home/user/downloads. There are two kinds of paths:

Absolute Path

An absolute path specifies the full path to reach a file. For example, the absolute path of the Pictures directory in the home folder guru99 is /home/guru99/Pictures:

cd /home/guru99/Pictures

Relative Path

A relative path is handy when you browse a subdirectory within the current directory; it saves you from typing complete paths. Suppose you are in your home directory and want to navigate to Downloads. Instead of typing the full path, simply type:

cd Downloads

This works because you are already inside the /home/guru99 directory, so you do not have to specify the complete path to reach a location within the same part of the file system.

Common Terminal File Managers

Beyond the cd command, text-based file managers add a visual, keyboard-driven layer inside the terminal, which is useful over SSH or in containers:

  • Midnight Commander (mc): A long-standing dual-pane manager with menus and hotkeys, modeled on Norton Commander.
  • ranger: A Vim-inspired manager with a three-column layout and quick file previews.
  • nnn: An ultra-lightweight, single-column manager built for speed and low memory use.

FAQs

The tilde represents your home directory. When it shows in the prompt, you are in your home folder; it disappears once you change to another directory.

The $ sign means you are logged in as a regular user. The # sign means you are working as the root (administrator) user, who has full system privileges.

Use cd – (cd followed by a hyphen). It switches you back to the last directory you were in, which is handy when toggling between two locations.

Common choices are ranger, the lightweight nnn, and Midnight Commander (mc). They add panels, previews, and hotkeys on top of the shell.

Press the Tab key. The shell completes the file or directory name automatically. Pressing Tab twice lists all matching options when several names share the same prefix.

Use the ls command. Add ls -l for details such as permissions and size, and ls -a to include hidden files whose names begin with a dot.

Yes. AI assistants explain what a command does, translate plain English into the right cd or ls syntax, and suggest flags, which speeds up learning the terminal.

AI can draft commands, but always review them before running, especially rm or sudo commands. Intelligent assistants flag destructive operations, yet you remain responsible for what executes on your system.

Summarize this post with: