Linux: Top 10 Linux Commands for File and Folder Management
Top 10 Linux Commands for File and Folder Management
Linux file management commands are essential for anyone working with the Linux operating system. These Linux command-line tools help you navigate, organize, and maintain your filesystem efficiently. Whether you're a beginner or a Linux system administrator, mastering these commands will make your workflow faster and more reliable.
1. ls – List Directory Contents
Purpose: View files/folders inside a directory using the Linux CLI basics.
Common options:
-l: Long listing format (permissions, owner, size, datetime)-a: Show hidden files (starting with dot)-h: Human-readable sizes (e.g., KB, MB)-R: Recursively list subdirectories
Example:
ls -lah /var/log
Expected Output sample:
drwxr-xr-x 5 root root 4.0K Nov 12 10:00 .
drwxr-xr-x 14 root root 4.0K Nov 1 15:22 ..
-rw-r--r-- 1 root root 1.2M Nov 12 09:58 syslog
-rw-r--r-- 1 root root 0 Nov 12 09:59 wtmp
2. cd – Change Directory
Purpose: Navigate between directories in the Linux shell.
Common usage:
cd /path/to/directory: Change to a specific directory.cd ..: Move up one level.cd ~or simplycd: Go to home directory.cd -: Go to previous directory.
Example:
cd /usr/local/bin
3. mkdir – Create Directory
Purpose: Create one or multiple directories using Linux terminal tips.
Common options:
-p: Make parent directories as needed.
Example:
mkdir -p projects/week1
4. rmdir – Remove Empty Directory
Purpose: Delete empty directories only.
Common options:
-p: Remove parent directories if they become empty.
Example:
rmdir old_folder
Note: For directories with contents, use rm -r.
5. rm – Remove Files and Directories
Purpose: Delete files or directories in Linux command examples.
Common options:
-r: Recursive delete for directories.-f: Force delete, no prompt.-i: Interactive prompt before deletion.
Example:
rm -rf temp_folder
rm file.txt
6. cp – Copy Files and Directories
Purpose: Duplicate files or directories in Linux tutorials.
Common options:
-ror-R: Recursively copy directories.-i: Prompt before overwrite.-v: Verbose output during copying.
Example:
cp -rv source_dir backup_dir
cp file1.txt file2.txt /home/user/documents/
7. mv – Move or Rename Files and Directories
Purpose: Move files/directories or rename them using Linux shell commands.
Common options:
-i: Interactively prompt before overwriting.-v: Verbose output.
Example:
mv oldname.txt newname.txt
mv file.txt /tmp/
8. touch – Create or Update Files
Purpose: Create empty files or update timestamps.
Common options:
-c: Do not create file, only update timestamp if it exists.-a: Change only access time.-m: Change only modification time.
Example:
touch newfile.txt
touch -c existingfile.txt
9. stat – Display File or Directory Status
Purpose: Detailed information about a file/directory (size, permissions, times).
Example:
stat filename.txt
Expected Output sample:
File: filename.txt
Size: 1024 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 524292 Links: 1
Access: 2025-11-13 09:00:00.000000000 +0530
Modify: 2025-11-13 08:58:00.000000000 +0530
Change: 2025-11-13 08:59:30.000000000 +0530
10. find – Search for Files and Directories
Purpose: Locate files/directories matching criteria using Linux command-line tools.
Common options:
-name [pattern]: Search by filename.-type [f/d]: Files or directories.-mtime [+-n]: Modified time in days.-exec: Execute command on results.
Example:
find /home/user -type f -name "*.log" -mtime -7

Comments
Post a Comment