How to find Files that are Modified today in Unix / Linux

To find all files that was modified since a specific time ago (i.e an hour ago, a day ago, 24 hours ago, a weeks ago, a month ago and so on) in Unix and Linux environment, the find command will come in handy. The command syntax is:

To find all files modified in the last 24 hours (last full day) in current directory and its sub-directories:

find . -mtime -1 -print

Flag -mtime -1 option tells find command to look for files modified in the last day (24 hours). Flag -print option will cause find command to print the files’ location. -print can be replaced with -ls if you want a directory-listing-type response.

To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:

find /directory_path -mtime -1 -print

The command is basically the same with the earlier command, just that now you no need to cd (change directory) to the directory you want to search.

To find all files with regular file types only, and modified in the last 24 hours (last full day) in current directory and its sub-directories:

find /directory_path -type f -mtime -1 -print

Find files Modified 4 days ago on linux

To find all files that are modified today only (since start of day only, i.e. 12 am), in current directory and its sub-directories:

touch -t `date +%m%d0000` /tmp/$$
find /tmefndr/oravl01 -type f -newer /tmp/$$
rm /tmp/$$

The first command can be modified to specify other date and time, so that the commands will return all files that have changed since that particular date and time.

'Coz sharing is caring

How to set up Virtual Hosts in Apache

Setting up Virtual Hosts in Apache on Mac OSX is straight forward after you have your local Web Development environment up and running. The process of setting up Virtual Hosts is done easily in the Terminal either using nano or vi with sudo or as a root user.

Allow the vhosts configuration from the Apache configuration file httpd.conf

Open the httpd.conf

sudo nano /etc/apache2/httpd.conf

Search for ‘vhosts‘ and uncomment the include line

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf</pre>

Also allow another module to run by uncommenting:

LoadModule vhost_alias_module libexec/apache2/

Edit the vhosts.conf file

Open this file to add in the virtual host.

sudo nano /etc/apache2/extra/httpd-vhosts.conf

An example domain in the file is given of the format required to add in additional domains, just follow this to create your new virtual host:

<VirtualHost *:80>
  DocumentRoot "/usr/docs/"
  ErrorLog "/private/var/log/apache2/"
  CustomLog "/private/var/log/apache2/" common

We can take this example and extend on it, if you wanted a domain named for example, you can copy the existing text block and edit to suit:

<VirtualHost *:80>
  DocumentRoot "/Users/USERNAME/Sites/apple"
  ErrorLog "/private/var/log/apache2/"
  CustomLog "/private/var/log/apache2/" common

So in the example above a vhost for is created and the document root is in the Sites folder, in the text block above I have also added in some log files, what you need to change is the document root location username and domain name to suit your needs. Finish and save the file.

Now also you need to map the IP address to be the localhost.

Map Your IP address to localhost

sudo nano /etc/hosts

Add the Domain and ‘www‘ alias to resolve to the localhost address

Restart Apache

sudo apachectl restart

Check out your local vhost domain in the browser

Losing Localhost

One caveat to note about virtual hosts is that once set up you lose your older document root previously at/Library/WebServer/Documents or accessed in the browser at http://localhost what happens is that you get a 403 Forbidden Error. But the ~/username document root is still compatible.

To get around this, you need to add in a vhost for localhost and declare this vhost before any of the others, in the same file:

sudo nano /etc/apache2/extra/httpd-vhosts.conf

Add in:

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot /Library/WebServer/Documents/

Restart Apache

sudo apachectl restart

Changing the WebServer Default User

One of the frustrations of using the Users/username/Sites folder for vhosts is the permissions issues with things like updates and authentication.

This is because the default webserver user which runs httpd is known as _www, which will not be the user in your local account. If your machine is only in use by you and the webserver will run only under your account then you can change the user.

Find Your User and Group

In the Terminal use the id command to see your username and group

 id (use this command)

You will get a bunch of user groups, you need your primary user uid and group gid names

uid=502(<mark>swatantra</mark>) gid=20(<mark>staff</mark>)

Change this back in /etc/apache2/httpd.conf


Restart Apache

sudo apachectl restart

Restart Apache and now you are running httpd as your local account.

'Coz sharing is caring

Logging WWWTF