Logo

dev-resources.site

for different kinds of informations.

Title: A Beginner's Guide to Command-Line File and Directory Manipulation

Published at
3/3/2024
Categories
linux
command
cmd
Author
mdadul
Categories
3 categories in total
linux
open
command
open
cmd
open
Author
6 person written this
mdadul
open
Title: A Beginner's Guide to Command-Line File and Directory Manipulation

In the realm of command-line interfaces, understanding basic commands for file and directory manipulation is a fundamental skill. Whether you're navigating through your file system or creating, modifying, and deleting files and directories, these commands empower users to efficiently manage their digital workspace. In this guide, we'll explore essential command-line commands and create a cheat sheet for quick reference.

Navigation Commands:

  1. pwd (Print Working Directory):
    • Displays the full path of the current working directory.
   pwd
Enter fullscreen mode Exit fullscreen mode
  1. ls (List):
    • Lists the contents of the current directory.
   ls
Enter fullscreen mode Exit fullscreen mode
  1. cd (Change Directory):
    • Change into an existing directory.
   cd directory-name
Enter fullscreen mode Exit fullscreen mode
  1. cd .. (Move Backward):
    • Move back one directory level (to the parent directory).
   cd ..
Enter fullscreen mode Exit fullscreen mode
  1. cd directory/sub-directory:
    • Change forward through multiple directories.
   cd directory/sub-directory
Enter fullscreen mode Exit fullscreen mode
  1. cd ../.. (Move Backward Multiple):
    • Move backward through multiple directories.
   cd ../..
Enter fullscreen mode Exit fullscreen mode

File and Directory Manipulation:

  1. mkdir (Make Directory):
    • Create a new directory.
   mkdir directory-name
Enter fullscreen mode Exit fullscreen mode
  1. touch:
    • Create a new file.
   touch file-name
Enter fullscreen mode Exit fullscreen mode
  1. echo "text" > file:
    • Overwrite a file with specified text.
   echo "text" > file
Enter fullscreen mode Exit fullscreen mode
  1. echo "text" >> file:

    • Append text to the end of a file.
    echo "text" >> file
    
  2. cat file-a > file-b:

    • Overwrite content of file-b with content of file-a.
    cat file-a > file-b
    
  3. cat file-a >> file-b:

    • Append content of file-a to content of file-b.
    cat file-a >> file-b
    
  4. mv source-file target-file:

    • Move/rename source-file to target-file.
    mv source-file target-file
    
  5. mv source-dir target-dir:

    • Move/rename source-directory to target-directory.
    mv source-dir target-dir
    
  6. rm file:

    • Delete a file.
    rm file
    
  7. rm -r directory:

    • Delete a non-empty directory.
    rm -r directory
    
  8. rmdir directory:

    • Delete an empty directory.
    rmdir directory
    
  9. cp file-a > file-b:

    • Copy content of file-a into file-b (overwrite).
    cp file-a > file-b
    
  10. cp -r dir-a dir-b:

    • Copy content of dir-a into dir-b (overwrite).
    cp -r dir-a dir-b
    

Additional Commands:

  1. clear:

    • Clear the command line.
    clear
    

Conclusion:

Mastering these basic command-line operations provides a solid foundation for navigating and managing files and directories in a terminal environment. Always exercise caution, double-check your commands, and remember that certain actions, such as deletion, can be irreversible. With this cheat sheet, you're well on your way to becoming proficient in command-line file and directory manipulation. Happy coding!

cmd Article's
30 articles in total
Favicon
Windows 上 VSCode 的 C/C++ 延伸模組處理編碼的問題
Favicon
TryHackMe | Windows Command Line | RSCyberTech
Favicon
50+ Most Useful CMD Commands to Boost Your Windows Productivity
Favicon
Video: Enable IIS using CMD and PowerShell
Favicon
Video: List All Available Windows Features on Windows 11 using CMD & PowerShell
Favicon
🚀 Arch Linux Cheat Sheet: Essential Commands for new Users
Favicon
RIME Input | curl: (6) Could not resolve host: raw.githubusercontent.com
Favicon
Rename Multiple Files in Sequence with Just One Click Using PowerShell in Windows! 🚀
Favicon
Maximizing IT Service Excellence with ServiceNow CMDB
Favicon
🍑understanding windows Command Line Interface
Favicon
Comandos Avanzados
Favicon
Comandos de Red
Favicon
Comandos de Fecha
Favicon
Comandos para Manipular Archivos y Directorios
Favicon
Tech notes 02 - Most Important Command Line Notes
Favicon
Comandos Básicos
Favicon
Bash Scripting Fundamentals
Favicon
Decoding the Linux Command Line: 75 Indispensable Utilities Explained
Favicon
How to restore a Mysql backup with XAMP
Favicon
Remotely Control Raspberry Pi via SSH from External Network
Favicon
SSH Raspberry Pi via Cell Phone
Favicon
Enhancing Internet Speed Through CMD Commands
Favicon
Install Oh-My-Posh On Windows Command Prompt (cmd) Via Clink
Favicon
Important CMD Commands
Favicon
Title: A Beginner's Guide to Command-Line File and Directory Manipulation
Favicon
Mastering Deployments in Kubernetes
Favicon
SetEnv 工具程式
Favicon
My K8s Cheatsheet
Favicon
Membuat Database Melalui CMD Pada Laragon
Favicon
Perbedaan perintah RUN dan CMD di dalam Docker

Featured ones: