Posts

Showing posts from December, 2010

How to install & configure getmail, replacement of Fetchmail utitity ?

How to install & configure getmail, replacement of Fetchmail utitity ? Getmail : G etmail is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. getmail is designed to be secure, flexible, reliable, and easy-to-use. getmail is designed to replace other mail retrievers such as fetchmail. getmail version 4 includes the following features: simple to install, configure, and use retrieve virtually any mail support for accessing mailboxes with the following protocols: POP3 POP3-over-SSL IMAP4 IMAP4-over-SSL SDPS (Demon UK's extensions to POP3) support for single-user and domain mailboxes retrieve mail from an unlimited number of mailboxes and servers can remember which mail it has already retrieved, and can be set to only download new messages support for message filtering, classification, and annotation by external programs like spam filters and anti-

How to redirect all /etc/passwd user list to your SAMBA User list ? OR, How to add users from your NIS server to SAMBA server ?

How to redirect all /etc/passwd user list to your SAMBA User list ? OR How to add users from your NIS server to SAMBA server ? Use below command, # cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd Here, /etc/samba/smbpasswd files have user data for SAMBA server. Now check, All your system users will be added to your SAMBA user list. What if you are working on NIS Server and you want to redirect all NIS users in to SAMBA server list. then, # ypcat passwd | mksmbpasswd.sh > /etc/samba/smbpasswd IN BOTH THE CASES YOU MUST DO THIS : #chmod 600 /etc/samba/smbpasswd Done ...

How to split big files in to small chunks or in small parts ?

Image
How to split big files in to small chunks or in small parts ? What to do if you dont have much space on a drive to store any big file & you want to split and store it in to some small size parts. A. First check md5sum hash of file, and make a note of it; #md5sum <Big File Name> e.g. #md5sum Linux-pdf-HOWTOs.tar.bz2 B. Split file in to small managable chunks, #split --bytes=<Size of each chunk>m <Big File Name> <Chunk File Prefix> e.g. #split --bytes=10m Linux-pdf-HOWTOs.tar.bz2 Linux-pdf-   Note : Here it'll make 10-10 MB file chunks. C. Now if you want to reassemble chunk files in to Big File, #cat <File Chunk Prefix>* > <Big File Name> e.g. #cat Linux-pdf-a* > Linux_PDF_HOWTOS.tar.bz2 D. Check md5sum hash of file, #md5sum <Big File Name> e.g. #md5sum Linux_PDF_HOWTOS.tar.bz2 E. Compare md5sum of "Step A" & "Step D", If both the md5sum are sam

How to set proxy settings on RHEL OR CentOS ?

How to set proxy settings on RHEL OR CentOS ? What you will do if you dont have direct internet connection & you want to download some package or file by wget suppose. In this scenario we have to set proxy server settings for HTTP as well as FTP traffic. 1. Get full information about the Proxy server & your access account on it like, A. Proxy Server IP OR Hostname B. Proxy Port Number C. Login cridentials if any D. Ask if admin managing different accounts & server info for HTTP & FTP access. Now here we go, We can do this thing in two manner one is Temporary & other is Permanent setting, To do this on temporary basis, we will set this info in environment variable; #export http_proxy=http://<Proxy Server IP>:<Proxy Port No.> (For HTTP Proxy) #export ftp_proxy=http://<Proxy Server IP>:<Proxy Port No.> (For FTP Proxy)     e.g. #export http_proxy=http://10.10.10.1:3128 #export ftp_proxy=http://10.10.10.1:3128

How to mount NTFS (Windows) partition on RHEL or CentOS 7 ?

H ow to mount NTFS (Windows) partition on RHEL or CentOS 7 ? Here for this tutorial i am using CentOS 7 OS, Because you can easily find many open source 3rd party repos to install your any software with its dependency, just in one click. Or If you are working on RHEL then you can get all the required packages from these two sites, 1. Before downloading fuse & ntfs-3g we will have to install EPEL (Extra Packages for Enterprise Linux) repository: # yum --enablerepo=extras install epel-release Or directly install : # rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 2. Install "fuse" and "ntfs-3g" packages: # yum install ntfs-3g fuse 3. Once both of these packages are installed, create a mount directory where we are planning to mount NTFS partition or disk: # mkdir /mydisk-ntfs 4. To mount NTFS disk partition temporarily, you should get to know the NTFS device name in my case it's "/dev/sdb1"

How to configure rpmforge and epel yum repos in RHEL or CentOS 7

How to configure 3rd Party Yum Repo's ? 1. Configuring RPM Forge Repo: # wget http://repository.it4i.cz/mirrors/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm # rpm -ivh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm # yum clean all # yum repolist   2. Configuring EPEL Repo EPEL was started because many Fedora contributors wanted to use the Fedora packages they maintain on Red Hat Enterprise Linux (RHEL) and its compatible derivatives. # rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # yum repolist [root@localhost ~]# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile  * base: centos.mirrors.estointernet.in  * epel: sg.fedora.ipserverone.com  * extras: centos.mirrors.estointernet.in  * rpmforge: mirrors.tuna.tsinghua.edu.cn  * rpmforge-extras: mirrors.tuna.tsinghua.edu.cn  * updates: centos.mirrors.estointernet.in repo id           

How to install .bin files in RHEL or CentOS 5 ?

Image
How to install .bin files in RHEL or CentOS 5 ? The *.bin files are Self extracting packages just like rpm packages. Here i am installing JAVA 6 with " jre-6u23-linux-i586.bin " package. So take a look ... To install Java with .bin file, first give it execution permission by #chmod 777 jre-6u23-linux-i586.bin           (Very important step) Now just run it with #./jre-6u23-linux-i586.bin Installed ... Now to configure any settings you have to see it's manual or README file if provided with package, because every utility have different configuration steps.

What is difference between SetUID, SetGID & Sticky Bits ?

What is difference between SetUID, SetGID & Sticky Bits ?          This question is one of the most important one in Linux interviews. So here we go ! Set UID: When a Set UID bit is turned on for a program, your EUID (effective user ID) becomes the same as the program’s owner when you run the program. You also gain all the privileges of the program’s owner. In other words, if user freddie runs a Set UID program owned by user root, freddie has superuser privileges while that program is running. Set UID affects programs only; it’s really not important for data files and directories. If you find a Set UID program, read the WARNING!!! Warning: Set UID programs are potentially dangerous.Users can gain extra privileges by using files that grant them superuser privileges. Set GID: The Set GID bit works similarly to Set UID — anyone running the program gains all the privileges of the group. When the Set GID box is checked for a directory, the files in that directory belong to th

How to enable Telnet service on RHEL / CentOS 5 ?

Image
How to enable Telnet service on RHEL / CentOS 5 ?  Generally in production servers we dont use Telnet connections because this doesn't use encrypted format of trasfer or session. But some applications need this to be enabled on the server to communicate. By default this service always kept disabled. To enable it, First take a backup of "/etc/xinetd.d/telnet" configuration file; #cp /etc/xinetd.d/telnet /etc/xinetd.d/telnet.bak Now to start edit "/etc/xinetd.d/telnet" file, #vi /etc/xinetd.d/telnet Here "xinetd" word means X Internet Deamon. Search for the "disable = yes" & replace it with "disable = no". Remember here in example i have commented 1st "disable" statement. So dont get confuse. Next save file & restart "xinetd" service #service xinetd restart Done ...

How to install Webmin on RHEL OR CentOS 5 ?

Image
How to install Webmin on RHEL OR CentOS 5 ? What is Webmin ? Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely. You can download webmin through " www.webmin.com/download.html". How do i install it to start web administration of my server ? 1. NOTE : Please note down that to use Webmin, you should have proper static IP. 2. Two methods of Webmin installation; A. By rpm package,   Here i am installing "webmin-1.530-1.noarch.rpm" on CentOS 5.3, #rpm -ivh webmin-1.530-1.noarch.rpm Here in the above snap as shown, after installation you will get the login link, https://localhost.localdomain:10000/ e.g. https://192.168.44.128:10000/ Instead of writing "localhost.localdo

How to disable USB Storage Devices on CentOS/RHEL 7?

How to disable USB Storage Devices on CentOS/RHEL 7 ? The USB storage drive automatically detects USB flash or hard drives. You can easily force and disable USB storage devices under any Linux distribution. The modprobe program used for automatic kernel module loading and can be configured to not load the USB storage driver upon demand. This will prevent the modprobe program from loading the usb-storage module, but will not prevent root (or another program) from using the insmod program to load the module manually. There are total four ways to do it, 1. Disable by BIOS    Disable USB from system BIOS configuration option. Make sure BIOS is password protected. 2. Type the following command: # echo 'install usb-storage /bin/true' >> disable-usb-storage.conf    You can also remove USB Storage driver, enter: # ls /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko # mv /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko /root

How to enable Hot-add Memory in Linux RHEL 5 ?

What if you have Hot-added memory in your RHEL 5 server but it's still displaying Last memory configuration ? Step :  1. Check if two modules are loaded properly by,      #lsmod | grep acpi                  acpiphp                      43673  0                  acpi_memhotplug        42199  0 If not loaded, follow below steps;      #modprobe acpiphp      #modprobe acpi_memhotplug 2. Now increase your server memory with Hot-add memory module. This will be done by Hardware engineer directly on the server, i am not talking about on OS level. 3. Make a shell script like "memory_online.sh" with below contents, "for a in /sys/devices/system/memory/memory*/state;   do   echo 'online' > "$a"   done" and then  "cat /sys/devices/system/memory/memory*/state" Save it & exit For Ubuntu you have to try with another script as below, #!/bin/sh i=0 while [ $i -lt 4500 ] do    if [ -f /sys/devices/system/m

How to compile kernel in RHEL and CentOS 5?

Image
Here i am compiling Kernel "linux-2.6.36.2" on CentOS 5.3 To create new custom kernel we will follow below steps; 1. Check for essential packages. 2. Find the kernelsource code. 3. Configure the new kernel. 4. Customize the kernel. 5. Build the kernel. 6. Edit entry in "/boot/grub/grub.conf" file. Steps : 1. Before you start compiling a kernel ckeck following packages are installed or not, gcc & make #rpm -qa make gcc 2. You can download latest stable kernel from " Kernel.org ", then download and untar "linux-2.6.36.2.tar.bz2" package, #bunzip2 linux-2.6.36.2.tar.bz2 #tar xvf linux-2.6.36.2.tar 3. Now got to extracted directory of latest kernel #cd linux-2.6.36.2 4. Copy Kernel source code directory "linux-2.6.36.2"in "/usr/src" directory, #cp -r linux-2.6.36.2 /usr/src/ 5. Go to "/usr/src/linux-2.6.36.2/" and run, #make menuconfig         Note : Don&#

Understanding /proc File system

Understanding /proc File system: Files that contain configuration information for all the devices connected to your computer are scattered throughout the "/proc" file system. The /proc file system also contains files full of information about system resources. 1. /proc/bus/usb: This file contains all info about USB (Universal Serial Bus) devices currently plugged into your system. USB devices like mice, cameras, and serial storage devices currently connected to your computer. 2. /proc/scsi/scsi: This file contains all information about every SCSI devices currently attached to your system. 3. /proc/cpuinfo: This file contains a collection of all information about the system’s CPU. 4. /proc/crypto: The /proc/crypto file contains information about the current encryption algorithms and digital signature tools installed on your system. 5. /proc/meminfo: This file contains a wealth of information about your system’s memory resources. 6. /proc/filesystems: This file c

How to install src.rpm packages in RHEL 6 ?

Image
How to install *.src.rpm packages in RHEL 6 ? Here i am installing "libpciaccess-0.12.1.fc14.src.rpm" 1. Copied libpciaccess-0.12.1.fc14.src.rpm on "/root/Desktop" location. 2. open console and go to "/root/Desktop". 3. Now give command, #rpmbuild --rebuild libpciaccess-0.12.1.fc14.src.rpm Here at the time i executed the above command it gave me a dependancy error to compile "libpciaccess-0.12.1.fc14.src.rpm" package, asked me for new version of "xorg-x11-util-macros" package, then i installed "xorg-x11-util-macros-1.3.0-1.fc12.noarch.rpm". Now again i executed the same command, #rpmbuild --rebuild libpciaccess-0.12.1.fc14.src.rpm this time it executed properly without any error. Keep in mind ; if its asking for any dependancy, you must resolve it, else you can't go for next step. 4. Next, if you check in "/root" folder you will find a new folder named "rpmbuild" with sub-fo

How to install and uninstall VMware Server 2.0.2 on CentOS 5 / RHEL 5 ?

Image
How to install VMware Server 2.0.2 on CentOS 5 / RHEL 5 ? VMware Server 2.0.2 is a open source server virtualization tool for Windows as well as Linux from VMware. Remember if you are installing VMware Server in VMware Workstation or on VMware ESX then dont install VMware Tools on your VM on which you are installing these product. 1. Getting VMware Server 2.0.2 : Go to http://downloads.vmware.com/d/info/datacenter_downloads/vmware_server/2_0 . Make an free account in VMware, download the package "VMware-server-2.0.2-203138.i386.tar"& get free installation keys. 2. Now extract the "VMware-server-2.0.2-203138.i386.tar" & you will see "vmware-server-distrib" folder in the same location. 3. Go to "vmware-server-distrib" folder by # cd vmware-server-distrib 4. Next, run "./vmware-install.pl" command in terminal to execute "vmware-install.pl" script. & Press  <ENTER> to go with default opti

Installed RHEL 6, but not getting network connection up ?

It's a reported bug for RHEL 6, Follow these steps to get up and running network connection ... Edit "/etc/sysconfig/network-scripts/ifcfg-eth0" file, which is your defualt first NIC configuration file. If you are using DHCP server to take IP then, edit it like this; #vi /etc/sysconfig/network-scripts/ifcfg-eth0 ONBOOT="yes" BOOTPROTO="dhcp" Save & restart networking service, #service network restart               OR #/etc/init.d/network restart If you are providing manual IP then, edit it like this; DEVICE=eth0 IPADDR=10.10.10.10 NETMASK=255.255.255.0 NETWORK=10.10.10.0 GATEWAY=10.10.10.253 ONBOOT=yes BOOTPROTO=none USERCTL=no Save & restart networking service, #service network restart               OR #/etc/init.d/network restart OR you can use simple Network Configuration tool  to configure IP's but the highlighted two lines are compulsory to add manu

Command Shortcuts in Linux

Command Prompt Shortcuts : / - 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 c

How to Enable / Disable, Firewall / SELinux ?

Image
What is Firewall ? Firewall (IPTables): IPTables is software based firewall that provides protection between your server and damaging content on the Internet or network. It will try to guard your server against both malicious users and software such as viruses / worms. How to disable IPTables ? You must be a Root user. #service iptables save (Will save your existing IPTable Rules) #service iptables stop (It will disable firewall Temporarly) To Disable it Permanentely: #chkconfig iptables off To Enable it again: #service iptables start (It will enable firewall Temporarly) To enable it Permanentely: #chkconfig iptables on You can also use; #system-config-securitylevel #system-config-securitylevel-tui Apply & "Ok". SELinux : Also known as Security-Enhanced Linux, implements various security policies on Linux and additional levels of access crontrol. To disable SELinux, edit file "/etc/selinux/config" and find line;

Important configuration files in RHEL / CentOS

Important Linux Config Files : For Configuring Ethernet card :- /etc/hosts (Uses to maintain IP to Hostname to IP convention ) /etc/resolv.conf (DNS Servers for connectivity) /etc/sysconfig/network (Contains gateway, hostname etc.) /etc/sysconfig/network-scripts/ifcfg-eth0 (Defualt Network card configuration like IP, MAC address, Subnet mask etc.) For adduser command :- /etc/passwd (File contains info about user like UserID, shell, Username, Defualt Directory etc.) /etc/shadow (File contains mainly encrypted password of a user) /etc/group (Contains info about groups) /etc/gshadow (Info about group & related users) /etc/login.defs (F ile defines the site-specific configuration for the shadow password suite ) /etc/shells (Contains name of all the types of shells available) Configuration file for the color ls utility :- /etc/DIR_COLORS Configuration file for the grub loader and other related files:- /etc/grub.conf - Symbolic

Important RHEL Directories & their usage

Important Linux Directories : Different distributions have different directory structures, despite attempts at standardization such as the the Linux Filesystem Hierarchy Standard (FHS) organization. /bin - essential UNIX commands such as ls, etc. Should contain all binaries needed to boot the system or run it in single-user mode /boot - files used during booting and possibly the kernel itself are stored here /dev - contains device files for various devices on system /etc - files used by subsystems such as networking, NFS, and mail. Includes tables of disks to mount, processes to run on startup, etc. /etc/profile.d - contains scripts that are run by /etc/profile upon login. /etc/rc.d - contains a number of shell scripts that are run on bootup at different run levels. A rc.local script that can be edited to run commands desired by the administrator, along the lines of autoexec.bat in DOS. /etc/rc.d/init.d - contains most of the initialization scripts themselves on an rpm