1ae1de6d0d2a87e6834da409bfd891b2 file/folder create, upload, delete, copy, move commands for linux(ubuntu) terminal

file/folder create, upload, delete, copy, move commands for linux(ubuntu) terminal

File Commands

  • Create a file


    touch filename

    or


    echo "some text" > filename
  • Delete a file


    rm filename
  • Upload a file (via SCP from local to remote server)


    scp /path/to/localfile user@remote:/path/to/destination
  • Upload a file (via rsync from local to remote server)


    rsync -av /path/to/localfile user@remote:/path/to/destination

Folder (Directory) Commands

  • Create a folder


    mkdir foldername
  • Create nested folders


    mkdir -p folder1/folder2/folder3
  • Delete an empty folder


    rmdir foldername
  • Delete a folder and its contents


    rm -r foldername

    or force delete without confirmation:


    rm -rf foldername
  • Upload a folder (via SCP)


    scp -r /path/to/localfolder user@remote:/path/to/destination
  • Upload a folder (via rsync)


    rsync -av /path/to/localfolder user@remote:/path/to/destination

To move a file to another folder in Linux (Ubuntu), use the mv command:


mv filename /path/to/destination/

Examples:

1️⃣ Move a file to another folder:


mv myfile.txt /home/user/Documents/

2️⃣ Move and rename a file:


mv myfile.txt /home/user/Documents/newname.txt

3️⃣ Move multiple files:


mv file1.txt file2.txt /home/user/Documents/

4️⃣ Move all .txt files to another folder:


mv *.txt /home/user/Documents/

for copy one file to folder

Basic Syntax:

cp filename /path/to/destination/

Examples:

1️⃣ Copy a file to another folder:


cp myfile.txt /home/user/Documents/

2️⃣ Copy and rename a file while copying:


cp myfile.txt /home/user/Documents/newfile.txt

3️⃣ Copy multiple files to a folder:


cp file1.txt file2.txt /home/user/Documents/

4️⃣ Copy all .txt files to a folder:


cp *.txt /home/user/Documents/

5️⃣ Copy a folder and its contents (-r for recursive copy):


cp -r myfolder /home/user/Documents/


💻 Linux Terminal (Bash/Zsh)

Pros:

  • More powerful for scripting and automation (bash, zsh, fish).
  • Comes with built-in tools like grep, awk, sed, curl.
  • Full package management (apt, dnf, pacman).
  • No need for extra software like WSL for native UNIX commands.
  • Easily integrates with servers, Docker, and dev environments.

Cons:

  • Learning curve for Windows users.
  • Some software requires workarounds (like Microsoft Office).

🖥️ Windows Terminal (PowerShell/CMD)

Pros:

  • PowerShell is great for managing Windows systems (registry, services).
  • Now supports WSL (Windows Subsystem for Linux), so you can run Linux commands.
  • Better support for Windows-based applications.
  • Native GUI file management integration.

Cons:

  • CMD is outdated and lacks many features of Linux shells.
  • PowerShell syntax is more verbose compared to Bash.
  • WSL is good, but not as smooth as a real Linux system.

Which One is Better?

🔹 For developers, system admins, and automation: Linux Terminal 🐧
🔹 For Windows users who need admin control & scripting: PowerShell 💻
🔹 For a mix of both worlds: Use WSL on Windows!

Post a Comment

0 Comments