Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 182009
 

How to find where a command is stored in Linux

Answer:

To find out where a command is stored in Linux, you can use the which command to locate the command

# which wget
/usr/bin/wget

or use whereis command to locate the binary/source/manual

# whereis wget
wget: /usr/bin/wget /usr/share/man/man1/wget.1.gz

Jan 172009
 

How to change the owner of a file in Linux

Answer:

You need to use the chown command:

1. To change the owner of text.txt to john

# chown john /tmp/text.txt

2. To change the owner of text.txt to john, but group identifier to admin.

# chown john:admin /tmp/text.txt

3. To change the group of text.txt to admin

# chown :admin /tmp/text.txt

Reference: http://en.wikipedia.org/wiki/Chown

Jan 072009
 

Becareful when using the mtime option in find command

Answer:

A simple command like the following is very handy when finding all the files in the current directory which have been modified within 1 day.

# find -type f -mtime -1

But the above interpretation is simply wrong!

The real meaning of the above command is: Find all the files in the current directory which have been modified less than 2 days.

So if a file is modified before 1.9999999.. day, it still match the above command since the fractional part is ignored.

Try it yourself if you don't believe.

Reference:

man find