Monday, January 31, 2011
Display Past Date and Time
Display Current Date and Time in a Specific Format
Following are different ways of displaying the current date and time in
various formats:
$ date
Thu Jan 1 08:19:23 PST 2009
$ date --date="now"
Thu Jan 1 08:20:05 PST 2009
$ date --date="today"
Thu Jan 1 08:20:12 PST 2009
$ date --date='1970-01-01 00:00:01 UTC +5 hours' +%s
18001
$ date '+Current Date: %m/%d/%y%nCurrent Time:%H:%M:%S'
Current Date: 01/01/09
Current Time:08:21:41
$ date +"%d-%m-%Y"
01-01-2009
$ date +"%d/%m/%Y"
01/01/2009
$ date +"%A,%B %d %Y"
Thursday,January 01 2009
Following are the different format options you can pass to the date
command:
o %D date (mm/dd/yy)
o %d day of month (01..31)
o %m month (01..12)
o %y last two digits of year (00..99)
o %a locale’s abbreviated weekday name (Sun..Sat)
o %A locale’s full weekday name, variable length
(Sunday..Saturday)
o %b locale’s abbreviated month name (Jan..Dec)
o %B locale’s full month name, variable length
(January..December)
o %H hour (00..23)
o %I hour (01..12)
o %Y year (1970…)
Friday, January 21, 2011
Set Hardware Date and Time
Set System Date and Time
Thursday, January 20, 2011
Use “shopt -s cdspell” to automatically correct mistyped directory names on cd
Use dirs, pushd and popd to manipulate directory stack
You can use directory stack to push directories into it and later pop directory
from the stack. Following three commands are used in this example.
o dirs: Display the directory stack
o pushd: Push directory into the stack
o popd: Pop directory from the stack and cd to it
Dirs will always print the current directory followed by the content of the
stack. Even when the directory stack is empty, dirs command will still print
only the current directory as shown below.
# popd
-bash: popd: directory stack empty
# dirs
~
# pwd
/home/ramesh
How to use pushd and popd? Let us first create some temporary directories
and push them to the directory stack as shown below.
# mkdir /tmp/dir1
# mkdir /tmp/dir2
# mkdir /tmp/dir3
# mkdir /tmp/dir4
# cd /tmp/dir1
# pushd .
# cd /tmp/dir2
# pushd .
# cd /tmp/dir3
# pushd .
# cd /tmp/dir4
# pushd .
# dirs
/tmp/dir4 /tmp/dir4 /tmp/dir3 /tmp/dir2 /tmp/dir1
[Note: The first directory (/tmp/dir4) of the dir
command output is always the current directory and not
the content from the stack.]
# dirs
/tmp/dir4 /tmp/dir4 /tmp/dir3 /tmp/dir2 /tmp/dir1
[Note: The first directory (/tmp/dir4) of the dir
command output is always the current directory and not
the content from the stack.]
At this stage, the directory stack contains the following directories:
/tmp/dir4
/tmp/dir3
/tmp/dir2
/tmp/dir1
The last directory that was pushed to the stack will be at the top. When you
perform popd, it will cd to the top directory entry in the stack and remove it
from the stack. As shown above, the last directory that was pushed into the
stack is /tmp/dir4. So, when we do a popd, it will cd to the /tmp/dir4 and
remove it from the directory stack as shown below.
# popd
# pwd
/tmp/dir4
[Note: After the above popd, directory Stack Contains:
/tmp/dir3
/tmp/dir2
/tmp/dir1]
# popd
# pwd
/tmp/dir3
[Note: After the above popd, directory Stack Contains:
/tmp/dir2
/tmp/dir1]
# popd
# pwd
/tmp/dir2
[Note: After the above popd, directory Stack Contains:
/tmp/dir1]
# popd
# pwd
/tmp/dir1
[Note: After the above popd, directory Stack is empty!]
# popd
-bash: popd: directory stack empty
Wednesday, January 19, 2011
Perform mkdir and cd using a single command
Use cd alias to navigate up the directory effectively
Use CDPATH to define the base directory for cd command
Monday, January 17, 2011
Linux Kernel 2.6.37 Released
Another year has passed and thus another new kernel release by Linus. As expected, Linus finally released the final Linux Kernel 2.6.37 as of today after having several RC release before Christmas and eventually it didn't make it as Christmas gift for everyone, so let's just consider this as a new year gift. Fair enough.
At this moment, the link on Kernel.org hasn't showed up, but you can still download it by clicking on this link. More information about what has been included in this release in human-friendly language can be seen inKernelNewbies (give some tim to update the page as the kernel has just been released).
Now, time to look for patches for NVidia and VMWare if i wanted to compile this kernel
Thursday, January 13, 2011
open port in microtik
Mikrotik on setting the default to open five ports to access the server, to see the open ports can use the command:
/ip service pr
It will look something like this
01 | [admin@MikroTik] > /ip service pr |
02 | Flags: X - disabled, I - invalid |
03 | # NAME PORT ADDRESS |
04 | 0 telnet 23 0.0.0.0/0 |
05 | 1 ftp 21 0.0.0.0/0 |
06 | 2 www 80 0.0.0.0/0 |
07 | 3 ssh 22 0.0.0.0/0 |
08 | 4 X www-ssl 443 0.0.0.0/0 |
09 | 5 X api 8728 0.0.0.0/0 |
10 | 6 winbox 8291 0.0.0.0/0 |
suppose we want to close the ports for telnet, the command used is:
1 | /ip service set telnet disabled=yes |
ketik :
1 | /ip service pr |
and shall appear the sign x in the telnet, as in www-ssl and API.
want to open the port if disabled = no
1 | /ip service set telnet disabled=yes |
Cwim