0% found this document useful (0 votes)
36 views12 pages

Working With Files - Directories in Linux (21-25)

This document discusses various aspects of file and directory manipulation in Linux. It covers Linux file types, using commands like find, locate, passwd, cp, mv, rm, mkdir, and rmdir to search for, copy, move, delete, and manage files and directories. Understanding these file operations is essential for system administrators, developers, and Linux users.

Uploaded by

Varinder Dhillon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views12 pages

Working With Files - Directories in Linux (21-25)

This document discusses various aspects of file and directory manipulation in Linux. It covers Linux file types, using commands like find, locate, passwd, cp, mv, rm, mkdir, and rmdir to search for, copy, move, delete, and manage files and directories. Understanding these file operations is essential for system administrators, developers, and Linux users.

Uploaded by

Varinder Dhillon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Working with Files & Directories in Linux

Linux

1
Introduction

In the world of Linux, managing files and directories is a fundamental task.


Whether you're a system administrator, developer, or just a user, understanding
how to work with files and directories efficiently is essential. In this presentation,
we will cover various aspects of file and directory manipulation in Linux, including
file types, searching, copying, moving, deleting, and creating directories.

2
1. Linux File Types

• Linux classifies files into different types based on their content and purpose.
• Common file types include regular files, directories, symbolic links, device files,
and more.
• ls -l command displays file details, including file types and permissions.

3
2. Finding Files

• find command: Used to search for files and directories based on various criteria
like name, size, type, etc.
• Syntax: find [path] [expression].
• Example: find /home/user -name "*.txt" finds all .txt files in the user's home
directory.

4
3. Locating Files

• ‘locate’ command: Quickly searches a pre-built database of file and directory


names.
• Requires an up-to-date database. Update using ‘sudo updated’.
• Syntax: ‘locate [filename]’.
• Example: ‘locate myfile.txt’ finds the location of ‘myfile.txt’ using the database.

5
4. Changing Password

• ‘passwd’ command: Used to change a user's password.


• Syntax: ‘passwd [username]’.
• Example: ‘passwd johndoe’ lets user "johndoe" change their password.

6
5. Copying Files

• ‘cp’ command: Used to copy files and directories.


• Syntax: ‘cp [options] source destination’.
• Example: ‘cp file.txt /backup’ copies ‘file.txt to the /backup’ directory.

7
6. Moving & Renaming Files

• ‘mv’ command: Moves files and directories to new locations or renames them.
• Syntax: ‘mv [options] source destination’.
• Example: ‘mv oldname.txt newname.txt’ renames the file.

8
7. Removing Files & Directories

• ‘rm’ command: Removes files and directories.


• Use with caution; deleted data is not recoverable.
• Syntax: ‘rm [options] filename’.
• Example: ‘rm unwanted.txt’ deletes ‘unwanted.txt’.

9
8. Creating Directories

• ‘mkdir’ command: Creates directories.


• Syntax: ‘mkdir [options] directoryname’.
• Example: ‘mkdir newdir’ creates a directory named "newdir."

10
9. Removing Directories

• ‘rmdir’ command: Removes empty directories.


• Syntax: ‘rmdir [options] directoryname’.
• Example: ‘rmdir emptydir’ removes the empty directory.

11
Conclusion

Working with files and directories is a foundational skill in Linux. Understanding


different file types, effectively searching for files, managing passwords, copying,
moving, and deleting files, as well as creating and removing directories, empowers
users to navigate and manipulate the Linux file system confidently. These
commands are essential tools for system administrators, developers, and anyone
interacting with Linux systems. Always exercise caution while performing file
operations, as mistakes can lead to data loss.

12

You might also like