Linux

Linux File System Management: Basics for Beginners

This guide will introduce you to essential commands and concepts for managing files and directories in Linux. You'll learn to confidently work with the file system, perform basic operations, and understand directory structure.

Updated at February 17, 2026
15-30 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04+Debian 11+CentOS 7/8Fedora 35+Any Linux distribution

Introduction / Why This Is Needed

The Linux file system is a hierarchical structure where everything is represented as files and directories. The ability to manage it is a fundamental skill for any Linux user, from beginners to administrators. This guide will provide you with practical tools for navigation, data organization, and basic administration. You will be able to work confidently in the terminal, create/delete files, manage permissions, and understand the logic behind system file placement.

Requirements / Preparation

  1. Access to a terminal on any Linux distribution (Ubuntu, CentOS, Fedora, etc.).
  2. A user account with permissions to execute commands in your home directory (/home/your_name).
  3. For operations outside your home folder (e.g., in /etc or /var), superuser (sudo) privileges may be required. Be cautious with such commands.
  4. Basic understanding of what a path is (e.g., /home/user/Documents/file.txt).

Basic Navigation and Viewing Commands

Step 1: Determine Your Location — pwd

The pwd (print working directory) command displays the full path to your current directory. This is the first command you should use when opening a terminal to understand where you are.

pwd
# Example output: /home/username

Step 2: Move Between Directories — cd

The cd (change directory) command allows you to navigate the file system.

# Navigate to your home directory
cd ~
# or simply
cd

# Navigate to a specific absolute path
cd /etc/nginx

# Move up one level (to the parent directory)
cd ..

# Go back to the previous directory (like "back" in a browser)
cd -

Tip: Use Tab autocompletion. Start typing cd /ho and press Tab — the system will automatically complete it to cd /home/.

Step 3: View Directory Contents — ls

The ls (list) command outputs a list of files and subdirectories in the current or specified directory.

# Simple list
ls

# Detailed list (permissions, owner, size, date)
ls -l

# Show all files, including hidden ones (starting with .)
ls -la

# Sort by size (largest at the top)
ls -lS

# Recursive view (including nested directories)
ls -R

Working with Files and Directories

Step 4: Creating Files and Folders

  • Create an empty file: touch filename.txt
    touch notes.txt
    
  • Create a directory: mkdir foldername
    mkdir project_2026
    
  • Create nested directories (if parents don't exist): mkdir -p path/to/new/folder
    mkdir -p archive/2026/02
    

Step 5: Copying, Moving, and Renaming

  • Copy a file: cp source.txt destination/
    cp report.docx ~/Documents/
    
  • Copy a directory (recursively): cp -r source_folder/ destination/
    cp -r templates/ backup/
    
  • Move or rename: mv oldname.txt newname.txt or mv file.txt /new/path/
    mv draft.txt final.txt
    mv image.jpg /var/www/images/
    

    ⚠️ Important: The mv command without flags overwrites the destination file without warning. Use mv -i for interactive confirmation.

Step 6: Deleting Files and Directories

  • Delete a file: rm filename
    rm temp.log
    
  • Delete an empty directory: rmdir folder
    rmdir empty_cache
    
  • Delete a non-empty directory (with all contents): rm -rf foldername
    rm -rf old_backup/
    

    ⚠️ Critically important: The -rf (recursive, force) flag deletes everything permanently and without confirmation. Double-check the path before executing. A command error like rm -rf / can destroy the entire system.

Permissions and Security

Step 7: Viewing and Understanding Permissions

When using ls -l, you see a string like: -rw-r--r-- 1 user group 1234 Feb 17 10:00 file.txt.

Decoding:

  • First character: type (- for file, d for directory).
  • Next 9 characters: permissions in three groups (owner, group, others). Each group: r (read), w (write), x (execute).
  • Example: rw- = read and write, but not execute.

Step 8: Changing Permissions — chmod

There are two main syntaxes:

  1. Symbolic (more intuitive):
    # Add execute permission for the owner
    chmod u+x script.sh
    
    # Remove write permission for group and others
    chmod go-w important.conf
    
    # Set permissions: owner - rwx, group and others - r-x (5)
    chmod 755 script.sh
    
  2. Octal (numeric): Each group (owner, group, others) is assigned a number from 0 to 7, where:
    • 4 = read (r)
    • 2 = write (w)
    • 1 = execute (x)
    • Sum: 7=4+2+1 (rwx), 6=4+2 (rw-), 5=4+1 (r-x), etc.
    # 755 = rwxr-xr-x (owner: all, group and others: read and execute)
    chmod 755 script.sh
    

Step 9: Changing Owner and Group — chown

Requires sudo.

# Change a file's owner
sudo chown newuser filename.txt

# Change both owner and group simultaneously
sudo chown newuser:newgroup folder/

# Recursively change owner for an entire directory
sudo chown -R www-data:www-data /var/www/html

Verification

  1. Check your current path: pwd should show the expected directory.
  2. Confirm creation: ls should display the new files/folders.
  3. Verify permissions: ls -l filename will show the set permissions (-rwxr--r--).
  4. Test execution: If you created a script, run ./script.sh (if the owner has x permission).

Common Issues

ProblemCauseSolution
Permission deniedNo permissions for the operation (read/write/execute) in the target directory or for the file.1. Use sudo for system paths (carefully!).
2. Change permissions via chmod or ownership via chown (if that is your task).
3. Perform operations in your home directory (/home/username).
No such file or directoryAn incorrect path or filename was specified.1. Check your current path with pwd.
2. Use ls to view the contents of the current or specified directory.
3. Ensure correct character case (Linux is case-sensitive: File.txtfile.txt).
File accidentally deletedUsed rm or rm -rf with an error in the path.1. Immediately stop writing to the disk.
2. Try recovery with utilities (extundelete, testdisk) if the file system hasn't been overwritten. Chances are low.
3. Prevention: always use ls before rm -rf, set up alias rm='rm -i' in ~/.bashrc.
Operation not permitted with chown/chmodAttempting to change permissions/ownership of a file you don't own without sudo.1. Add sudo to the beginning of the command if you are an administrator.
2. If the file is system-critical, reconsider if it needs to be changed.
Autocompletion (Tab) not workingThe terminal is using a shell other than bash/zsh, or settings are misconfigured.1. Ensure you are in bash (echo $SHELL).
2. Check if the bash-completion package is installed (sudo apt install bash-completion for Debian/Ubuntu).

Final Tip: Start with simple operations in an isolated test folder (e.g., mkdir test && cd test). The more confident you become with basic commands, the more effectively you will work with Linux.

F.A.Q.

How to view the current directory in Linux?
How to safely delete a file without removing something important?
What are '.' and '..' when using the ls command?
How to change a file's owner?

Hints

Open the terminal
Identify the current directory
View folder contents
Create a file and folder
Copy or move a file
Set access permissions
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community