Today we’ll talk about a simple trick that could be used to change last modified date of a file. Certaainly, you’re welcome to use touch command to do it under Linux, and it will be the most simple way. But… if you don’t know what does this command do, you can try to do it under MS Windows.
If you have a Microsoft Windows system, this will not be a problem for you. All you need is to change the date on your Windows PC and then make some changes to the file you need. Then you need to upload it back to your Linux machine and you’re done. Since Windows doesn’t have any restrictions on file modification time, this trick really works. It is usually necessary to do something like this when you have to imitate that something remained unchanged for a long time :).
It is a common practice to use a different operating system to do some tricks to the current one. For example, small linux distros are used to change Windows administrator password without knowing it. Maybe I will tell you about this in my future posts. If you have physical access to your PC or server, OS restrictions are usually useless – you may do almost anything with any of your operating systems installed.
Hello,
you can change the modification time with the touch command. Use it like this:
touch -m -t 09082000 file
to change the modification time to 8 sep, 20:00.
Or missed I something?
leo
Hello,
you can change the modification time with the touch command. Use it like this:
touch -m -t 09082000 file
to change the modification time to 8 sep, 20:00.
Or missed I something?
leo
But if you need to change the modified date to year 1998? How do you issue this command for an existing file?
It’s always dangerous to say something cannot be done, specially with linux, you can change the modification date to the past too, for 10/15/1998 12:30 the command would be something like this:
touch -t 19981015123000 file
The -m option will let you change only the modification timestamp without changing the accessed timestamp too.
It’s always dangerous to say something cannot be done, specially with linux, you can change the modification date to the past too, for 10/15/1998 12:30 the command would be something like this:
touch -t 19981015123000 file
The -m option will let you change only the modification timestamp without changing the accessed timestamp too.
Admin, touch only updates timestamps. It will create a new file /if it doesn’t exist already/. Please see the man page for touch by typing:
man touch
into a terminal, or by visiting http://linux.die.net/man/1/touch
In fact I would go so far as to say that Windows makes simple tasks like this unnecessarily difficult at times. Everything that a server administrator might want to do seems to be almost deliberately hidden under Windows, all the most basic things are completely impossible.
To instantly get an educated guess about a file’s contents? The command “file” in non-Windows systems.
To extract all printable strings from a file? “strings”. In Windows? Yeah, right. I guess you could open it in Notepad and try to view the contents as-is… Have you ever tried opening a large binary file in Notepad? Go on, try it, see what happens.
I want to see if 192.168.2.5 has visited /files/foo.html in the past month, I can just use cat and grep. Sure, in Windows you have type instead of cat (and it is a better name, too). Where’s grep under Windows?
I don’t think I could handle trying to do server administration under Windows.
Is Windows completely useless? No way! It’s great! That’s why it has 90% market share, it’s truly fantastic…. But in this day and age, it’s just not something you want to try to use for webserver administration. Look at simple tasks like changing the last modified time to a date in the past, apparently you have to go to extreme measures and even change the system clock! I mean that’s ridiculous.
Unless you’re circumventing security, there’s generally no reason to use one operating system to do things to another, at least in my personal experience. Linux comes with everything I need built in, and for Windows… Well, if I spend all day searching I can usually find an alternative eventually.
We are comparing Apples with Oranges. Each system has its own strengths and weaknesses, and someone with enough experience wearing both hats will tell you that there is nothing which you can do under Windows which you can’t do under other systems – and vice versa.
Admin, touch only updates timestamps. It will create a new file /if it doesn’t exist already/. Please see the man page for touch by typing:
man touch
into a terminal, or by visiting http://linux.die.net/man/1/touch
In fact I would go so far as to say that Windows makes simple tasks like this unnecessarily difficult at times. Everything that a server administrator might want to do seems to be almost deliberately hidden under Windows, all the most basic things are completely impossible.
To instantly get an educated guess about a file’s contents? The command “file” in non-Windows systems.
To extract all printable strings from a file? “strings”. In Windows? Yeah, right. I guess you could open it in Notepad and try to view the contents as-is… Have you ever tried opening a large binary file in Notepad? Go on, try it, see what happens.
I want to see if 192.168.2.5 has visited /files/foo.html in the past month, I can just use cat and grep. Sure, in Windows you have type instead of cat (and it is a better name, too). Where’s grep under Windows?
I don’t think I could handle trying to do server administration under Windows.
Is Windows completely useless? No way! It’s great! That’s why it has 90% market share, it’s truly fantastic…. But in this day and age, it’s just not something you want to try to use for webserver administration. Look at simple tasks like changing the last modified time to a date in the past, apparently you have to go to extreme measures and even change the system clock! I mean that’s ridiculous.
Unless you’re circumventing security, there’s generally no reason to use one operating system to do things to another, at least in my personal experience. Linux comes with everything I need built in, and for Windows… Well, if I spend all day searching I can usually find an alternative eventually.
We are comparing Apples with Oranges. Each system has its own strengths and weaknesses, and someone with enough experience wearing both hats will tell you that there is nothing which you can do under Windows which you can’t do under other systems – and vice versa.
(Sorry for the double comment)
Furthermore, how under Windows could you set that file’s last modified time to be updated by a script automatically? Under *nixes I know exactly how, you’d just use cron and touch, simple. Or apache + cgi or php or python or perl…. and maybe touch for good measure.
Under Windows????? Powershell can probably do it. It’s obscure though, I know Windows admins who didn’t know about it and don’t use it. PHP can do it under Windows too – http://php.net/touch – and in fact had better support for it on Windows at one point.
And yes, Windows does have a task scheduler (although I no longer have any idea how to access it without Microsoft Networking enabled)
Did you know these things? Maybe, just maybe, Windows might have a sensible way to do this after all like every other operating system? Apparently not:
http://www.codeproject.com/KB/applications/touch_win.aspx
Oh, well :-( sucks to be a Windows sysadmin then.
Nope, I cannot say that Windows is the best solution to change the modification time. It’s just one of the possible ideas, especially for newbies. Using touch is really great and I really appreciate the solutions posted here.
Nope, I cannot say that Windows is the best solution to change the modification time. It’s just one of the possible ideas, especially for newbies. Using touch is really great and I really appreciate the solutions posted here.