Sunday, January 26, 2014

Install Source RMP on Centos/Redhat

1. Prepare the build environment and get the dependencies. Do those following command under your root home directory :
2. Put the source rpm file at the root of your home directory and then run this command to rebuild the rpm under your system :
(*replace  including ‘< >’ with your package name. you can put the source package under /rpmbuild/SOURCES as well to archive it.)
3. Install the RPM :

Shell
1
2
cd /rpmbuild/RPMS
rpm -i <package-0.0-0.x86_64.rpm>

Friday, January 24, 2014

Restore file and directory permission to default vaule

As we know umask value controls which permission are set for  files and directories  when they are created.

By default root has umask value of 022 and all ordinary users has umask value of 002.

So for ordinary user file permission would be 664 and directory permission would be 775 and for root users it would be 644 and 744 respectively.

So we know the default permission of files and directories when are created which can be restored using the following commands.

find . -type d \! -user root  -print -exec chmod 775 {} \; - for all files owned by ordinary users excluding root

find . -type f \! -user root  -print -exec chmod 644 {} \; - for all directory owned by ordinary users excluding root

find . -type f  -user root  -print -exec chmod 644 {} \; - For all files owned by root

find . -type d  -user root  -print -exec chmod 744 {} \; - For all directory owned by root

If you have any user which has different umask value other than the defualt one then change the command accordingly. The above procedure is used to restore the permission only to default value.

Wednesday, January 15, 2014

Allowing only root user to login through ssh

This can be done in two ways, not sure whether it's possible in another ways. Here are the two possible ways.

1. Configuring /etc/ssh/sshd_config file

AllowUsers root - which will allow only root user to login through ssh

2. Using PAM.

Add "Account pam_access.so" to /etc/pam.d/sshd 

Adding the above the line make login process to check /etc/security/access.conf for access

-:ALL EXCEPT root:ALL

Monday, January 13, 2014

Linux Commands

-->
chown:

Regular users cannot change the ownership of a file, root can only do that. Group can be changed by regular user to the group which the users belongs to.

Example : chown filename
To allow non-root users to change the owner of a file, change the suid of the chown command as given below

chmod u+s chown


Editing a file inline
--------------------------

sed -i 's/suman/siddhanth/g' testfile

perl -i.bak -pe 's/suman/siddhanth/g' testfile


Saturday, January 11, 2014

Linux Package management

Package management using yum
----------------------------------------------

I have multiple repository configured on my CentOS. Few online repositories and one local repository with all the packages from CD

Below command is to install package from one specific repository

yum --disablerepo="*" --enablerepo="ius" list available

 yum --disablerepo="*" --enablerepo="local" groupinstall "KDE desktop" local

where "local" is the repository name.

Skip dependency -

yum --disablerepo="*" --enablerepo="local" groupinstall basic-desktop desktop-platform x11 fonts --skip-broken