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

Overview:

In this tutorial, we will cover the basics of 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. 

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 contents of file1 is 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 directory

  • Syntax: mkdir [OPTION] directory
  • Example: Create 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.

PREV Tutorial | NEXT Tutorial


Further Reading