Unix File System Commands Touch, Cat, Cp, Mv, Rm, Mkdir (Part B)

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated January 19, 2025

Overview:

In this tutorial, we will cover the basics of the Unix file system.

We will also cover the commands that are used to work with the file system such as touch, cat, cp, mv, rm, mkdir, etc. 

=> Click here for the Complete Unix Tutorial series

Unix File System Commands

Unix Video #3:

#1) touch: Create a new file or update its timestamp.

  • Syntax: touch [OPTION]…[FILE]
  • Example: Create empty files called ‘file1’ and ‘file2’
    • $ touch file1 file2

#2) cat: Concatenate files and print to stdout.

  • Syntax: cat [OPTION]…[FILE]
  • Example: Create file1 with entered cotent
    • $ cat > file1
    • Hello
    • ^D

#3) cp: Copy files

  • Syntax: cp [OPTION]source destination
  • Example: Copies the contents from file1 to file2 and the contents of file1 are retained
    • $ cp file1 file2

#4) mv: Move files or rename files

  • Syntax: mv [OPTION]source destination
  • Example: Create empty files called ‘file1’ and ‘file2’
    • $ mv file1 file2

#5) rm: Remove files and directories

  • Syntax: rm [OPTION]…[FILE]
  • Example: Delete file1
    • $ rm file1

#6) mkdir: Make a directory

  • Syntax: mkdir [OPTION] directory
  • Example: Create a directory called dir1
    • $ mkdir dir1

#7) rmdir: Remove a directory

  • Syntax: rmdir [OPTION] directory
  • Example: Create empty files called ‘file1’ and ‘file2’
    • $ rmdir dir1

#8) cd: Change directory

  • Syntax: cd [OPTION] directory
  • Example: Change working directory to dir1
    • $ cd dir1

#9) pwd: Print the present working directory

  • Syntax: pwd [OPTION]
  • Example: Print ‘dir1’ if a current working directory is dir1
    • $ pwd

Watch out more about Unix commands in the upcoming tutorial.

=> Click here for the Complete Unix Tutorial series

PREV Tutorial | NEXT Tutorial

Was this helpful?

Thanks for your feedback!

Leave a Comment