Commands For Managing Files and Directories With Other Commonly Used Commands
This document provides a comprehensive guide to essential commands for managing files and directories in Linux, including navigation, listing, creating, copying, moving, and deleting files. It also covers file permissions, compression, disk usage, networking, and process management commands. Familiarity with these commands will enhance efficiency in navigating and manipulating the Linux environment.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
33 views2 pages
Commands For Managing Files and Directories With Other Commonly Used Commands
This document provides a comprehensive guide to essential commands for managing files and directories in Linux, including navigation, listing, creating, copying, moving, and deleting files. It also covers file permissions, compression, disk usage, networking, and process management commands. Familiarity with these commands will enhance efficiency in navigating and manipulating the Linux environment.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Commands For Managing Files And Directories With
Other Commonly Used Commands
These commands provide a robust toolkit for managing files, directories, and various system tasks in Linux. Familiarity with these commands will enhance your ability to navigate and manipulate the Linux environment efficiently. File and Directory Management Commands 1. Navigating Directories pwd: Print the current working directory. cd [directory]: Change the current directory to the specified one (e.g., cd /home/user). cd ..: Move up one directory level. 2. Listing Files and Directories ls: List files and directories in the current directory. ls -l: List files with detailed information (permissions, owner, size, etc.). ls -a: List all files, including hidden files (those starting with a dot). 3. Creating Files and Directories touch filename: Create an empty file or update the timestamp of an existing file. mkdir directory_name: Create a new directory (e.g., mkdir my_folder). 4. Copying Files and Directories cp source destination: Copy a file (e.g., cp file.txt /home/user/). cp -r source_directory destination_directory: Copy a directory and its contents recursively. 5. Moving and Renaming Files and Directories mv source destination: Move or rename a file or directory (e.g., mv oldname.txt newname.txt). 6. Removing Files and Directories rm filename: Delete a file (e.g., rm unwanted_file.txt). rm -r directory_name: Recursively delete a directory and its contents (use with caution).
7. Viewing File Contents
cat filename: Display the contents of a file. less filename: View the contents of a file with pagination (allows scrolling). head filename: Display the first 10 lines of a file. tail filename: Display the last 10 lines of a file. 8. Searching for Files and Text find [directory] -name [pattern]: Search for files matching the specified pattern (e.g., find /home -name "*.txt"). grep 'text' filename: Search for a specific text string within a file. Other Commonly Used Commands 1. File Permissions chmod permissions filename: Change file permissions (e.g., chmod 755 script.sh). chown user:group filename: Change the owner and group of a file (e.g., chown user:group file.txt). 2. File Compression and Archiving tar -cvf archive.tar directory/: Create a tarball (archive) from a directory. tar -xvf archive.tar: Extract files from a tarball. gzip filename: Compress a file (e.g., gzip myfile.txt). gunzip filename.gz: Decompress a gzipped file. 3. Disk Usage and Management df -h: Display disk space usage for all mounted filesystems. du -sh directory: Display the size of a directory. 4. Networking Commands ping [host]: Test network connectivity to a host. ifconfig: Display network interface configuration (use ip addr for newer systems). scp source user@remote_host:destination: Securely copy files to/from a remote host. 5. Process Management ps: Display currently running processes. top: Interactive view of system processes. kill [PID]: Terminate a process by its process ID.