Linux Online Advertisement
[ Register ]

[ Applications ]
[ Documentation ]
[ Distributions ]
[ Download Info ]
[ General Info ]
[ Book Store ]

Advertisement

[ Courses ]
[ News ]
[ People ]
[ Hardware ]
[ Vendors ]
[ Projects ]
[ Events ]
[ User Groups ]
[ User Area ]

Moving to Linux: Kiss the Blue Screen of Death Goodbye!

[ About Us ]
[ Home Page ]
[ Advertise ]

Getting Started with Linux - Lesson 9

Other interesting and useful commands

The command 'touch'

Now we're going to talk about a touchy subject. The command 'touch' which is used to change the time and/or date of a file.

You can use 'touch' if your boss yells at you about not having a report ready at lunchtime. You should quickly finish the report, then type:

touch -t 05070915 my_report.txt

and it makes it look like you did it at 9:15. The first four digits stand for May 7 (0507) and the last four (0915) the time, 9:15 in the morning. Make sure your digits match your story. You don't want to have it look like you did it in February. Of course, if you punched in at 9:40, then you're in trouble.

'touch' can be used also to create an empty file. You would just enter touch [a file name]. There may be times in the future when you need an empty file that will be filled up later automatically by the workings of some program. We'll deal with the uses of 'touch' in our later courses.

Finding things with the command 'find'

There's so much on a computer's hard drive, nobody could ever know from memory where everything is. Perhaps the smart lad who won the spelling bee by spelling 'prestidigitator' might be able to, but most of us are going to have to find things now and then.

If you use a windows manager like KDE, you can use the find tool. It's very useful because it has a lot of options and you can use them to modify your searches.

How to use the 'find' command

But if you're getting used to using command line stuff, just type in:

find -name *hawaii*

and find out where you put you pictures of you Hawaiian vacation. If you're in your /home directory, it will go through every directory and find every file that has the name 'hawaii' in it. The two asterisks make sure it does that. If they started with 'hawaii' you wouldn't need the first asterisk but you can leave it there if you want.

You may have created some file recently. For example, you may want to find some file that you were working on, let's say from now up to 10 minutes ago, you could type.

find -mmin +0 -mmin -10

This will list the files that you created or modified within the last ten minutes. If you choose to use a higher number for -mmin -? you should probably use a pipe, for example:

find -mmin +0 -mmin -120 | less

will find things that you created or modified up to 2 hours ago and the '| less' part will make it easier to read.

[Previous] [Next]




Comments: feedback (at) linux.org
Advertising: banners (at) linux.org
Copyright Linux Online Inc.
Compilation ©1994-2008 Linux Online, Inc.
All rights reserved.