Working with Files _ Directories in Linux(21-25).pptx

Saini71 13 views 12 slides Jun 24, 2024
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

Working with Linux files


Slide Content

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