Basic Commands to Create files and Directories with Linux.

How to Create Files and Directories

Creating a file in Linux (Terminal)

Using Cat Commands

  • cat (Concatenate) command is used to create a file and to display and modify the contents of a file
  • To Create a file
               cat > filename (eg: gyani)
                Welcome to Get Gyan Tech Blogger
                Hope all are doing good. 

           Ctrl+d (to save the file)

  • To display the content of the file
                cat filename (eg: gyani)
               

  • To append the data to the existing file
                cat >> filename (eg: gyani)
                        Today we will learn about
                        Basic Commands

                ctrl +d (to save the file)


  • To Create multiple files at the same time using touch commands
                    touch <filename> <filename> <filename>
                    touch gyani1 gyani2 gyani3

    Note: To check the file use the ls command


Creating a directory in Linux (Terminal)

                    To create a directory we use mkdir command
                    mkdir <dir name>
                    eg: mkdir tech


  • To create multiple directories inside a directory

                Let us make some directories according to the following architecture using one command


                 mkdir -p Device/{Laptop/{Dell,HP},Mobile/{Nokia,Mi},Television/{Sony,Samsung}}


        Note: We Can Check it by using tree command or ls -R command

Comments

Popular posts from this blog

Linux Filesystem Hierarchy

Basic Commands to Copy, Move, rename, remove files and Directories with Linux.