Navigating and Managing Files in Kali

LinuxBeginner
Practice Now

Introduction

Security work produces notes, scan outputs, and reference files. Before running a tool, you need to know where its results will be written and how to organize them without losing the originals.

In this lab, you will work as the ordinary kali user in the prepared Kali container. You will navigate paths, build a small workspace, edit a note with nano, and copy, rename, and remove practice files. All work stays under the shared /home/labex/project directory; no security scans or administrator commands are needed.

In this step, you will distinguish absolute and relative paths and create directories for a small security exercise.

Open the Terminal. It initially belongs to the Ubuntu host. Use the prepared entry command to open Kali as an ordinary user:

kali

The prompt begins with kali@kali-training. Confirm your identity and location:

whoami

The output is kali.

pwd

The output is /home/labex/project, the directory shared with the host. Your container home is /home/kali; the project directory is the place for your exercise files.

ls lists the names in a directory. Supply an absolute path, beginning with /, to list a location regardless of your current directory:

ls /home/labex/project

The listing can contain platform files; leave them alone. Create a dedicated workspace with mkdir. Its -p option creates missing parent directories and accepts an already existing directory. Each path after the option is a separate directory to create:

mkdir -p /home/labex/project/kali-work/notes /home/labex/project/kali-work/results

cd changes your shell's current directory. Enter the workspace using its absolute path:

cd /home/labex/project/kali-work
pwd

Expected output:

/home/labex/project/kali-work

Now list this directory:

ls

You should see notes and results; spacing and color may differ. A relative path starts from your working directory. Enter notes by name:

cd notes
pwd

The path now ends in /kali-work/notes. The special relative path .. means the parent directory:

cd ..

You are back in /home/labex/project/kali-work. Using pwd after navigation helps prevent writing a result into the wrong folder.

touch creates an empty file when that path does not exist. Create a placeholder in the results directory without changing directories:

touch results/pending.txt
ls results

You should see pending.txt. The relative path results/pending.txt names a file inside a child directory of your workspace.

Edit and Preserve a Note

In this step, you will edit a text file with nano and preserve a copy before renaming the working note.

Stay inside Kali. First return to the workspace with an absolute path, so the commands work even if you navigated elsewhere:

cd /home/labex/project/kali-work

nano is a terminal text editor. It is already installed for this exercise. Open a new file under notes:

nano notes/session.txt

Nano occupies the terminal. Type this single line into the editor:

Authorized training only.

Save with Ctrl+O (hold Ctrl and press O), then press Enter to accept the filename. Exit with Ctrl+X. The ^ shown in nano's shortcut bar means Ctrl. You should return to the Kali prompt.

Read the file to check that the save worked:

cat notes/session.txt

Expected output:

Authorized training only.

cp copies a file. Its first path is the source, and its second is the destination. Keep a copy in results:

cp notes/session.txt results/session-backup.txt

mv moves a file or changes its name. Rename the note while leaving the backup in place:

mv notes/session.txt notes/scope.txt
cat notes/scope.txt
cat results/session-backup.txt

Both files should contain Authorized training only. The copy preserves the original content; renaming the working file changes its path rather than its contents.

Remove a Disposable File

In this step, you will remove an obsolete placeholder while keeping your useful notes and backup.

rm removes a file. It normally has no undo, so identify the exact disposable file before using it. Start from your known workspace:

cd /home/labex/project/kali-work

List the results directory:

ls results

You should see pending.txt and session-backup.txt. Only the empty placeholder is obsolete. Remove it by its specific relative path:

rm results/pending.txt

No output is expected. List both directories to inspect the final organization:

ls notes

The notes directory contains scope.txt.

ls results

The results directory contains session-backup.txt. Read the preserved backup one more time:

cat results/session-backup.txt

Its content should still be Authorized training only. You removed a named disposable file while preserving useful material. Avoid broad wildcards or recursive deletion when a single exact filename is enough.

Summary

You navigated absolute and relative paths, created directories and an empty file, edited a note in nano, and used cp, mv, and rm to organize files. You checked that useful content survived each change. The paired challenge gives you a fresh set of files to organize independently.