Linux Filesystem Navigation Commands
Linux Filesystem Navigation Commands
In Linux, everything is organized in a hierarchy of directories and files, starting from the root directory (/). To work with files and folders effectively, you need to know how to navigate through this structure. Linux provides simple and powerful commands for filesystem navigation. Even if you are new to Linux, learning these basic commands will help you feel more comfortable moving around the system.
pwd (Print Working Directory)
The pwd command shows the current directory you are in. It helps you know your exact location in the filesystem.
Example:
$ pwd
/home/user/Documents
ls (List Directory Contents)
The ls command lists the files and directories in your current directory. It helps you see what items are available.
Example:
$ ls
file1.txt file2.txt my_folder
cd (Change Directory)
The cd command is used to move from one directory to another.
Example:
$ cd my_folder
cd .. (Move to Parent Directory)
The cd .. command moves you one level up in the directory structure, to the parent directory.
Example:
$ cd ..
cd / (Move to Root Directory)
The cd / command takes you directly to the root directory.
Example:
$ cd /
ls -l (List in Long Format)
The ls -l command displays detailed information about each file and directory, such as permissions, owner, size, and modification date.
Example:
$ ls -l
-rw-r--r-- 1 user user 4096 Apr 17 10:00 file1.txt
drwxr-xr-x 2 user user 4096 Apr 17 10:01 my_folder
ls -a (List All Files Including Hidden Files)
The ls -a command shows all files, including hidden files (those starting with a dot .).
Example:
$ ls -a
. .. .hiddenfile file1.txt my_folder
cd ~ (Move to Home Directory)
The cd ~ command takes you back to your home directory from anywhere in the system.
Example:
$ cd ~