Thursday, May 21, 2009

Cron and Crontab commands

The cron command starts a process that schedules command execution at specified dates and times.

crontab - maintain crontab files for individual users.Similar to other commands this to have options .
-u It specifies the name of the user whose crontab is to be tweaked.
-l The current crontab will be displayed on standard output.
-r The current crontab will be be removed.
-e This option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables.

Usage :
#crontab -u [user_name] - e
An entry under crontab for user specified by the user_name will be made and saved automatically on exiting the editor.
#crontab -u [user_name] - l
Shows the cron jobs for the user specified.

The cron jobs deceleration needs to be done in a 5 column format consisting of
  1. minute (0-59)
  2. hour (0-23)
  3. day of the month (1-31)
  4. month of the year (1-12)
  5. day of the week (0-6 with 0=Sunday)
Taking the example that if the 'root' user desires to setup a cron job,which displayes massage "Hello Jack" on the user's [Jack] terminal at 01:45 AM everyday ,the process will go like this

#crontab -u jack - e
45 01 * * * /bin/echo "Hello Saurabh"
save and exit using ':wq' if using VI editor.

Viewing the cron job to edit
#crontab -u jack - l

Deleting the cronjob
#crontab -u jack - r

Shorthand at the Linux CLI

Some of the very useful shortcuts of the CLI are
  • / :- root directory
  • ./ :- current directory
  • ./command_name :- run a command in the current directory when the current directory is not on the path
  • ../ :- parent directory
  • ~ :- home directory
  • $ :- typical prompt when logged in as ordinary user
  • # :- typical prompt when logged in as root or superuser
  • ! :- repeat specified command
  • !! :- repeat previous command
  • ^^ :- repeat previous command with substitution
  • & :- run a program in background mode
  • [Tab][Tab] :- prints a list of all available commands. This is just an example of autocomplete with no restriction on the first letter.
  • x[Tab][Tab] :- prints a list of all available completions for a command, where the beginning is ``x''
  • [Alt][Ctrl][F1] :- switch to the first virtual text console
  • [Alt][Ctrl][Fn] :- switch to the nth virtual text console. Typically, there are six on a Linux PC system.
  • [Alt][Ctrl][F7] :- switch to the first GUI console, if there is one running. If the graphical console freezes, one can switch to a nongraphical console, kill the process that is giving problems, and switch back to the graphical console using this shortcut.
  • [ArrowUp] :- scroll through the command history (in bash)
  • [Shift][PageUp] :- scroll terminal output up. This also works at the login prompt, so you can scroll through your boot messages.
  • [Shift][PageDown] :- scroll terminal output down
  • [Ctrl][Alt][+] :- switch to next X server resolution (if the server is set up for more than one resolution)
  • [Ctrl][Alt][-] :- change to previous X server resolution
  • [Ctrl][Alt][BkSpc] :- kill the current X server. Used when normal exit is not possible.
  • [Ctrl][Alt][Del] :- shut down the system and reboot
  • [Ctrl]c :- kill the current process
  • [Ctrl]d :- logout from the current terminal
  • [Ctrl]s :- stop transfer to current terminal
  • [Ctrl]q :- resume transfer to current terminal. This should be tried if the terminal stops responding.
  • [Ctrl]z :- send current process to the background
  • reset :- restore a terminal to its default settings
  • [Leftmousebutton] :- Hold down left mouse button and drag to highlight text. Releasing the button copies the region to the text buffer under X and (if gpm is installed) in console mode.
  • [Middlemousebutton] :- Copies text from the text buffer and inserts it at the cursor location. With a two-button mouse, click on both buttons simultaneously. It is necessary for three-button emulation to be enabled, either under gpm or in XF86Config.

Sunday, April 12, 2009

Flash installation for better browsing experience

Allof the following steps should be done as ROOT user in terminal
1) Download the package for Yum repo configuration on your machine,using
wget http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
2) Once the download is complete,run command
# rpm -ivh adobe-release-i386-1.0-1.noarch.rpm
3) Now your box is configured to use flash plufuns available from ADOBE
4) To install flash ,just type in
# yum install flash-plugin
5) Verify that flash have installed close the browser instances and reopen them and browse the following page.
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15507
6) To update the flash plugin in future just type in as ROOT
# yum update flash-plugin

Labels: ,

Few good URL's

Root Login Not Possible

