Linux Navigation and File Management
Navigating and manipulating files in Linux is a core concept for fluently operating the system. The terminal acts as your powerful control center, allowing you to traverse through directories, fetch files, and perform modifications. Whether you work on a local Linux installation or access a remote system via a secured SSH session, you can rely on basic commands to streamline your tasks.
And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS.
This tutorial will use practical examples and precise instructions to demonstrate Linux file navigation and manipulation.
Exploring Linux File Setup Copy link
Linux structures its files and directories in a hierarchical layout resembling a tree, where the root directory (/) serves as the foundation. Everything, including folders and files, branches out from this root. Below is a concise synopsis of some key directories:
Root (/) Copy link
It is the main folder where everything begins. Every other directory and file is kept inside it.
/home Copy link
This folder contains personal files for every user. For instance, if your username is hostman, files will be kept in /home/hostman.
/var Copy link
This folder keeps frequently updated files, including system logs and temporary data. Logs can be located in /var/log.
/etc Copy link
Linux preserves configuration files and system settings, including networking and account setup inside the etc directory.
File Navigation and Manipulation in Linux Copy link
Navigating and organizing files involves traversing the file system to handle files and directories. Linux commands make these tasks efficient, let you automate them, and provide you precise control, especially in non-graphical environments.
Checking Current Directory Copy link
The pwd command retrieves your current address in the file system. It's useful for identifying your position when navigating through complex directory structures:
pwdThe outcome indicates that the active directory is anees located inside the system’s home directory:

Traversing Directories Copy link
The cd utility lets us traverse distinct directories. Entering the command below will take us to the root directory:
cd /
Let’s employ cd with the tilde symbol ~ or cd without any option to traverse back to the Home Directory:
cd ~
Execute cd with the - sign to toggle between current and previous directories:
cd -It switches us from hostmanExamples to the previous folder, i.e., hostman:

Similarly, running cd with a precise path lets us access a particular file/directory:
cd Desktop/hostman/hostmanExamples
Retrieving Directories Data Copy link
ls is a Linux utility that retrieves the folder’s data, such as files, links, and sub-folders. You can utilize distinct flags with ls to exhibit additional details like access rights, sizes, and last modified timestamps.
Let’s utilize ls without any flag to retrieve the folder’s data from the recent path:
ls
Utilizing ls with a precise path retrieves the details of that directory:
ls Desktop/hostman/
To get invisible files, utilize ls with -a flag:
ls -a
To demonstrate precise information, run ls followed by the -l flag:
ls -l
Returning Folder Structure Copy link
The tree command retrieves folders and files in a hierarchical tree format. To do that, utilize the syntax:
tree /directory_pathLet’s retrieve the directory structure in a tree format, with each file’s size depicted in a human-understandable structure:
tree -h
Hidden Linux Files Copy link
These files or folders initiate with a dot (.) and are invisible by default. They typically keep configuration settings or important data for applications, such as .bashrc for customizing terminal behavior or .ssh for managing secure keys. They can be viewed by utilizing the ls -a command or by enabling the "show hidden files" from the file managers.
File Administration Copy link
Let’s study the below-listed Linux sections to handle files and directories effortlessly.
File Creation Copy link
Files are made in Linux via the touch command. It offers a simple method to make blank files. If the file is already present, touch revises the DateTime of the last change instead of generating a new file:
touch hostmanExample.txt
Folder Creation Copy link
The mkdir utility in Linux allows you to create a directory at the desired path:
mkdir hostmanFolderIt constructs a hostmanFolder in the current directory:

Re-labeling and Relocating Files Copy link
mv lets you alter the name of files or transfer them to a distinct location. To re-title a file, write the existing name followed by the desired one:
mv hostmanExample.txt hostman1.txtThis alters the name of hostmanExample.txt to hostman1.txt:

Likewise, users can transfer a file by specifying its name and the destination directory:
mv hostman1.txt /hostmanFolder
Cloning Files/Directories Copy link
To duplicate a file/folder, execute cp with the source file and the destination path:
cp graphqlFile.txt hostmanFolder
To duplicate a directory along with its contents, employ the -r (recursive) flag with cp:
cp -r graphql-examples hostmanFolderIt clones the complete graphql-examples folder with all its data to the hostmanFolder:

Deleting Files and Directories Copy link
The rm command removes files and directories eternally without sending them to the bin/trash, so use it cautiously by providing the file name:
rm graphqlFile.txt
Likewise, to trash a directory and all of its data, employ the -r flag:
rm -r hostmanFolder
For extended safety, utilize the -i flag, which asks for verification before deleting any item:
rm -ri graphql-examplesSpecify y (for "yes") and press Enter to approve the removal of each file or directory. If you input n, the file or directory will not be deleted.
File Compression Copy link
Zipping files is vital for sharing data, and organizing files and storage space. To accomplish this, Linux utilizes tools like gzip and bzip2.
gzip is a widely employed tool for compressing files. It decreases the file size while retaining the original data. Let’s employ gzip to compress the hostmanExample.txt file:
gzip hostmanExample.txtThe command compresses the original file (overrides the actual file):

Similarly, users can execute gzip with -d flag to decompress a compressed file:
gzip -d hostmanExample.txt.gz
Users can employ the -k flag to compress a file without overriding the original one:
gzip -k hostmanExample.txt
File Archiving Copy link
File archiving refers to the method of grouping multiple files and directories together into one unified archive file. This practice makes it easier to share, compress, and manage large data by consolidating various items into a single, organized package. For this purpose, we can utilize the tar command:
tar -cvf hostman.tar hostmanExample.txt hostman1.txt hostmanDir/By default, it makes an archive without compression, which contains hostmanExample.txt and hostman1.txt files and a hostmanDir directory:

To assemble a compressed archive, we can define the compression format such as z for gzip and j for bzip2:
tar -czvf hostman1.tar.gz hostmanExample.txt hostman1.txt hostmanDir/
Similarly, users can extract the archived data by executing the tar command with the -x flag:
tar -xvf hostman.tarTo extract a gzip or bzip2-compressed archives, use the -z or -j flags respectively:
tar -xzvf hostman1.tar.gzNavigating with Shortkeys Copy link
Shortcut keys can save time and make command-line navigation more efficient:
- Use
cd -to switch to the previous directory. - Run
cd ..to steer one directory up. - Execute
cd ~to return to the home folder. - Press Ctrl + A to leap to the left-most (beginning) of the command line.
- Press Ctrl + E to leap to the right-most (end) of the command line.
- Hit Tab to auto-complete file or folder names.
Gaining proficiency in these fundamental shortcut keys will simplify and enhance your experience with Linux file management.
Conclusion Copy link
In this write-up, we wrapped the essential techniques for navigating and handling files in Linux. We examined how to switch between directories and depict their data. We also examined the creation, deletion, renaming, and relocation of files and directories. Additionally, we explored invisible files, their functionality, and methods to handle them. Mastering these core skills will make working with Linux more easily and effectively.