Tuesday, 31 March 2015

7. Redhat Linux : RHCE 6

7. Redhat Linux : RHCE 6


Firewall
      
* iptables used to configure firewall settings
* iptables -t filter/NAT -I INPUT/OUTUT -s/-d Source_IP/Destination_IP -P tcp/udo/icmp --dport Destn_Port_No -j accept/reject/drop
* /etc/sysconfig/iptables
* 6535 ports are there in server
* /etc/services lists all the port infos

DHCP
* port 68
* range giving for dynamic IPs are called leases
* can be used for IPV4 and IPV6(dhcpd,dhcpd6)

Steps to do at server:
---------------------
1. yum install dhcp -y
2. cp /usr/share/doc/dhcp-4.1.1/dhcp.conf.sample /etc/dhcp/dhcpd.conf
3. vim /etc/dhcp/dhcpd.conf
 line 32 give 'subnet server_ip netmask netmask{ range start_IP End_IP}'
 comment all other lines except line 8,9,22, and 32
4. service NetworkManager restart
5. service network restart
6. route -n
7. route add default gw server_ip

Steps to do at client:
---------------------
1. service NetworkManager restart
2. service network restart
3. route add default gw 192.168.3.1

/*
Commands for the day:
--------------------
* iptables -t filter -I INPUT -s 192.168.2.0/24 -p tcp --dport 22 -j REJECT
* iptables -t filter -I INPUT -s 192.168.2.0/24 -p icmp -j REJECT
* service iptables save
* nslookup ip
* dig ip
* ps  : process status
* ps a  : process status
* ps u  : process status
* ps x  : process status
* top  : task manager
 pid
 user
 priority(depends on NI, inversily proportional)
 Nice value
 Virtualization Image
 residence value(RAM)
 Shared value(between swap and ram)
 Status
* renice -19 PID  : to re allocate nice value(+19 to -19)
* vmstat   : virtual memory statistics (eg. vmstat 2 5 :- 2 processes 5 programs)
* cat /proc/cpuinfo
* cat /proc/meminfo
* cat /proc/cmdline
* iostat
* sar   : system activity report
* ifconfig eth0:0

*/

Tuesday, 3 February 2015

8. Redhat Linux : RHCE 6

8. Redhat Linux : RHCE 6



Log files:
* variable messages are stored in /var file
* three types of logs:
 system logs ( /var/log/messages )
 secure logs ( /var/log/secure )
 kernel logs ( /var/log/dmesg )

* rsyslogd generates the logs in RHEL 6
* syslogd + klogd in RHEL 5
* 546 is the port for logs
* config file is /etc/rsyslog.conf
 2 fields:
  selector
  action
* NTP (Network time protocol) is used to maintain network time
* logrotate is used to reuse the same server in particular period after backup
* /etc/logrotate.conf
* /etc/hosts is called cache DNS
* Primary DNS:
* Secondary DNS: 
 to support primary, so it is called failover.
 also be used in load balancing
* Teritiary DNS:
 can be used as cache
* Domain server gives the local mounting(eg: gmail)
* LDAP : Light weight access protocol
* NIS(Network Information Storage) : Active directory for linux

ISCSI
* scsi-target-utils is the package
* tgtd is the service
* /etc/tgt/target.conf
Steps to do at server:
 1. fdisk /dev/sda
 2. partprobe /dev/sda
 3. pvcreate /dev/sdxy
 4. vgcreate vg1 /dev/sdxy
 5. lvcreate -n lv1 -L 460M vg1
 6. yum install scsi-target -y
 7. vim /etc/tgt/targets.conf
 8. service tgtd restart
 9. chkconfig iptables on

Steps to do at client:
 1. yum install scsi-target -y
 2. iscsiadm -m discovery -t st -p server_ip
 3. iscsiadm -m node -T iqn.2015-04.com.exapmle:server1.target1 -l
 4. fdisk -l
 5. iscsiadm -m node -T iqn.2015-16.com.example:server.target1 -u
 6. mount

TCP Wrappers
* /etc/hosts.allow stores the users to deny
 VSFTPD:server1.exapmle.com
* /etc/hosts.deny
 
Disk Quota
* to give some space reserved for users
* 2 limits:
 soft limits(if it cross the limit, say 1 GB, it will display warning and allow to create more files)
 hard limits(if it cross the limit, say 1 GB, it will not display warning and do not allow to create more files)
* edquota to edit quota
* repquota for listing quotas
/*
Commands for the day:
--------------------
* edquota username
*/

Saturday, 31 January 2015

9. Sample Test

9. Sample Test

 
Note : Please go through the parent posts 1-8 to know about this test. 
 

Q1. Create users Natasha, Harry and Sarah. Natasha and Harry should be member of secondary group admin and Sarah should not be the member. Sarah should have no interactive shell and password of all users are wakennym.