Few wrong settings that can prevent the 'Root' user to login to the linux box are
1) The Shell
Check for the login shell that the system is offering to the 'Root' user.
Steps for checking this
i) Log in to the system in a single user mode.Help
ii) Check for login shell under the /etc/passwd using following
# grep root /etc/passwd
in the results look for the line starting with 'root' check for the last entry considering ':' as a delimiter.
iii) If the entry is '/sbin/nologin' that means the root user is not being provided a shell that enables a user to login to the system and perform tasks.We need to change this shell to /bin/bash so that user is allowed to login.
iv) To change this we need to fire a single command.
# usermod -s /bin/bash root
this command will change the shell for the root user to /bin/bash as desired.
v) The new shell can be cross checked by running the command used previously in step ii.
# grep root /etc/passwd
this time the last entry should be /bin/bash.

2) Permissions of /etc/securetty file
For the root user to login to the machine the file /etc/securetty should be having follwing either 600 or 644 set as the permissions.So first we need to check the present permissions of the file.This is as sinple a viewing the listing of files.
# ls -l /etc/securetty
the first column of the listing should be somewhat similar to -rw------- which means the value is set to 600.
In case if this value is not one of 600 or 644 then we need to change that by using ollowing commmand.
# chmod 600 /etc/securetty
Cross check can be done to see if the file permissions have been modified by again viewing the permissions as above.

3) No terminal entry in /etc/securetty should be commented.
Open the file /etc/securetty using vi editor.Check to insure that no line in there is commented.If there is any uncomment it ,save the file and exit.
For editing the contents of the file working with vi editor should be known.
PS :A very good post at The linux Documentation Project explains the use of VI .

4)Check for account details.
The next check to be done is for the account details for the root user.Over-here first of all we will check for the present account details of the user.
# chage -l root
The command will list account information about the root user.Check for the dates and insure that there should be none offending.the default and good settings are
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

if we take as an example that Account expires have a value of date earlier to today, it's very much clear that the account is no longer existing.But since the root user account should not be expred we need to change the value of this paramter to its default value of never.

Labels: ,

single user mode

Steps for entering the single user mode.
i) Reboot the machine,at GRUB [Boot Loader] there will be the listing of the Kernel selection.
ii) Select the version of the kernel that you wish to boot and type e for edit. A list of items in the configuration file for the Kernel you just selected will show up.
iii) Select the line that starts with kernel and type e to edit the line.
iv) At the end of this line, giving the Space type-in 1. Press [Enter] to exit edit mode.
v) Once back at the GRUB screen, type b to boot into single user mode.

Saturday, February 28, 2009

Changing Panel Color Scheme

After a lot of fight to locate the a simple hack to change the panel colour scheme,instead of installing another application for this, finally got the answer as a '.gtkrc-2.0' file with colour definitions for panel.

All needed is to create a simple file with name as .gtkrc-2.0, the definition fg[NORMAL] = "#ffffff" defines the foreground colour [Font Colour] to be white [#ffffff].This value can be set to any value per your needs.A list of hex values for different colours are available at http://www.free-webmaster-tools.com/colorpicker.htm.

Steps to create this file, and change the colour . Per this example font colour will be changed.

1. Go to your home directory,using the terminal. [ cd ~ ]
2. vi .gtkrc-2.0
3. Go to the Insert mode of vi editor by pressing in INSERT key,
4. -- INSERT --,should appear at the bottom left corner of the terminal screen.
5. Copy the mentioned contents and paste in the file.
6. Press Esc. key followed by [:wq] to save the changes made to the file.
7. Type in following lines at prompt,this will reload the settings done to panel UI.
8. killall gnome-panel
9. Once done,you are now having your new colour scheme.


Contents of file [.gtkrc-2.0] :
style "panel"
{
fg[NORMAL] = "#ffffff"
# fg[PRELIGHT] = "#000000″
# fg[ACTIVE] = "#ffffff”
# fg[SELECTED] = "#000000″
# fg[INSENSITIVE] = "#8A857C”
# bg[NORMAL] = "#000000″
# bg[PRELIGHT] = "#dfdfdf”
# bg[ACTIVE] = "#D0D0D0″
# bg[SELECTED] = "#D8BB75″
# bg[INSENSITIVE] = "#EFEFEF”
# base[NORMAL] = "#ffffff”
# base[PRELIGHT] = "#EFEFEF”
# base[ACTIVE] = "#D0D0D0″
# base[SELECTED] = "#DAB566″
# base[INSENSITIVE] = "#E8E8E8″
# text[NORMAL] = "#161616″
# text[PRELIGHT] = "#000000″
# text[ACTIVE] = "#000000″
# text[SELECTED] = "#ffffff”
# text[INSENSITIVE] = "#8A857C”
}
widget "*PanelWidget*" style "panel"
widget "*PanelApplet*" style "panel"
class "*Panel*" style "panel"
widget_class "*Mail*" style "panel"
class "*notif*” style "panel"
class "*Notif*” style "panel"
class "*Tray*” style "panel"
class "*tray*” style "panel"

Labels: , ,