Wednesday, August 8, 2012

Disable su for users not in wheel group

You can disable the su option for users not in wheel group.

vim /etc/pam.d/su

#auth           required        pam_wheel.so use_uid


Uncomment this line , Save and exit.  There after the users cannot use su option, will display incorrect password.

Monday, August 6, 2012

Set the shell prompt with your messages using PROMPT_COMMAND

You can use the PROMPT_COMMAND to make your current shell displaying a message of your own ideas.

Here ''Have a wonderful day" is my message.


[root@tester ~]# PROMPT_COMMAND="echo Have a wonderful day"
Have a wonderful day

[root@tester ~]# date
Mon Aug  6 21:35:43 IST 2012
Have a wonderful day

[root@tester ~]# cat /etc/issue

Red Hat Enterprise Linux Server release 5.1 (Tikanga)
Kernel \r on an \m

Have a wonderful day

[root@tester ~]# unset
Have a wonderful day

[root@tester ~]# date
Mon Aug  6 21:36:35 IST 2012
Have a wonderful day


[root@tester ~]# PROMPT_COMMAND=" "
[root@tester ~]# date
Mon Aug  6 21:37:16 IST 2012

All the countries time can be checked in linux with the single command "tzselect"

[root@tester ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 2
Please select a country.
 1) Anguilla              18) Ecuador               35) Paraguay
 2) Antigua & Barbuda     19) El Salvador           36) Peru
 3) Argentina             20) French Guiana         37) Puerto Rico
 4) Aruba                 21) Greenland             38) St Kitts & Nevis
 5) Bahamas               22) Grenada               39) St Lucia
 6) Barbados              23) Guadeloupe            40) St Pierre & Miquelon
 7) Belize                24) Guatemala             41) St Vincent
 8) Bolivia               25) Guyana                42) Suriname
 9) Brazil                26) Haiti                 43) Trinidad & Tobago
10) Canada                27) Honduras              44) Turks & Caicos Is
11) Cayman Islands        28) Jamaica               45) United States
12) Chile                 29) Martinique            46) Uruguay
13) Colombia              30) Mexico                47) Venezuela
14) Costa Rica            31) Montserrat            48) Virgin Islands (UK)
15) Cuba                  32) Netherlands Antilles  49) Virgin Islands (US)
16) Dominica              33) Nicaragua
17) Dominican Republic    34) Panama
#? 10
Please select one of the following time zone regions.
 1) Newfoundland Time, including SE Labrador
 2) Atlantic Time - Nova Scotia (most places), PEI
 3) Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971
 4) Atlantic Time - New Brunswick
 5) Atlantic Time - Labrador - most locations
 6) Atlantic Standard Time - Quebec - Lower North Shore
 7) Eastern Time - Quebec - most locations
 8) Eastern Time - Ontario - most locations
 9) Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
10) Eastern Time - Thunder Bay, Ontario
11) Eastern Time - east Nunavut - most locations
12) Eastern Time - Pangnirtung, Nunavut
13) Eastern Time - Resolute, Nunavut
14) Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
15) Central Time - central Nunavut
16) Central Time - Manitoba & west Ontario
17) Central Time - Rainy River & Fort Frances, Ontario
18) Central Time - west Nunavut
19) Central Standard Time - Saskatchewan - most locations
20) Central Standard Time - Saskatchewan - midwest
21) Mountain Time - Alberta, east British Columbia & west Saskatchewan
22) Mountain Time - central Northwest Territories
23) Mountain Time - west Northwest Territories
24) Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
25) Pacific Time - west British Columbia
26) Pacific Time - south Yukon
27) Pacific Time - north Yukon
#? 21

The following information has been given:

        Canada
        Mountain Time - Alberta, east British Columbia & west Saskatchewan

Therefore TZ='America/Edmonton' will be used.
Local time is now:      Mon Aug  6 09:49:49 MDT 2012.
Universal Time is now:  Mon Aug  6 15:49:49 UTC 2012.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
        TZ='America/Edmonton'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
America/Edmonton