Q2. Create /common/adm. Group owner should be admin. Only admin group should have read write execute permission. Natasha and Harry should connect to /common/adm. Any file under /common/adm should have group admin.

Q3. Copy /etc/fstab to /var/tmp/fstab. Owner and group should be root. Natasha should be allowed to read and write and no one should be allowed to execute. And all others should be able to read the files. Harry should not be allowed to read or write.

Q4. Create the partition having 500 MB size and mount it in /mnt/backup.

Q5. Resize lvm from 100 MB to 300 MB

Q6. Configure swap of 700 MB

================================================================================
ANSWERS
Ans 1:  
    groupadd admin
    useradd -G admin Natasha
    passwd Natasha
    useradd -G admin Harry
    passwd Harry
    useradd -s /sbin/nologin Sarah

Ans 2:
mkdir -p /common/adm chgrp -R admin /common chmod -R 2070 /common

Ans 3:
cp -rvf /etc/fstab /var/tmp/fstab setfacl -m u:Natasha:rw /var/tmp/fstab setfacl -m u:Harry:000 /var/tmp/fstab setfacl -m u:Sarah:r /var/tmp/fstab
Ans 4: fdisk /dev/sda n 7 default +500M w mkfs -t ext4 /dev/sda7 mkdir /mnt/backup mount /dev/sda7 /mnt/backup
Ans 5: fdisk /dev/sda n 8 default +500M t 8 8e w pvcreate /dev/sda8 vgcreate VG1 /dev/sda8 lvcreate -n LV1 -l 25 VG1 mkfs.ext4 /dev/sda8 lvextend -L +200M /dev/VG1/LV1 resize2fs -p /dev/VG1/LV1
Ans 6: fdisk /dev/sda n 9 default +700M t 9 82 w mkswap /dev/sda9 swapon /dev/sda9

For any help;
noohppnoohpp@gmail.com

Tuesday, 21 October 2014

Play on Disks with Ubuntu

Play on Disks with Ubuntu


1. Partitioning of  devices using fdsik tool:

    $ fdisk -l /* Listing all partition details of all available devices */
    $ sudo fdisk /dev/sdx /* selecting fdisk tool for sdx device */
        p /* display present partitions */
        d(untill no partition exists) /* deleting existing partitions */
        n /* Creating new partitions */
        p /* selecting partiton as primary */
        1 /* giving partition number */
        (default) /* offset byte */
        (select size) /* needed partition size */
        w /* write changes */
    $ sudo mkfs.(filesystem type) /dev/sdx1 /* format the new partition as a file system type */

2. Bootable SD card without any third party:

    $ sudo mkfs.vfat -F32 /dev/sdx /* Formating the card */
    $ sudo tar -xvf ubuntu.iso /* Extracting the iso image */
    $ sudo cp -rvf ubuntu/ /SD_CardMountPoint /* Copying contents to card */
    rename isolynux folder into syslinux
    rename syslinux/isoconfig to syslinux/sysconfig

For more help click here

3. White listing icons in the display panel:

    $ gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"   

4. Adding repositories and ppa's in Ubuntu:

    $ sudo add-apt-repository "deb <repository_link>"
    $ sudo add-apt-repository ppa:<ppa_name>
    $ sudo apt-get update
    $ sudo apt-get install <Package_name>

5. Checkout repository using svn:

    $ svn checkout svn://<ip_address_of_server> /* Cloning from server */
    $ sudo git clone git://github.com/<path>.git /* Cloning from git */

6. For creating symbolic links:

    $ sudo ln -sv <original_path> <link_path>

7. Compile wxWidgets programs:

    $ ./configure --disable-shared --enable-monolithic --enable-unicode --enable-debug
    $ make SHARED=0 MONOLITHIC=1 UNICODE=1 BUILD=debug
    $ sudo make install

   Cross Compiling:
   
    $ sudo ./configure --prefix=/usr/nooh/gen --exec-prefix=/usr/nooh/arm --pdfdir=/usr/nooh/pdf --x-includes=/usr/nooh/includes --x-libraries=/usr/nooh/libraries --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf  --enable-monolithic --enable-debug --disable-shared --enable-unicode --enable-webview --with-gtk  --disable-gtktest --disable-gtktest --disable-sdltest
    $ make SHARED=0 MONOLITHIC=1 UNICODE=1 BUILD=debug
    $ sudo make install

    $ cc `wx-config --cxxflags` `wx-config --libs` <program_name>
       
        or

    $ g++ -c `wx-config --cxxflags` -o hello.o hello.cpp
    $ g++ -o hello hello.o `wx-config --libs`

For more help Click here

8. Export path to linker:

    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path>

9. Setting up network:

    $ sudo ifconfig eth0 <ip_address> netmask 255.255.0.0
    $ sudo mv /etc/apt/sources.list /etc/apt/sources.list.d/
    $ sudo touch /etc/apt/sources.list
    $ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" (forubutnu 12.04)