Navigasi Menggunakan CLI - 1 Mengenal Struktur File System
Table of Contents
Introduction
This tutorial will guide you through navigating the file system using the Command Line Interface (CLI). Understanding the file system structure is crucial for efficient file management and system navigation. By the end of this tutorial, you will learn how to access and manipulate files and directories using CLI commands.
Step 1: Understand the File System Structure
-
Familiarize yourself with the basic components of a file system:
- Root Directory: The top-level directory in a file system.
- Subdirectories: Folders within the root directory that can contain files and other subdirectories.
- Files: The individual documents or data stored within directories.
-
In UNIX-based systems, the file system is hierarchical. This means that all directories stem from the root directory (denoted as
/
).
Step 2: Navigate Using Basic Commands
-
Learn and practice the following fundamental commands:
-
pwd: Print Working Directory
- Displays the current directory you are in.
- Usage: Type
pwd
and hit Enter.
-
ls: List Directory Contents
- Shows all files and folders in the current directory.
- Usage: Type
ls
and hit Enter.
-
cd: Change Directory
- Move between directories.
- To go to a specific directory, type
cd directory_name
. - To go back to the parent directory, use
cd ..
.
-
-
Practical Tip: Always use
ls
after changing directories to confirm your location and see the contents.
Step 3: Create and Delete Directories
-
Use the following commands to manage directories:
-
mkdir: Make Directory
- Create a new directory.
- Usage: Type
mkdir new_directory_name
.
-
rmdir: Remove Directory
- Delete an empty directory.
- Usage: Type
rmdir directory_name
. - Note: To delete a directory with files, use
rm -r directory_name
(this command is more destructive).
-
-
Common Pitfall: Ensure the directory is empty before using
rmdir
, or you may lose files unintentionally.
Step 4: Manipulate Files
-
Learn how to create and delete files:
-
touch: Create an Empty File
- Usage: Type
touch filename.txt
.
- Usage: Type
-
rm: Remove Files
- Delete specific files.
- Usage: Type
rm filename.txt
. - Caution: This action is permanent; files will not be recoverable.
-
-
To view the contents of a file, use:
- cat: Concatenate and Display Files
- Usage: Type
cat filename.txt
.
- Usage: Type
- cat: Concatenate and Display Files
Conclusion
By mastering these foundational CLI commands, you can effectively navigate your file system, manage directories and files, and enhance your overall productivity. As a next step, practice using these commands in your terminal to build confidence and familiarity. Exploring additional commands such as cp
(copy) and mv
(move) will further enhance your file management skills.