Wednesday, May 26, 2010

How to make a permanent hostname for a redhat linux system

To make a permanent hostname for a redhat linux system, edit the following file
# vi /etc/sysconfig/network

save this file. Now check the file /etc/hosts, it contain the old hostname, change/delete it.

restart the network service.
# service network restart

Logout and then login again.


Tuesday, May 25, 2010

root, sudo and shells

To start a root shell, starting root's environment and login scripts, use:
sudo -i
This is similar to sudo su - , gives you roots environment configuration.

To start a root shell, but keep the current shell's environment, use:
sudo -s 
This is similar to sudo su


Monday, May 24, 2010

How to disable root login (or any user's login)

If you want to disable root user's login (or any other user's login), you can change his/her home directory to /sbin/nologin or /bin/false.

Now user can not login into any shell.


Wednesday, May 19, 2010

execute a program periodically

To execute a program periodically, you can use 'watch' command

watch runs command periodically, displaying its output. This allows you to watch the command output change over time.
By default, the command is run every 2 seconds. Use -n or --interval to specify a different interval.


watch df -h
checks free disk space in every 2 seconds.

watch -n 5 df -h
checks free disk space in every 5 seconds.


Tuesday, May 18, 2010

sudo: cannot get working directory

sudo problem
sudo: cannot get working directory


at terminal type 'cd' and press enter


Sun Virtual Box -Tips n Tricks

Access windows folders in linux guest OS using Share folders in Sun Virtual Box
In linux you can use mount command to access windows share

mount -t vboxsf  share  mountpoint

where share is the name of shared folder in windows and mount point is the directory where you want to mount the share.

mount -t  vboxsf   mypic  /mnt/pictures/

Linux File Structure

Linux File Structure

  • root - The home directory for the root user
  • home - Contains the user's home directories
  • bin - Commands needed during bootup that might be needed by normal users
  • sbin - Like bin but commands are not intended for normal users. Commands run by LINUX.
  • proc - This filesystem is not on a disk. It is a virtual filesystem that exists in the kernels imagination which is memory.

    • 1 - A directory with info about process number 1. Each process has a directory below proc.
  • usr - Contains all commands, libraries, man pages, games and static files for normal operation.

    • bin - Almost all user commands. some commands are in /bin or /usr/local/bin.
    • sbin - System admin commands not needed on the root filesystem. e.g., most server programs.
    • include - Header files for the C programming language. Should be below /user/lib for consistency.
    • lib - Unchanging data files for programs and subsystems
    • local - The place for locally installed software and other files.
    • man - Manual pages
    • info - Info documents
    • doc - Documentation
    • X11 - The X windows system files.
  • boot - Files used by the bootstrap loader, LILO. Kernel images are often kept here.
  • lib - Shared libraries needed by the programs on the root filesystem

    • modules - Loadable kernel modules, especially those needed to boot the system after disasters.
  • dev - Device files
  • etc - Configuration files specific to the machine.

    • skel - When a home directory is created it is initialized with files from this directory
    • sysconfig - Files that configure the linux system for devices.
  • var - Contains files that change for mail, news, printers log files, man pages, temp files

    • lib - Files that change while the system is running normally
    • local - Variable data for programs installed in /usr/local.
    • lock - Lock files. Used by a program to indicate it is using a particular device or file
    • log - Log files from programs such as login and syslog which logs all logins and logouts.
    • run - Files that contain information about the system that is valid until the system is next booted
    • spool - Directories for mail, printer spools, news and other spooled work.
    • tmp - Temporary files that are large or need to exist for longer than they should in /tmp.
  • mnt - Mount points for temporary mounts by the system administrator.
  • tmp - Temporary files.