Wednesday, June 4, 2008

Displaying message of the day (motd)

When you have logged to your machine through ssh, this is what you will always see after each successful access:

Last login: Tue Jun 3 13:17:35 2008 from 10.20.20.171
[user@server ~]$

You can have additional message displayed like this, by using message of teh day (motd):

Last login: Wed Jun 4 14:59:13 2008 from 10.20.20.241
This is a my server!!!!!!
[user@server ~]$

Here are the steps to do it:

  1. Open /etc/motd using your favorite text editor. I will use vi
    • vi /etc/motd
  2. Append your message to the file and save
    • This is a my server!!!!!!
  3. Then, when this will be displayed when you access your machine again
    • Last login: Wed Jun 4 14:59:13 2008 from 10.20.20.241
      This is a my server!!!!!!
      [user@server ~]$
Have fun....:)

Tuesday, June 3, 2008

Shell scripting built-in variables

When doing scripting in shell, like bash, there are a few built-in variables that we can use to optimize our script. Below are a few useful ones:

  • $$ = The PID number of the process executing the shell.
  • $? = Exit status variable.
  • $0 = The name of the command you used to call a program.
  • $1 = The first argument on the command line.
  • $2 = The second argument on the command line.
  • $n = The nth argument on the command line. n = 0-9
  • $* = All the arguments on the command line.
  • $# = The number of command line arguments.
Hope this can help

Creating banner for ssh server

A banner for ssh server is a few phrase that will come out the time you want to access a server through ssh. By default, this feature is turned off. To turned it on:

  1. Login as 'root'
  2. Create your banner file first. In this example, i will create banner file named /home/banner
    • # vi /home/banner
    • Insert your banner message to the file. I will insert 'Welcome to my pc'
  3. After you have finish with the banner file, open /etc/sshd_config
    • # vi /etc/sshd_config
    • Uncomment or add the following line
      • Banner /home/banner
  4. Restart ssh server
    • # /etc/init.d/sshd restart
  5. When you login, this will be displayed
    • # ssh pingu@10.20.20.171
      Welcome to my pc
      pingu@10.20.20.171's password:

Monday, May 26, 2008

The mystery of quotes

In linux environment, there are 3 types of quotes as far as i know. Each of the quotes bring different meaning and usage.

  1. ' a.k.a. single quotes - Everything wrapped in this quote won't be changed (Strong quotes)
  2. " a.k.a. double quotes - Quotes that doesn't expand meta-characters like "*" or "?," but does expand variables and does command substitution (Weaker quotes)
  3. ` a.k.a. back quotes - To execute command
Examples of quotes usage (top lines are commands and the output are displayed below the commands):

Example of using back quotes within single quotes. Nothing is changed.
$ echo 'Today is `date`'
Today is `date`

Example of using back quotes within double quotes. The `date` command will be executed
$ echo "Today is `date`"
Today is Mon May 26 09:42:50 MYT 2008

Wednesday, May 14, 2008

Fedora 9 is here

Fedora 9 is already available. Get your copy here. A brief introduction to fedora:

" Fedora is a Linux-based operating system that showcases the latest in free and open source software. Fedora is always free for anyone to use, modify, and distribute. It is built by people across the globe who work together as a community: the Fedora Project. The Fedora Project is open and anyone is welcome to join.

The Fedora Project is out front for you, leading the advancement of free, open software and content. "