Playing with files & directories in Linux🐧

Playing with files & directories in Linux🐧

Table of contents

No heading

No headings in the article.

Hey all👋,

Hope you all are doing well. In this blog, we will be focusing on basic commands which can be useful while working with the files & directories.

The commands can help you in:

  • Creating files
  • Creating directories
  • Copying files
  • Copying directories
  • Finding files
  • Finding directories

Let's explore the commands one by one with examples

1 . Creating files :
Files can be created with the help of 2 commands

  • touch

    The following is the syntax:

    touch <filename>

for eg: If you want to create a file named "myfile", then

touch.PNG

  • cp : copy command can also be used for file creation

The following is the syntax:

cp <path of file from which you want to copy> <path of file to which you want to copy>

for eg: While copying contents from "myfile1" to "myfile2", new file "myfile2" will be automatically created.

cp.PNG

2 . Creating directories :

  • mkdir : This command is used for creating directory in the system

The following is the syntax:

mkdir <directoryname>

for eg: If you want to create directory named "omega", then

mkdir.PNG

3 . Copying files/directories

  • cp : Copy command is used for copying files/directories

The following is the syntax:

cp <path of file from which you want to copy> <path of file to which you want to copy>

In case of directories, syntax will be:

cp -r <path of source_directory > <path of destination_directory>

for eg: If you want to copy contents from "myfile1" to "myfile2", then

cp.PNG

4 . Finding files/directories

  • find : It is used to find files/directories in the system

The following is the syntax:

find [where to start searching from] -name <name of file/directory you want to find>

for eg: If you want to find directory named "omega" starting from "/" then

find.PNG

Hope this blog gave you pretty much idea about basic commands required to work with file/directories into Linux file system. We will explore more in next upcoming blogs.

Have a nice day🙌