{"id":1279,"date":"2021-11-29T05:15:49","date_gmt":"2021-11-28T23:45:49","guid":{"rendered":"https:\/\/smarttech101.com\/?p=1279"},"modified":"2022-02-10T19:44:04","modified_gmt":"2022-02-10T14:14:04","slug":"touch-command-in-linux-unix-with-examples","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/","title":{"rendered":"Touch Command in Linux\/Unix with Examples"},"content":{"rendered":"\n<p>In Linux\/Unix, the touch command is used to <strong>change<\/strong> the <strong>&#8220;modify-time<\/strong>&#8221; and &#8220;<strong>access-time<\/strong>&#8221; of a file without modifying the contents of the file. <strong>If the file does not exist, it is created.<\/strong><\/p>\n\n\n\n<p>But before I start, you should know a little bit about these terms. <strong>Modify Time<\/strong> is the last time the <strong>content <\/strong>in the file was changed. On the other hand, the <strong>access time <\/strong>is the last time the file was <strong>read<\/strong>. I will be using the <strong>stat command<\/strong> to find these.<\/p>\n\n\n\n<p>Now, we will understand the application of the touch command using a few examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"table-of-contents\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"#how-to-create-an-empty-file\">How to Create an Empty File<\/a><\/li><li><a href=\"#how-to-change-the-timestamps-of-an-existing-file\">How to Change the Timestamps of an Existing File<\/a><\/li><li><a href=\"#how-to-change-times-of-multiple-files-together\">How to Change Times of Multiple Files Together<\/a><\/li><li><a href=\"#how-to-change-only-the-access-time-of-a-file\">How to Change Only the Access Time of a File<\/a><\/li><li><a href=\"#how-to-change-only-the-modification-time-of-a-file\">How to Change Only the Modification Time of a File<\/a><\/li><li><a href=\"#how-to-put-a-given-timestamp-instead-of-current-time-on-a-file\">How to Put a Given Timestamp instead of Current Time on a File<\/a><ul><li><a href=\"#1-using-touch-t\">1. Using touch -t<\/a><\/li><li><a href=\"#2-using-touch-d\">2. Using touch -d<\/a><\/li><\/ul><\/li><li><a href=\"#how-to-change-timestamps-of-links\">How to Change Timestamps of Links<\/a><\/li><li><a href=\"#how-to-assign-timestamp-of-another-file\">How to Assign Timestamp of Another File<\/a><\/li><li><a href=\"#how-to-use-touch-command-without-creating-any-file\">How to Use Touch Command without Creating Any File<\/a><\/li><li><a href=\"#wrapping-up\">Wrapping Up<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-create-an-empty-file\">How to Create an Empty File<\/h2>\n\n\n\n<p>If you have followed my recent post of <a href=\"https:\/\/smarttech101.com\/urxvt-installation-color-scheme-fonts-resize-etc\/\">setting up URxvt<\/a>, you might have seen that I created an empty file <code>~\/.Xresources<\/code> before <a href=\"https:\/\/smarttech101.com\/hard-links-and-soft-links-in-linux\/\">symlinking<\/a> it to <code>~\/.Xdefaults<\/code>. There are many such real-life examples\/commands where a file needs to exist before these commands can be executed. And in this scenario, we use touch commands to create the empty file.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch NON-EXISTANT-FILE<\/code><\/pre>\n\n\n\n<p>For the <strong>example<\/strong> shown below, there is no such file called <code>empty.txt<\/code> but as soon as I execute the <strong><code>touch empty.txt<\/code><\/strong> command, I create it. You can also notice its size as &#8220;0&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1250\" height=\"439\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/touch_empty.png?resize=1250%2C439&#038;ssl=1\" alt=\"touch to create empty file if non-existent\" class=\"wp-image-1281\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/touch_empty.png?w=1250&amp;ssl=1 1250w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/touch_empty.png?resize=768%2C270&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption><em>Touch Creating an Empty File<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-change-the-timestamps-of-an-existing-file\">How to Change the Timestamps of an Existing File<\/h2>\n\n\n\n<p>To set the timestamp to the current time, we follow the following <strong>Syntax<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch EXISTING-FILE<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1295\" height=\"669\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_164652.jpg?resize=1295%2C669&#038;ssl=1\" alt=\"linux touch changing timestamp\" class=\"wp-image-1284\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_164652.jpg?w=1295&amp;ssl=1 1295w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_164652.jpg?resize=768%2C397&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption><em>Linux Touch Command Changing Timestamp of an Existing File<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-change-times-of-multiple-files-together\">How to Change Times of Multiple Files Together<\/h2>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch FILE1 FILE2 FILE3<\/code><\/pre>\n\n\n\n<p>The command is the same as <strong>touch FILE1<\/strong> except that all three files are given the same timestamps.<\/p>\n\n\n\n<p>\ud83d\ude03 <strong>Fun Fact: <\/strong>In any <strong>man page<\/strong>, &#8220;triple dots&#8221; (&#8230;) means &#8220;repeatable argument&#8221;. You can have these arguments as many times as you want.<br><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"182\" class=\"wp-image-1283\" style=\"width: 720px;\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_164029.jpg?resize=720%2C182&#038;ssl=1\" alt=\"Triple Dots (Ellipsis) in Man Pages\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_164029.jpg?w=1023&amp;ssl=1 1023w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_164029.jpg?resize=768%2C194&amp;ssl=1 768w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-change-only-the-access-time-of-a-file\">How to Change Only the Access Time of a File<\/h2>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch -a FILE<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1060\" height=\"680\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_173643.jpg?resize=1060%2C680&#038;ssl=1\" alt=\"touch -a Changing Only the Access Time\" class=\"wp-image-1287\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_173643.jpg?w=1060&amp;ssl=1 1060w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_173643.jpg?resize=768%2C493&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption>touch -a Changing Only the Access Time<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-change-only-the-modification-time-of-a-file\">How to Change Only the Modification Time of a File<\/h2>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch -m FILE<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1246\" height=\"679\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_172957.jpg?resize=1246%2C679&#038;ssl=1\" alt=\"touch -m Changing only the Modification Time\" class=\"wp-image-1286\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_172957.jpg?w=1246&amp;ssl=1 1246w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_172957.jpg?resize=768%2C419&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption><em><code>touch -m<\/code> changing only the modification mime<\/em><\/figcaption><\/figure>\n\n\n\n<p>All of the above <code>touch<\/code> commands were putting a <code>current<\/code> timestamp on an existing file. What if we want to put a timestamp other than the current one?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-put-a-given-timestamp-instead-of-current-time-on-a-file\">How to Put a Given Timestamp instead of Current Time on a File<\/h2>\n\n\n\n<p>Two ways are possible:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Using <code>touch -t<\/code><\/li><li>Using <code>touch -d<\/code> or <code>touch --date<\/code><\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-using-touch-t\">1. Using touch -t<\/h3>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch -t STAMP FILE<\/code><\/pre>\n\n\n\n<p>The above command assumes timestamp in the format of <code>CCYYMMDDhhmm.ss<\/code><\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch -t 202103040100.10 ~\/.Xresources<\/code><\/pre>\n\n\n\n<p>Here,<br><code>CCYY<\/code>=2021<br><code>MMDD<\/code>=0304=4 March<br><code>hhmm.ss<\/code>=0100.10=01 hour 00 min 10 sec<\/p>\n\n\n\n<p>If you omit <code>CCYY<\/code>, it becomes the current year. <strong>You can omit CC as well but I prefer not to do that because it is more confusing and not sustainable<\/strong> (for more, see <strong>info touch <\/strong>command).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1016\" height=\"676\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_170501.jpg?resize=1016%2C676&#038;ssl=1\" alt=\"Touch -t STAMP using Given Time instead of Current Time\" class=\"wp-image-1285\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_170501.jpg?w=1016&amp;ssl=1 1016w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_170501.jpg?resize=768%2C511&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption><code><em>touch -t<\/em><\/code><em> STAMP using Given Time instead of Current Time<\/em><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-using-touch-d\">2. Using touch -d<\/h3>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch -d STRING FILE<\/code><\/pre>\n\n\n\n<p>Here, <a href=\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/#3-how-to-print-a-given-time-instead-of-the-current-time-using-date-command-in-linux\" target=\"_blank\" rel=\"noreferrer noopener\">touch parses the STRING in human-readable form <strong>like that in the<\/strong> <strong>date -d<\/strong> command<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>-d STRING<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td><code>-d '14:02'<\/code><\/td><td>14:02 @ Today<\/td><\/tr><tr><td><code>-d 'yesterday'<\/code><\/td><td>current time @ yesterday<\/td><\/tr><tr><td><code>-d 'today'<\/code><\/td><td>current day<\/td><\/tr><tr><td><code>-d 'next sunday'<\/code><\/td><td>upcoming Sunday<\/td><\/tr><tr><td><code>-d 'tomorrow<\/code>\u2018<\/td><td>current time but tomorrow<\/td><\/tr><tr><td><code>-d 'June 15, 2004'<\/code><\/td><td>June 15 2004 @ 12:00:00 AM<\/td><\/tr><tr><td><code>-d '@1619076682<\/code>\u2018<\/td><td>Thu Apr 22 01:01:22 PM IST 2021; explained below<\/td><\/tr><tr><td><code>-d '00:03:00'<\/code><\/td><td>00:03:00 @ Today<\/td><\/tr><tr><td><code>-d '-1 hour'<\/code><\/td><td>1 hour ago<\/td><\/tr><tr><td><code>-d '+1 hour'<\/code><\/td><td>1 hour later<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1030\" height=\"673\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_174533.jpg?resize=1030%2C673&#038;ssl=1\" alt=\"Touch -d in Action\" class=\"wp-image-1288\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_174533.jpg?w=1030&amp;ssl=1 1030w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_174533.jpg?resize=768%2C502&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption><em>touch -d taking argument in human-readable form.<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-change-timestamps-of-links\">How to Change Timestamps of Links<\/h2>\n\n\n\n<p>By default, the touch command <strong>changes the timestamps of the linked file<\/strong> instead of the <a href=\"https:\/\/smarttech101.com\/hard-links-and-soft-links-in-linux\/\">symlink<\/a> itself as can be seen from the following <strong>example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"864\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_180541-1.jpg?resize=882%2C864&#038;ssl=1\" alt=\"Touch Changing linked file instead of the link itself\" class=\"wp-image-1291\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_180541-1.jpg?w=882&amp;ssl=1 882w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_180541-1.jpg?resize=768%2C752&amp;ssl=1 768w\" sizes=\"(max-width: 882px) 100vw, 882px\" \/><figcaption><em>Touch changing linked file&#8217;s timestamp instead of the link itself<\/em>.<\/figcaption><\/figure>\n\n\n\n<p>However, if we like to change the timestamp of the link instead we need to use the  <strong><code>--no-dereference<\/code> (or <code>-h<\/code>)<\/strong> flag. <\/p>\n\n\n\n<p>S<strong>yntax: <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch --no-dereference LINK-FILE<\/code><\/pre>\n\n\n\n<p>Continuing with the same<strong> example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"865\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_182223.jpg?resize=895%2C865&#038;ssl=1\" alt=\"touch --no-dereference changing the link's timestamp directly\" class=\"wp-image-1292\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_182223.jpg?w=895&amp;ssl=1 895w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_182223.jpg?resize=768%2C742&amp;ssl=1 768w\" sizes=\"(max-width: 895px) 100vw, 895px\" \/><figcaption><code><em>touch --no-dereference<\/em><\/code><em> changing the link&#8217;s timestamp directly<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-assign-timestamp-of-another-file\">How to Assign Timestamp of Another File<\/h2>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch --reference=REFERENCE-FILE FILE<\/code><\/pre>\n\n\n\n<p>Here the <strong><code>touch --reference<\/code> (or <code>-r<\/code>)<\/strong> command will impose REFERENCE-FILE&#8217;s timestamp on the FILE. <\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"926\" height=\"865\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_175510.jpg?resize=926%2C865&#038;ssl=1\" alt=\"touch -r in action\" class=\"wp-image-1289\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_175510.jpg?w=926&amp;ssl=1 926w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_175510.jpg?resize=768%2C717&amp;ssl=1 768w\" sizes=\"(max-width: 926px) 100vw, 926px\" \/><figcaption><em>touch -r in action<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-use-touch-command-without-creating-any-file\">How to Use Touch Command without Creating Any File<\/h2>\n\n\n\n<p>By default, touch creates an empty file if the file does not exist. To avoid this, use <code>--no-create<\/code> (or <code>-c<\/code>) <strong>syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~$ touch --no-create FILE<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"304\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_182824.jpg?resize=923%2C304&#038;ssl=1\" alt=\"touch -c in action\" class=\"wp-image-1293\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_182824.jpg?w=923&amp;ssl=1 923w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/2021-11-23_182824.jpg?resize=768%2C253&amp;ssl=1 768w\" sizes=\"(max-width: 923px) 100vw, 923px\" \/><figcaption><em>touch -c in action<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"wrapping-up\">Wrapping Up<\/h2>\n\n\n\n<p>I have tried my best in covering up everything about the touch command in the Linux\/Unix system. But if you are still dissatisfied, please comment below. In that case, you can also dig in <strong><a href=\"https:\/\/man7.org\/linux\/man-pages\/man1\/touch.1.html\" target=\"_blank\" rel=\"noreferrer noopener\">man touch<\/a> <\/strong>and <strong>info touch<\/strong> commands. I have also tried my best to remove all kinds of errors. But if you find any, please let me know in the comment section. It will also help the Linux Community.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux\/Unix, the touch command is used to change the &#8220;modify-time&#8221; and &#8220;access-time&#8221; of a file. If the file does not exist, it is created.<\/p>\n","protected":false},"author":2,"featured_media":1306,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17],"tags":[18,20],"class_list":["post-1279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line-tools","tag-command-line-tools","tag-touch"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Touch Command in Linux\/Unix with Examples | SmartTech101<\/title>\n<meta name=\"description\" content=\"In Linux\/Unix, the touch command is used to change the &quot;modify-time&quot; and &quot;access-time&quot; of a file. If the file does not exist, it is created.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Touch Command in Linux\/Unix with Examples | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"In Linux\/Unix, the touch command is used to change the &quot;modify-time&quot; and &quot;access-time&quot; of a file. If the file does not exist, it is created.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-28T23:45:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-10T14:14:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"721\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"Touch Command in Linux\/Unix with Examples\",\"datePublished\":\"2021-11-28T23:45:49+00:00\",\"dateModified\":\"2022-02-10T14:14:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\"},\"wordCount\":778,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1\",\"keywords\":[\"Command Line Tools\",\"Touch\"],\"articleSection\":[\"Command Line Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\",\"url\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\",\"name\":\"Touch Command in Linux\/Unix with Examples | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1\",\"datePublished\":\"2021-11-28T23:45:49+00:00\",\"dateModified\":\"2022-02-10T14:14:04+00:00\",\"description\":\"In Linux\/Unix, the touch command is used to change the \\\"modify-time\\\" and \\\"access-time\\\" of a file. If the file does not exist, it is created.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1\",\"width\":1280,\"height\":721,\"caption\":\"Touch Command in Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Touch Command in Linux\/Unix with Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Touch Command in Linux\/Unix with Examples | SmartTech101","description":"In Linux\/Unix, the touch command is used to change the \"modify-time\" and \"access-time\" of a file. If the file does not exist, it is created.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/","og_locale":"en_US","og_type":"article","og_title":"Touch Command in Linux\/Unix with Examples | SmartTech101","og_description":"In Linux\/Unix, the touch command is used to change the \"modify-time\" and \"access-time\" of a file. If the file does not exist, it is created.","og_url":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/","og_site_name":"SmartTech101","article_published_time":"2021-11-28T23:45:49+00:00","article_modified_time":"2022-02-10T14:14:04+00:00","og_image":[{"width":1280,"height":721,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg","type":"image\/jpeg"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"Touch Command in Linux\/Unix with Examples","datePublished":"2021-11-28T23:45:49+00:00","dateModified":"2022-02-10T14:14:04+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/"},"wordCount":778,"commentCount":1,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1","keywords":["Command Line Tools","Touch"],"articleSection":["Command Line Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/","url":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/","name":"Touch Command in Linux\/Unix with Examples | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1","datePublished":"2021-11-28T23:45:49+00:00","dateModified":"2022-02-10T14:14:04+00:00","description":"In Linux\/Unix, the touch command is used to change the \"modify-time\" and \"access-time\" of a file. If the file does not exist, it is created.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1","width":1280,"height":721,"caption":"Touch Command in Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"Touch Command in Linux\/Unix with Examples"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2021\/11\/link_linux.jpg?fit=1280%2C721&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1279"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=1279"}],"version-history":[{"count":5,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1279\/revisions"}],"predecessor-version":[{"id":1729,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1279\/revisions\/1729"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/1306"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=1279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=1279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=1279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}