Showing posts with label OS. Show all posts
Showing posts with label OS. Show all posts

Monday, 14 August 2017

DNS SERVER

DNS configure without CHROOT on RHEL/OEL For Oracle RAC


[root@dns1 ~]# rpm -qa | grep -i bind
ypbind-1.19-12.el5_6.1
kdebindings-3.5.4-6.el5
bind-utils-9.3.6-20.P1.el5_8.6
system-config-bind-4.0.3-6.0.1.el5
bind-libs-9.3.6-20.P1.el5_8.6
bind-9.3.6-20.P1.el5_8.6

[root@dns1 ~]# hostname
dns1.testenv.com



----- Create/Edit /etc/named.conf File ------

[root@dns1 ~]# cat /etc/named.conf
options {
        listen-on port 53 { 192.168.2.200; };
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        /*
         * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
         // query-source address * port 53;

        // My Additions
        // Forwarder: Anything this DNS can't resolve gets forwarded to my ISPs DNS.
        #forwarders { 194.168.4.100; 194.168.8.100; };
        // End My Additions
};

zone "testenv.com." IN {
                 type master;
                 file "testenv.com.zone";
                 allow-update { none; };
};

zone "2.168.192.in-addr.arpa." IN {
        type master;
        file "2.168.192.in-addr.arpa";
        allow-update { none; };
};

include "/etc/rndc.key";




----------- Create/Edit /var/named/2.168.192.in-addr.arpa File ----------------
[root@dns1 named]# pwd
/var/named
[root@dns1 named]# cat 2.168.192.in-addr.arpa
$ORIGIN 2.168.192.in-addr.arpa.
$TTL 1H
@          IN     SOA    testenv.com.  root.testenv.com. (
                         42 ; serial (d. adams)
                         3H ; refresh
                        15M ; retry
                         1W ; expiry
                         1D ) ; minimum

2.168.192.in-addr.arpa.   IN   NS     testenv.com.
151 IN PTR rac1.testenv.com.
152 IN PTR rac2.testenv.com.
161 IN PTR rac1-vip.testenv.com.
162 IN PTR rac2-vip.testenv.com.
51  IN PTR rac-scan.testenv.com.
52  IN PTR rac-scan.testenv.com.
53  IN PTR rac-scan.testenv.com.


------------------ Create/Edit /var/named/testenv.com.zone File --------

[root@dns1 named]# cat testenv.com.zone
$TTL    86400
@               IN SOA  testenv.com root.testenv.com (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS   testenv.com
rac1            IN A    192.168.2.151
rac2            IN A    192.168.2.152
rac1-priv       IN A    192.168.3.151
rac2-priv       IN A    192.168.3.152
rac1-vip        IN A    192.168.2.161
rac2-vip        IN A    192.168.2.162
rac-scan        IN A    192.168.2.51
rac-scan        IN A    192.168.2.52
rac-scan        IN A    192.168.2.53



-------- Give the Ownership --------

cd /var/named
chown named:named 2.168.192.in-addr.arpa
chown named:named testenv.com.zone

chkconfig named on

[root@dns1 named]# cat /etc/resolv.conf
nameserver 192.168.2.200



--------- Check the its working or not ----------

[root@dns1 named]# nslookup rac-scan
Server:         192.168.2.200
Address:        192.168.2.200#53

Name:   rac-scan.testenv.com
Address: 192.168.2.53
Name:   rac-scan.testenv.com
Address: 192.168.2.51
Name:   rac-scan.testenv.com
Address: 192.168.2.52


[root@dns1 named]# dig testenv.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.6 <<>> testenv.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50541
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;testenv.com.                   IN      A

;; AUTHORITY SECTION:
testenv.com.            86400   IN      SOA     testenv.com.testenv.com. root.testenv.com.testenv.com. 42 10800 900 604800 86400

;; Query time: 3 msec
;; SERVER: 192.168.2.200#53(192.168.2.200)
;; WHEN: Wed Jul  5 11:31:57 2017
;; MSG SIZE  rcvd: 82


---------------------------------------------------------------------------------------------------------------------------
=============
Now RAC Part
=============


Configure one node if working well athen follow all steps on all nodes.

[root@rac1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               rac1.testenv.com rac1 localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
#Public-IP
192.168.2.151  rac1  rac1.testenv.com
192.168.2.152  rac2  rac2.testenv.com

#Virtual-IP
192.168.2.161  rac1-vip      rac1-vip.testenv.com
192.168.2.162 rac2-vip      rac2-vip.testenv.com

#Scan-IP
192.168.198.51  rac-scan        rac-scan.testenv.com
192.168.2.52    rac-scan        rac-scan.testenv.com
192.168.2.53    rac-scan        rac-scan.testenv.com

192.168.2.200   dns1    dns1.testenv.com


[root@rac1 ~]# hostname
rac1.testenv.com


[root@rac1 ~]# cat /etc/resolv.conf
search testenv.com      dns1.testenv.com
nameserver 192.168.2.200


[root@rac1 ~]# dig rac1

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-16.P1.el5 <<>> rac1
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 63859
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;rac1.                          IN      A

;; Query time: 4 msec
;; SERVER: 192.168.2.200#53(192.168.2.200)
;; WHEN: Wed Jul  5 11:36:32 2017
;; MSG SIZE  rcvd: 22



[root@rac1 ~]# dig rac-scan

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-16.P1.el5 <<>> rac-scan
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 359
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;rac-scan.                      IN      A

;; Query time: 13 msec
;; SERVER: 192.168.2.200#53(192.168.2.200)
;; WHEN: Wed Jul  5 11:36:05 2017
;; MSG SIZE  rcvd: 26



Now its working fine ... above the setting replicate on all nodes.




Wednesday, 15 June 2016

RHEL PASSWORD POLICY

Linux turn OFF password expiration / aging


/etc/shadow stores actual password in encrypted format for user’s account with additional properties related to user password.
The password expiration information for a user is contained in the last 6 fields. Password expiration for a select user can be disabled by editing the /etc/shadow file
However I recommend using chage command. The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change his/her password.
To list current aging type chage command as follows:
# chage -l oracle
Output:
Last password change                                    : May 22, 2007
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

To disable password aging / expiration for user foo, type command as follows and set:
Minimum Password Age to 0
Maximum Password Age to 99999
Password Inactive to -1
Account Expiration Date to -1
Interactive mode command:

# chage username

OR
# chage -I -1 -m 0 -M 99999 -E -1 username
Updated for accuracy.

There are few commands which I know can be used to see if any user account on your Linux machine is locked.

Case 1: Password Locked

In this case the password of any account is locked using the below command.

To lock the password

# passwd -l user1
Locking password for user user1.
passwd: 
Success


Review the status in /etc/shadow

# grep user1 /etc/shadow user1:!!$6$ciJaoDR9$Qpt9sctRLjbZ4/Agxy9UOvu/XQqNrFo9rpgfZ/xrF/8JphkEvF29ITpef0SVLdJcrpv8Q/.6mRAHee4tZT0r11:16299:0:99999:7:::

As you can see above two exclamation mark (!!) before the encrypted password which means that the password has been locked

To unlock the password

# passwd -u user1
Unlocking password for user user1.
passwd: Success

Case 2: Account is Locked
In this case the user account might have been locked by the administrator

To lock an account

# usermod -L user1

Review your /etc/shadow file for the changes

# grep user1 /etc/shadow
user1:
!$6$ciJaoDR9$Qpt9sctRLjbZ4/Agxy9UOvu/XQqNrFo9rpgfZ/xrF/8JphkEvF29ITpef0SVLdJcrpv8Q/.6mRAHee4tZT0r11:16299:0:99999:7:::

As you see an extra single exclamation mark(!) appeared in the password section before the encrypted password starts which signifies that the user account is locked

To unlock a user account

# usermod -U user1

Case 3: Password never set
This can also be the scenario where the administrator has no assigned any password due to which the user is not able to login

So to verify this again you need to check your 
/etc/shadow file
# grep user1 /etc/shadow
user1:
!!:16299:0:99999:7:::

As you see two exclamation mark(!!) is there but no encrypted password which means a password is not set.

If the password was set without lock your 
/etc/shadow would look like something below
# grep user1 /etc/shadow
user1:
$6$ciJaoDR9$Qpt9sctRLjbZ4/Agxy9UOvu/XQqNrFo9rpgfZ/xrF/8JphkEvF29ITpef0SVLdJcrpv8Q/.6mRAHee4tZT0r11:16299:0:99999:7:::

Check the lock status of any Linux Account
Now one single command to see the lock status of the user
# passwd -S user1
user1 LK 2014-08-17 0 99999 7 -1 (
Password locked.)
If the user account is unlocked you will output like below

# passwd -S user1
user1 PS 2014-08-17 0 99999 7 -1 (Password set, SHA512 crypt.)

Friday, 5 February 2016

RHEL History Clean

Hi , Today we are discuss about .bash_profile & user History, Some client required don't show any history of UNIX user else ROOT also then do the following steps to hide history.

1. Login > root

2. # vim /home/oracle/.bash_profile    # In my case user name is oracle

3. history -c

4. # Insert Line on .bash_profile 
export HISTFILESIZE=0
export HISTSIZE=0
unset HISTFILE

5. $ . .bash_profile execute  then relogin session and check.


Reference:
https://linuxconfig.org/how-to-disable-bash-shell-commands-history-on-linux

Monday, 11 January 2016

FAT HDD MOUNT ON RHEL 6/5

Installed rpm's

     exfat-utils-1.2.0-1.el6.i686.rpm

-Alternate
     fuse-exfat-1.0.1-1.el6.i686.rpm
     fuse-exfat-1.0.1-2.el6.i686.rpm


mount.exfat /dev/sdb1 /media/

cp -rpvnf * /home/abc/

-rpvnf --- overwrite  all files

Tuesday, 29 December 2015

Datewise File find Scripts


--------------------
Scripts Crontab
--------------------
00 04 4 * * /etc/monthly.sh
00 04 * * 2-6 /etc/scanlog.sh
00 05 * * 1 /etc/monday.sh

--------------------------------------------------------------------------------------------------
 Total Count Files on Monthly Basis with string Scripts with rename datewise
--------------------------------------------------------------------------------------------------

#!/bin/bash
rm -rf /home/Monthly.log
touch /home/Monthly.log
echo -------------- AB ------------ >> /home/Monthly.log
cd /home/ab/
echo "MONTHLY PDF: " $(find /home/ab/ -type f -name "*201511*.pdf" |wc -l) >> /home/Monthly.log
echo ------------------------------ >> /home/Monthly.log
printf "\n \n" >> /home/Monthly.log
sleep 10
echo ------------- CD ------------- >> /home/Monthly.log
echo "MONTHLY PDF: " $(find /home/cd/ -type f -name "*201511*.pdf" |wc -l) >> /home/Monthly.log
echo ------------------------------ >> /home/Monthly.log
printf "\n \n" >> /home/Monthly.log
sleep 10
cd /home/
DATE=$(date +"%Y%m%d%H%M")
mv Monthly.log Monthly$DATE.log
exit


------------------------------------------------------------------------------
 Daily basis DateWise  Total Dir/FIles/DateWise PDF Generate
------------------------------------------------------------------------------

#!/bin/bash
rm -rf /home/scanlog.log
touch /home/scanlog.log

echo -------------- AB------------ >> /home/scanlog.log
cd /home/ab/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/scanlog.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/scanlog.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-1 days" +%Y%m%d.pdf) | wc -l) >> /home/scanlog.log
echo ------------------------------ >> /home/scanlog.log
printf "\n \n" >> /home/scanlog.log
echo ------------- CD ------------- >> /home/scanlog.log
cd ../cd/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/scanlog.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/scanlog.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-1 days" +%Y%m%d.pdf) | wc -l) >> /home/scanlog.log
echo ------------------------------ >> /home/scanlog.log
printf "\n \n" >> /home/scanlog.log
cd /home/
DATE=$(date +"%Y%m%d%H%M")
mv scanlog.log scanlog$DATE.log
exit


-----------------------------------------
 This Script execute only Monday
-----------------------------------------

#!/bin/bash
rm -rf /home/Monday.log
touch /home/Monday.log
echo --------------AB ------------ >> /home/Monday.log
cd /home/ab/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/Monday.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/Monday.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-2 days" +%Y%%m%d.pdf) | wc -l) >> /home/Monday.log
echo ------------------------------ >> /home/Monday.log
printf "\n \n" >> /home/Monday.log
echo ------------- CD ------------- >> /home/Monday.log
cd ../cd/
echo "TOTAL DIR: " $(ls -l | grep ^d | wc -l) >> /home/Monday.log
echo "TOTAL PDF: " $(find . -name "*.pdf" | wc -l) >> /home/Monday.log
echo "TOTAL DATEWISE PDF: " $(ls -ltR  |grep  $(date --date="-2 days" +%Y%m%d.pdf) | wc -l) >> /home/Monday.log
echo ------------------------------ >> /home/Monday.log
printf "\n \n" >> /home/Monday.log
cd /home/
DATE=$(date +"%Y%m%d%H%M")
mv Monday.log Monday$DATE.log
exit


Detect & Delete Empty Dir. / Files

---------------------------------------------------
 Lower case file name find & count in CS
---------------------------------------------------

ls | egrep [a-z] |wc -l
ls | egrep [a-z] >> /home/aru.out


------------------------------------------------------
 Find Empty / corrupted file and directories
------------------------------------------------------

cd /home/mr

find . -empty -type d >> /home/D_aru_empty.out
find . -empty -type d | wc -l

find . -empty -type f
find . -empty -type f | wc -l

----------------------------------------------
 Delete Empty File and directories
----------------------------------------------

cd /home/mr

find . -empty -type d -delete
find . -empty -type f -delete

find . -empty -type -d -delete
find . -empty -type -f -delete


------------------------------------------------------------
 find and delete all empty directories using xargs
------------------------------------------------------------

## secure and fast version ###
find /path/to/ -type d -empty -print0 | xargs -0 -I {} /bin/rmdir "{}"


## secure and fast version ###
find /path/to/ -type f -empty -print0 | xargs -0 -I {} /bin/rm "{}"

Friday, 26 October 2012

Linux Root Password Lost


Note: # This Technique use only when the Bootstrap password not Set

1.Start the Linux Machine after starting perss 'e'
2.Select kernal Line n press 'e' for edit and after the press '1'  for the end of Kernal line then enter
3.Press 'b' for boot your system.
4.Then your system entered on single user mode after that
5.passwd -d root // Delete for root password
6.init 5 // restart machine With GUI
7.After that enter username 'root'
8.See the direct login
9. Open terminal then after set the 'root' password.
10. passwd root

Saturday, 13 October 2012

RDP THROUGH LINUX TO WINDOWS


How i can take the remote PC through Linux to Windows

1. rpm -ivh rdesktop*

2. rdesktop -f<force fully only one seesion> -a<account> 16  192.168.xx.xx<destination>

Eg:-- rdesktop -f -a 16 192.xx.xx.xx

Wednesday, 3 October 2012

Create NFS (Newtwork File system)


Machine A
rpm -ivh nfs*
rpm -ivh system-config-nfs*

Note: make the dir where to share the directory i have to use /u01/oracle/

--on terminal type
system-config-nfs //share directory
then after
ADD >
Directory - /u01/oracle >
hosts - * >
read/write permission then ok


service portmap restart
service nfs restart
chkconfig nfs on
chkconfig portmap on

--Permanent method
vim etc/fstab
192.168.220.2:/oracle /u01 nfs defaults 0 0
showmount -e 192.168.220.2

client Machine B:
--Permanent method
vim etc/fstab
192.168.220.2:/oracle /u01 nfs defaults 0 0
mount -t 192.168.220.2:/u01/oracle /u01/oracle

Tuesday, 31 July 2012

RHEL / CentOS Support 4GB or more RAM ( memory )


If you have 4 GB or more RAM use the Linux kernel compiled for PAE capable machines. Your machine may not show up total 4GB ram. All you have to do is install PAE kernel package.

This package includes a version of the Linux kernel with support for up to 64GB of high memory. It requires a CPU with Physical Address Extensions (PAE).
 The non-PAE kernel can only address up to 4GB of memory. Install the kernel-PAE package if your machine has more than 4GB of memory (>=4GB).
How Do I Install PAE kernel?

To install PAE kernel, use yum command:
# yum install kernel-PAE

 Output:
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for kernel-PAE to pack into transaction set.
kernel-PAE-2.6.18-8.1.15. 100% |=========================| 207 kB    00:00
---> Package kernel-PAE.i686 0:2.6.18-8.1.15.el5 set to be installed
--> Running transaction check
Dependencies Resolved
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 kernel-PAE              i686       2.6.18-8.1.15.el5  updates            12 M
Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 12 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): kernel-PAE-2.6.18- 100% |=========================|  12 MB    00:12
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: kernel-PAE                   ######################### [1/1]
Installed: kernel-PAE.i686 0:2.6.18-8.1.15.el5
Complete!

Just reboot the server and make sure you boot with PAE kernel i.e. 2.6.18-8.1.15.el5PAE:
# reboot

Tuesday, 24 July 2012

Windows Server Memory Limits



1) Windows Server 2008 Web

2) Windows Server 2008 Standard
3) Windows Server 2008 Enterprise
4) Windows Server 2008 Datacenter


Windows support for physical memory is dictated by hardware limitations, licensing, operating system data structures, and driver compatibility. The Memory Limits for Windows Releases page in MSDN documents the limits for different Windows versions, and within a version, by SKU.
You can see physical memory support licensing differentiation across the server SKUs for all versions of Windows. For example, the 32-bit version of Windows Server 2008 Standard supports only 4GB, while the 32-bit Windows Server 2008 Datacenter supports 64GB. Likewise, the 64-bit Windows Server 2008 Standard supports 32GB and the 64-bit Windows Server 2008 Datacenter can handle a whopping 2TB. There aren't many 2TB systems out there, but the Windows Server Performance Team knows of a couple, including one they had in their lab at one point. Here's a screenshot of Task Manager running on that system:


The maximum 32-bit limit of 128GB, supported by Windows Server 2003 Datacenter Edition, comes from the fact that structures the Memory Manager uses to track physical memory would consume too much of the system's virtual address space on larger systems. The Memory Manager keeps track of each page of memory in an array called the PFN database and, for performance, it maps the entire PFN database into virtual memory. Because it represents each page of memory with a 28-byte data structure, the PFN database on a 128GB system requires about 980MB. 32-bit Windows has a 4GB virtual address space defined by hardware that it splits by default between the currently executing user-mode process (e.g. Notepad) and the system. 980MB therefore consumes almost half the available 2GB of system virtual address space, leaving only 1GB for mapping the kernel, device drivers, system cache and other system data structures, making that a reasonable cut off:
That's also why the memory limits table lists lower limits for the same SKU's when booted with 4GB tuning (called 4GT and enabled with the Boot.ini's /3GB or /USERVA, and Bcdedit's /Set IncreaseUserVa boot options), because 4GT moves the split to give 3GB to user mode and leave only 1GB for the system. For improved performance, Windows Server 2008 reserves more for system address space by lowering its maximum 32-bit physical memory support to 64GB.
The Memory Manager could accommodate more memory by mapping pieces of the PFN database into the system address as needed, but that would add complexity and possibly reduce performance with the added overhead of map and unmap operations. It's only recently that systems have become large enough for that to be considered, but because the system address space is not a constraint for mapping the entire PFN database on 64-bit Windows, support for more memory is left to 64-bit Windows.
The maximum 2TB limit of 64-bit Windows Server 2008 Datacenter doesn't come from any implementation or hardware limitation, but Microsoft will only support configurations they can test. As of the release of Windows Server 2008, the largest system available anywhere was 2TB and so Windows caps its use of physical memory there.



Configuration of FTP Server in LINUX 5.3

Ftp server is designed for uploading and downloading the files, when ftp server users log's in, they get their home folder at client side and if public/anonymous user log's in they get data stored in /var/ftp folder Steps to

Configure FTP Server in LINUX

Step:--1. Check and install required Packages

Check the packages are installed or not by rpm/yum command 
[root@server ~]# rpm -q vsftpd


Remove the packages and old data if required 
[root@server ~]# yum remove vsftpd* -y

Install the Packages

 Note: Here my file is at Desktop. So i was changing the path to Desktop.

[root@server ~]# cd /root/Desktop/
[root@server Desktop]# ls
FileZilla3 tomcat vsftpd-2.0.5-10.el5.i386.rpm

[root@server Desktop]# chmod 777 vsftpd-2.0.5-10.el5.i386.rpm

[root@server Desktop]# rpm -ivh vsftpd-2.0.5-10.el5.i386.rpm
warning: vsftpd-2.0.5-10.el5.i386.rpm:
Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

Step:--2. Create the resources on ftp server (file/folder & Users)


Create users and assign passwords to whom you want to allow logging through ftp


[root@server ~]# useradd vinay
[root@server ~]# useradd test

[root@server ~]# passwd test
Changing password for user test.
New UNIX password:
BAD PASSWORD:
it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.


[root@server ~]# passwd vinay
Changing password for user vinay.
New UNIX password:
BAD PASSWORD:
it is too simplistic/systematic
 Retype new UNIX password:
passwd: all authentication tokens updated successfully.


Create or Copy some files inside /var/ftp/pub folder


[root@server ~]# cd /var/ftp/pub/ 
[root@server pub]# touch abc.txt cde.txt audio.mp3 vedio.avi
[root@server pub]# ls 
abc.txt cde.txt audio.mp3 vedio.avi




Create a Upload folder for anonymous users and give full permission for read/write.


For example 
oracle helps
[root@server pub]# mkdir /var/ftp/oracle helps 
[root@server pub]# chmod 777 /var/ftp/oracle helps
[root@server pub]#


Step:--3. Edit the Main Configuration file /etc/vsftpd/vsftpd.conf


[root@server ~]# vi /etc/vsftpd/vsftpd.conf
# FTP EXAMPLES
12 anonymous_enable=YES
15 local_enable=YES
27 anon_upload_enable=YES
83 ftpd_banner=Welcome to oracle helps
:wq!


Step:-- 4. To block the ftp server users (for Ex:-- test) write the user name in file

/etc/vsftpd/ftpusers


[root@server ~]# vi /etc/vsftpd/ftpusers

# Users that are not allowed to login via ftp
test
:wq!

Step:--5. start th ftp service


[root@server ~]# vi /etc/vsftpd/ftpusers
[root@server ~]# service vsftpd restart
Shutting down vsftpd: [FAILED]
Starting vsftpd for vsftpd: [ OK ]

[root@server ~]# service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]

Note: Your system Firewall should be turnoff or In firewall settings ftp exception should be added.


For Checking your ftp in Client Machine, Do the following steps:



1.Open the Web Browser and give following

URL ftp://192.168.xxx.xxx/

Here replace your ftp server IP address.

To upload or Any changes use any Ftp Software like Winscp or Filzilla , etc....



Optional
User Prompting userid & password on FTP



Thursday, 12 July 2012

User Default Setting (LINUX)

set the default user setting

/etc/defaults/useradd

Disable Unnecessary Services (LINUX)


An important security principle is “if you don’t need it, disable it”. All running services expose the system to some level of risk. Obviously, some services are much more vulnerable than others but often you don’t know what the vulnerabilities of any given service are, and some may yet to have been discovered.
To see what services are enabled enter:
/sbin/chkconfig –list

To disable a service enter:
/sbin/chkconfig -del service
At a minimum the following should be disabled:
/sbin/chkconfig -del bluetooth
/sbin/chkconfig -del cups
/sbin/chkconfig -del autofs
/sbin/chkconfig -del isdn
/sbin/chkconfig -del portmap
/sbin/chkconfig -del vncserver
/sbin/chkconfig -del mdmonitor
/sbin/chkconfig -del winbind

It is also a good idea to go through the /etc/xinetd.d directory and delete any unused services here. For example:
rm /etc/xinetd.d/gssftp
rm /etc/xinetd.d/krb5-telnet
rm /etc/xinetd.d/tftp
rm /etc/xinetd.d/daytime*
rm /etc/xinetd.d/chargen*
rm /etc/xinetd.d/ekrg5-telnet*


Configure Password Policy (GLOBAL USERS LINUX)


The following settings force users to change their password every 90 days and enforce passwords at least 8 characters long.
su root
Enter root password
vi /etc/login.defs
Edit the file as follows:
PASS_MAX_DAYS 90
PASS_MIN_DAYS 1
PASS_MIN_LEN 8
PASS_WARN_AGE 14
Type ESC:x! to save and exit

Wednesday, 11 July 2012

samba server configuration in RHEL 5 AND RHEL 6.1 step by step


Samba is a suite of utilities that allows your Linux Machines to share files and other resources.
such as printers with Windows Machines.

Before configuring Samba server in Linux you need to have the following Pre-requests.

1. Linux System with network Configured Here i was configured My IP as 192.168.10.111 

2. Windows System with network configured in Same network. here my System is having 192.168.10.108 

3.Your Linux System firewall should be disabled. 

Main Configuration:

1. Check your linux system wheather the samba package is installed or not with the following 

command. [root@localhost ~]# rpm -qa samba*

2. If the packages are not installed in your system, use the following command to install from the internet. 

[root@localhost ~]# yum install samba* 

Note: Above command is for installing the packages from the internet only. So you should have the internet connection.

3. After installing the Packages 
Make sure that xinetd and Portmap service should be run. 
For checking those services are running or not, use the following commands.

[root@localhost ~]# /etc/init.d/xinetd status 

[root@localhost ~]# /etc/init.d/portmap status

For starting the above service use the following services use the following commands. 

[root@localhost ~]# /etc/init.d/xinetd restart 

[root@localhost ~]# /etc/init.d/portmap restart

After that Make sure that these services to be run completely.

 For that use the following commands.
[root@localhost ~]# chkconfig xinetd on 
[root@localhost ~]# chkconfig portmap on 

Check the services is running or not. These services should be running condition.

4. Create 2 users in your linux System i.e: vinay and Test 

[root@localhost ~]# useradd vinay 
[root@localhost ~]# passwd vinay 
Changing password for user vinay. 
New password: 
Retype new password: passwd: all authentication tokens updated successfully. 

[root@localhost ~]# useradd Test 
[root@localhost ~]# passwd Test 
Changing password for user Test. 
New password: 
Retype new password: passwd: all authentication tokens updated successfully.


5. Now create the share directory. i.e which directory you want to share. Here iam creating directory called 'Sambashare' in the following Path. i.e /opt and give the full Permissions to the directory.

[root@localhost ~]# mkdir /opt/sambashare/ 
[root@localhost ~]# chmod 777 /opt/sambashare/   (OPTIONAL #chmod -R 1777 /opt/sambshare/  it means only these users RW permission not others users)

[root@localhost ~]# ls -l /opt/ 
total 360 
drwx------. 2 root root 16384 Feb 1 11:01 lost+found 
drwxrwxrwx 3 root root 4096 Feb 6 18:12 sambashare 
-rwxrwxrwx. 1 root root 344558 Jan 30 15:41 sysstat-10.0.3-1.i586.rpm


6. Now enter the configuration into following file. i.e

 /etc/samba/smb.conf 
In the above file enter the following configuration. Here iam giving permission to one user only. 
Add the configuration at end of the file. 

Note: Better to take the backup of the configuration file.

[root@localhost ~]# vi /etc/samba/smb.conf 
    # My Sharing directory 
       [data] 
comment = personal share 
path = /opt/sambashare 
public = no 
writable = yes 
Read only = no 
printable = no 
browseable = yes
write list = vinay Test 

:wq! 

Use these to save the configuration file 

:wq!

7. Now add the user to the samba user's List 

[root@localhost ~]# smbpasswd -a vinay 
New SMB password: 
Retype new SMB password: 
Added user vinay.
[root@localhost ~]#

8. Now we did the all the configurations. so start the samba service and check its status. 

[root@localhost ~]# chkconfig smb on 
[root@localhost ~]# /etc/init.d/smb restart 
Shutting down SMB services: [ OK ] 
Starting SMB services: [ OK ] 

[root@localhost ~]# /etc/init.d/smb status 
smbd (pid 3686) is running...


Client side configuration for Samba server.

1. Check from your windows System to samba server whether Ping command is working or not. 

Start--> run--> cmd --> Ping 192.168.10.111

If you are getting ping with proper reply then your server is working fine or else check the network connectivity and Linux System firewall.


2. Now access your samba server in the following way. 

Start --> Run --> \\192.168.10.111 -->Press enter. 

(Here IP address is your samba server IP address)

3. It is asking for samba user's username and password.

4. This is your samba server Main Screen.

5. Now you can Copy or Paste your data.


Read only permission so create sharing folder and gave read only permission on file.

How do I set permissions to Samba shares? 
Samba Basic permissions are as follows (configuration file is smb.conf [/etc/samba/smb.conf]): 

 read only: This parameter controls whether an user has the ability to create or modify files within a share. This is default. 

 guest ok: Uf this parameter is set to yes, the users will have access to the share without having to enter a password. This can pose security risk. 

 writeable: Specifies users should have write access to the share. You can create the share called helpfiles with read only permission. 

[helpfiles]
path = /usr/share/docs 
read only = Yes


You can create the share called salesdoc with write permission 
[salesdoc] 
path = /home/shared/sales 
writeable = Yes

You can also create a list of users to give write access to the share with write list option.
 For example allow rocky and tony to write to the share called sales: 
[salesdoc] 
path = /home/shared/sales 
write list = rocky tony

You can use following options

  read list: This option accepts a list of usernames or a group as its value. Users will be given read-only access to the share. 
 valid users: You can make a share available to specific users. Usernames or group names can be passed on as its value. 
 invalid users: Users or groups listed will be denied access to this share.



Samba mask permission It is also possible to specify samba default file creation permission using mask. 

 create mask: This option is set using an octal value when setting permissions for files. 
 directory mask: Directories must have the execute bit for proper access. Default parameter is 0755. 
.
[salesdoc] 
path = /home/shared/sales
write list = rocky sys 
create mask = 0775


[root@oracle home]# smbstatus
Samba version 3.0.33-3.7.el5

PID Username Group Machine
-------------------------------------------------------------------
4614 almondz almondz hp2210-pc (192.168.11.99)
4608 Test Test nishank (172.16.10.15)
4611 almondz almondz nakulsharma (192.168.21.21)
4418 almondz almondz almo (192.168.21.137)
Service pid machine Connected at
-------------------------------------------------------
IPC$ 4418 almo Sun Mar 11 05:00:22 2012
almondz 4608 nishank Sun Mar 11 05:14:48 2012
data 4418 almo Sun Mar 11 05:00:24 2012
IPC$ 4611 nakulsharma Sun Mar 11 05:15:01 2012
IPC$ 4614 hp2210-pc Sun Mar 11 05:16:18 2012
IPC$ 4608 nishank Sun Mar 11 05:14:05 2012
No locked files



=================================================================


RHEL 6.1

remove rpm -e samba*

yum install samba*

/etc/samba/smb.conf

-------smb.conf
        hosts allow = 127. 192.168.12. 192.168.56.  10.128.   //uncommented this line and add ip series

[tptrc-01]
        comment = personal share
        path = /home/tptrc/tptrc-01
        writable = yes
        browseable = yes
        write list = tptrc-01
        valid users = tptrc

----- Hide directory directory
[tptrc]
        comment = personal share
        path = /home/tptrc
        writable = no
        browseable = no


useradd share
mkdir /home/share/tptr-04 -p
chown root:share -R tptr-04
chmod -R 775 tptr-04


chkconfig --levels 235 smb on
/etc/init.d/smb restart

smbpasswd  -a share


password : xxxxx



Enjoy............?

Tuesday, 3 July 2012

SWAP PARTITION ON RHEL


===============
Swap Files Partition
===============
As an alternative to creating an entire partition, a swap file offers the ability to vary its size on-the-fly, and is more easily removed altogether.
This may be especially desirable if disk space is at a premium (e.g. a modestly-sized SSD).
Note: The BTRFS filesystem does not currently support swapfiles.

Swap file creation
=============
As root use fallocate to create a swap file the size of your choosing (M = Megabytes, G = Gigabytes)
(dd can also be used but will take longer). For example, creating a 512 MB swap file:

cd /u02/

# fallocate -l 4096M /swapfile      // optional
# dd if=/dev/zero of=swapfile bs=1M count=4096

Set the right permissions (a world-readable swap file is a huge local vulnerability)
# chmod 600 swapfile

After creating the correctly-sized file, format it to swap:
# mkswap swapfile

Activate the swapfile:
# swapon swapfile

Edit /etc/fstab and add an entry for the swap file:
/u02/swapfile none swap defaults 0 0

This invocation creates a file called my_swap in /var. It is 128 Mb long (128 x 1024 = 131072). Initially, it is filled with zeros.
However, mkswap marks it as swap space and swapon tells the kernel to start using it as swap space. When you are done with it,

swapoff /u02/swapfile
rm /u02/swapfile

==============
Remove swap file
==============
To remove a swap file, the current swap file must be turned off.
As root:
# swapoff -a

Remove swapfile:
# rm -rf /swapfile


========================================================================


================
Swap with USB device
================


Thanks to modularity offered by Linux, we can have multiple swap partitions spread over different devices. If you have a very full hard disk,
USB device can be used as partition temporally. But this method has some severe disadvantage

* USB device is slower than hard disk.
* flash memories have limited write cycles. Using it as swap partition will kill it quickly.
* when another device is attached to the computer, no swap can be used.

To add a a USB device to SWAP, first take a USB flash and partition it with a swap partition.You can use graphical tools such as
Gparted or console tools like fdisk. Make sure to label the partition as SWAP before writing the partition table.
Make sure you are writing the partition to the correct disk!

Next edit the fstab
# nano /etc/fstab

Now add a new entry, just under the current swap entry, which take the current swap partition over the new USB one

UUID=... none swap defaults,pri=10 0 0

where UUID is taken from the output of the command
ls -l /dev/disk/by-uuid/ | grep /dev/sdc1

Just replace sdc1 with your new USB swap partition. sdb1

We use UUID because when you attach other devices to the computer it could modify the device order
Last, add

pri=0

in the original swap entry for teaching fstab to use HD swap only when USB is full
This guide will work for other memory such as SD cards, etc.


========================================================================

============
Swap partition
============
A swap partition can be created with most GNU/Linux partitioning tools (e.g. fdisk, cfdisk). Swap partitions are designated as type 82.

NOTE : Only Primary Partition  Use

To set up a Linux swap area, the mkswap command is used. For example:

fdisk /dev/sdb
p
n
p
+4096M
t
82
w

# mkswap /dev/sda2

Warning: All data on the specified partition will be lost.

To enable the device for paging:
# swapon /dev/sda2     // swapoff

To enable this swap partition on boot, add an entry to fstab:
/dev/sda2 none swap defaults 0 0

Friday, 15 June 2012

Linux Yum Server


How To Create Yum Server
====================

# cd /etc/yum.repos.d/
# ls
# cp -p rhel-debuginfo.repo server.repo
# ls
# vim server.repo
[rhel]
name=Red Hat Enterprise Linux
baseurl=file:///rhel5
enabled=1
:wq!
# cd
# yum clean all
# yum list all