Display a Calendar in the Terminal Window

How Do I Display a Calendar in the Terminal Window

For those who love the command line, the cal command helps display a calendar. It can show the calendar in a variety of ways like yearly or monthly.

Show the current month Code:
cal

Result:

     July 2013
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Show a specific month

Code:

cal 08 1983

Result:

    August 1983
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Show the current year

Code:

cal -y 2013

Result:

                            2013
      January               February               March
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
       1  2  3  4  5                  1  2                  1  2
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   3  4  5  6  7  8  9
13 14 15 16 17 18 19  10 11 12 13 14 15 16  10 11 12 13 14 15 16
20 21 22 23 24 25 26  17 18 19 20 21 22 23  17 18 19 20 21 22 23
27 28 29 30 31        24 25 26 27 28        24 25 26 27 28 29 30
                                            31
       April                  May                   June
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6            1  2  3  4                     1
 7  8  9 10 11 12 13   5  6  7  8  9 10 11   2  3  4  5  6  7  8
14 15 16 17 18 19 20  12 13 14 15 16 17 18   9 10 11 12 13 14 15
21 22 23 24 25 26 27  19 20 21 22 23 24 25  16 17 18 19 20 21 22
28 29 30              26 27 28 29 30 31     23 24 25 26 27 28 29
                                            30
        July                 August              September
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6               1  2  3   1  2  3  4  5  6  7
 7  8  9 10 11 12 13   4  5  6  7  8  9 10   8  9 10 11 12 13 14
14 15 16 17 18 19 20  11 12 13 14 15 16 17  15 16 17 18 19 20 21
21 22 23 24 25 26 27  18 19 20 21 22 23 24  22 23 24 25 26 27 28
28 29 30 31           25 26 27 28 29 30 31  29 30                                            
      October               November              December
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
       1  2  3  4  5                  1  2   1  2  3  4  5  6  7
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   8  9 10 11 12 13 14
13 14 15 16 17 18 19  10 11 12 13 14 15 16  15 16 17 18 19 20 21
20 21 22 23 24 25 26  17 18 19 20 21 22 23  22 23 24 25 26 27 28
27 28 29 30 31        24 25 26 27 28 29 30  29 30 31

 Deploying a Rails application on CentOS

I love Ubuntu. “Why not?”, you may ask. Well, the only reason is that I have worked almost exclusively with Ubuntu when deploying Rails applications.

Aside from the point that it’s easier and most tutorials on the internet involve Ubuntu deployment, at my current company, we only use Ubuntu on our staging and production server.

I always had the notion that deployment on other Linux distributions would be hard. It turns out, they may not be that different at all. Here’s the deployment recipe I’m using to deploy on CentOS 6.

Update CentOS

yum update

Install requirements

yum -y groupinstall "Development Tools"

groupinstall "Development Tools" will install necessary tools to create a basic development environment. Next step would be to make sure we don’t miss out on some other tools.

yum -y install ntp zlib zlib-devel sqlite-devel httpd mysql-server mysql-devel curl-devel httpd-devel apr-devel apr-util-devel mlocate manlibxml2-devel libxslt-devel libffi-devel readline-devel gcc gcc-c++ make openssl-devel sqlite-devel
/etc/init.d/ntpd stop
ntpdate pool.ntp.org
/etc/init.d/ntpd start
chkconfig ntpd on

Install Ruby

We are using ruby version 1.9.3 because Passenger 4.0 can’t work with 2.0.0 yet.

wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p429.tar.gz
tar zxf ruby-1.9.3-p429.tar.gz
cd ruby-1.9.3-p429
./configure
make
make install
cd ext/openssl
ruby extconf.rb
make
make install
cd ../zlib
ruby extconf.rb
make
make install
cd ../readline
ruby extconf.rb
make
make install
cd
gem update --system
Hiccups

If you are presented by this error:

It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

A simple fix would be to install libyaml.

curl -O http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/atomic-release-1.0-14.el6.art.noarch.rpm
sudo  rpm -Uvh atomic-release-1.0-14.el6.art.noarch.rpm
sudo yum install libyaml-devel

And then reinstall Ruby.

Install Rails and Passenger

gem install rails passenger

Install the Passenger and Apache module

passenger-install-apache2-module

After installation, you will be presented by some text(see below) you need to add to your Apache config file, which can be found here, /etc/httpd/conf/httpd.conf.

Load Module
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.5
PassengerDefaultRuby /usr/local/bin/ruby

You will also be presented by an Apache configuration file that you can modify and use for your virtual host

Virtual Host file
<VirtualHost *:80>
    ServerName www.yourhost.com
    # !!! Be sure to point DocumentRoot to 'public'!
    DocumentRoot /somewhere/public    
    <Directory /somewhere/public>
       # This relaxes Apache security settings.
       AllowOverride all
       # MultiViews must be turned off.
       Options -MultiViews
    </Directory>
 </VirtualHost>

Restart Apache

Now if everything goes well, you can restart Apache.

Visit your url and voila! A newly deployed Rails Application!

Visit the Passenger site for more Information about Deploying Rails with Passenger on Apache

 Starting, Stopping and Restarting Apache2

It will be more and more common as we add modules, settings to Apache2 to restart Apache2. You will need to start and stop the server when needed.

You have a few scripts available for this common tasks.

apachectl restart

This will restart the server. If the server isn’t running, it will start it.

apachechtl stop

The server would be stopped immediately

apachectl graceful

The server would be stopped. However, the server would allow connections in progress to be completed. Again, the server would also be restarted it isn’t.

apachectl start

This will start the server.

There is a convenient to start services in most Unix systems, service.

restarts the server

service apache restart

stops the server

service apache stop

starts the server

service apache start

In Fedora based systems, Red Hat and CentOS, there may be a slight change of commands

restarts the server

service httpd restart

stops the server

service httpd stop

starts the server

service httpd start

 Enable Mod Rewrite in Apache2 on Ubuntu

I have been working intensely with Apache2 for a few days and learning the ins and outs of Apache2.

Mod Rewrite is an Apache module used to modify urls in most CMSs like Wordpress.

Configuration for Apache2 can be found at /etc/apache2/. In Apache2, if you need to enable modules you need to copy files from /etc/apache2/mods-available/ to /etc/apache2/mods-enabled/.

Enable Mod Rewrite

Now we are ready to enable Mod Rewrite. Type the following commands:

cd /etc/apache2/
cp mods-available/rewrite.load mods-enabled/rewrite.load

The above would copy the module to the mods-enabled folder. Another option would be to create a symbolic links.

cd /etc/apache2/
ln -s mods-available/rewrite.load mods-enabled/rewrite.load

Restart Apache

All changes would not take effect until we restart Apache2.

service apache2 restart

Mod Rewrite Enabled!

Note

In Debian based systems, modules can be enabled and disabled at will using utilities provided by Debian’s Apache distribution. In our case, if you are using Debian, you can use the following command to load the Rewrite Module.

a2enmod rewrite

Good luck!