Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

File Handling

The bash shell provides lots of commands for manipulating files on the Linux filesystem. This section walks you through the basic commands you will need to work with files from the CLI for all your file-handling needs.

Creating Files

Every once in a while you will run into a situation where you need to create an empty file. Sometimes applications expect a log file to be present before they can write to it. In these situations, you can use the touch command to easily create an empty file:

$ touch test1

$ ls -il test1

1954793 -rw-r--r--  1 rich     rich         0 Sep  1 09:35 test1

$

The touch command creates the new file you specify and assigns your username as the file owner. Because the -il parameter was used for the ls command, the first entry in the listing shows the inode number assigned to the file. Every file on a Linux filesystem has a unique inode number.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial