touch command in linux with examples

touch command in linux allows you to create a file and modify or change time stamp and also to create files with extension.

linux touch command with syntax and examples

touch command in linux with examples
linux touch command

Hello, guys welcome to the next session on linux command line tutorial. In this session, we will learn how to use "touch command" in Linux.

The "touch" command is used to change the "timestamps" on existing files or directories.

It is also used to create new empty files in Linux.

So let's see how you can use it. First of all, I will open my terminal and as you can see on the desktop I have a directory called dir.

touch command in linux with examples
Preview of dir

let's list all the contents of the directory. So I will just do "ls -l" for a long list and you can see this directory contains 4 files.

And you can see the time of the files. Which is the "timestamp" at which they are created or updated.

Create a simple file

touch command in linux with examples
create an empty file using touch command

$touch fileName
Now I want to create a new empty file. We can use a "touch" command to create a new empty file.

And to create a new empty file you just need to write "touch" and give the name of the file.

So you can see the directory already contains 4 files and I want to create a "fifth file".

So I can just say "touch file5" and press ENTER.

Create a file with an extension

touch command in linux with examples
Create a txt file using the touch command

$touch filename.extension
Now earlier with touch command, I have only used the name of the file.

I can even give the "extension of the file".

For example "touch file6.txt" you can give any other extension and it will create it.

Create or modify the time stamp

touch command in linux with examples
Modify the time stamp using touch command

$touch fileName

Now the second use of touch command is to change the timestamp of a file.

For example, I want to change the timestamp on "file1" at which they are modified or created.

Then what I can do is I can use the "touch command" on them.

So if the file doesn't exist and if you use "touch" command then it's going to create a file.

If I use the "touch" command on the file which already exists it's going to update the "timestamp" of this file to the current time.

I can just say "touch file1" and press ENTER.

So in this way you can update the timestamp of the file using the touch command.

Conclusion

So these are the two basic uses of "touch command".
  • First is to create empty files.
  • The second is to update the timestamp of a given file.
So I hope you enjoyed this tutorial please rate your comment and bye for now.

HAVE A NICE DAY💗

Related,

Name

Apps,3,Games,1,Linux,38,Linux Commands,37,Terminal Apps,2,Termux,17,Userland,3,Windows,1,
ltr
item
Pro Tech guides: touch command in linux with examples
touch command in linux with examples
touch command in linux allows you to create a file and modify or change time stamp and also to create files with extension.
https://1.bp.blogspot.com/-GuQwFtAxPkY/X8zRQjPZu-I/AAAAAAAACiQ/lkuA-aHP0esh_NhbTu6Cn-W0AtUBInWYACNcBGAsYHQ/s16000/touch%2Bcommand.png
https://1.bp.blogspot.com/-GuQwFtAxPkY/X8zRQjPZu-I/AAAAAAAACiQ/lkuA-aHP0esh_NhbTu6Cn-W0AtUBInWYACNcBGAsYHQ/s72-c/touch%2Bcommand.png
Pro Tech guides
http://www.protechguidez.com/2020/12/touch-command-in-linux-with-examples.html
http://www.protechguidez.com/
http://www.protechguidez.com/
http://www.protechguidez.com/2020/12/touch-command-in-linux-with-examples.html
true
7053638852026728047
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content