Monday, 24 November 2014

The dmesg Command

The dmesg Command




The dmesg  command s used to write the kernel messages in Linux 
A kernel is the core of an operating system. It is the first part of the OS that is loaded into memory when a computer bootup (i.e., starts up), and it controls virtually everything on a system. The numerous messages generated by the kernel that appear on the display screen as a computer boots up show the hardware devices that the kernel detects and indicate whether it is able to configure them.
dmesg obtains its data by reading the kernel ring buffer. A buffer is a portion of a computer's memory that is set aside as a temporary holding place for data that is being sent to or received from an external device, such as a hard drive disk (HDD), printer or keyboard. A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest data in it. dmesg can be very useful when troubleshooting or just trying to obtain information about the hardware on a system. Its basic syntax is
dmesg [options]
Invoking dmesg without any of its options(which are rarely used) causes it to write all the kernel messages to standard output. This usually produces far too many lines to fit into the display screen all at once, and thus only the final messages are visible. However, the output can be redirected to the less command through the use of a pipe, thereby allowing the startup messages to be viewed one screenful at a time:
dmesg | less
less allows the output to be moved forward one screenful at a time by pressing the SPACE bar, backward by pressing the b key and removed by pressing the q key. (The more command could have been used here instead of the less command; however, less is newer than more and has additional functions, including the ability to return to previous pages of the output.)
When a user encounters a problem with the system, it can be convenient to write the output of dmesg to a file and then send that file by e-mail to a system administrator or other knowledgeable person for assistance. For example, the output could be redirected to a file named boot_messages using the output redirection operator (designated by a rightward facing angle bracket) as follows:
dmesg > boot_messages
Because of the length of the output of dmesg, it can be convenient to pipe its output to grep, a filter which searches for any lines that contain the string (i.e., sequence of characters) following it. The -i option can be used to tell grep to ignore the case (i.e., lower case or upper case) of the letters in the string. For example, the following command lists all references to USB(universal serial bus) devices in the kernel messages:
dmesg | grep -i usb
And the following tells dmesg to show all serial ports (which are represented by the string tty):
dmesg | grep -i tty
The dmesg and grep combination can also be used to show how much physical memory (i.e., RAM) is available on the system:
dmesg | grep -i memory
The following command checks to confirm that the HDD(s) is running in DMA (direct memory access) mode:
dmesg | grep -i dma
The output of dmesg is maintained in the log file /var/log/dmesg, and it can thus also be easily viewed by reading that file with a text editor, such as vi or gedit, or with a command such as cat, e.g.,
cat /var/log/dmesg | less

Monday, 8 September 2014

To install Local yum server or yum client on Centos 6 & Centos 7 ( Also Redhat 6 )



To install Local yum server or yum client  on Centos 6 & Centos 7 ( Also in Redhat 6 ) 


We are using 2 system , 1 for server & 2 for client system.

Yum Server OS               : Centos 6.4 & 7           
Yum Server IP Address   : 192.168.1.2
Client OS                       : Centos 6.4 & 7
Client IP Address           :  192.168.1.3

SERVER SIDE :- 192.168.1.2

Insert Your Centos DVD in server CD/DVD rom .

# mount /dev/cdrom /mnt/
# cd /mnt/
# cd Packages/
# rpm -ivh vsftpd-2.2.2-11.el6_3.1.i686.rpm

  warning: vsftpd-2.2.2-11.el6_3.1.i686.rpm: Header V3 RSA/SHA1 Signature, key ID
  c105b9de: NOKEY
  Preparing...               ########################################### [100%]
  1:vsftpd                    ########################################### [100%]

# service vsftpd restart
# chkconfig vsftpd on
# rpm -ivh libxml2-python-2.7.6-8.el6_3.4.i686.rpm
# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.i686.rpm
# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm
# rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm
# mkdir /var/ftp/pub/Packages
# cp -ar /mnt/Packages/*.* /var/ftp/pub/Packages

{note :- remove or rename to all older repositories } 

# vi /etc/yum.repos.d/yum.repo
     
      [YumServer]
      name=Packages
      baseurl=file:///var/ftp/pub/Packages               (note:- We are using '///' in server )
      gpgcheck=0

      enabled=1

      :wq

# setsebool -P ftp_home_dir on
# vi /etc/sysconfig/iptables
      [...]
      -A INPUT -p udp -m state --state NEW --dport 21 -j ACCEPT
      -A INPUT -p tcp -m state --state NEW --dport 21 -j ACCEPT
      [...]

      :wq

# createrepo -v /var/ftp/pub/Packages



# yum clean all
# yum update

CLIENT SIDE :- 192.168.1.3

# vi /etc/yum.repos.d/yum.repo
      [YumServer]
      name=Packages
      baseurl=ftp://192.168.1.2/pub/Packages               (note:- We are using '//' in client )
      gpgcheck=0

      enabled=1

      :wq

# yum update



enjoy your yum server ......


Friday, 5 September 2014

Backup through script on Centos, Redhat, Fedora ( Any flavor of Linux )


Backup through script on Centos, Redhat, Fedora ( Any flavor of Linux  )

Through this script , we can take backup of file , folder , any drive etc 

Create a folder to take backup . For Example :-

$mkdir ~/backup/
$cd  /usr/local/bin/
$vi backup.sh
***********************************************************************************
***********************************************************************************
         #!/bin/bash
         # A script for backing up any file & folder
         # First argument : The directory to be backed up
         # Second argument : The location to back-up to.
                        ORIG=$1
                        BACK=~/backups/

          if [ -e $BACK ]
          then
                        echo "WARNING:$BACK exists"
                        read -p "Press Ctrl+c to exit or Enter to Proceed:"
          fi
          cp -av $ORIG $BACK
          echo "Backup of $ORIG to $BACK completed at:$(date)"


       :wq
************************************************************************************
************************************************************************************
$ chmod 755 backup.sh
$ backup  (Path of file & folder Only )
$ cd  ~/backup/
$ ls -l                                             


*********************************************************************************
**************************************Enjoy *************************************
*********************************************************************************

Wednesday, 3 September 2014

To Capture your own Desktop video & audio for Blog or youtube on Ubuntu 13.04.






To Capture your own Desktop video & audio for Blog or youtube on Ubuntu 13.04. 


In ubuntu 13.04 open "Ubuntu Software center " & search "RecordMyDesktop" . Install this software on ubuntu 13.04 .You can record audio & video both for Blog & YouTube. See all screen shot step by step .









Video to Capture or Play Same background Music


                                                     


In Last Screenshot you check your saved video location or path .Also click given link to see video. how to record .

https://www.youtube.com/watch?v=9jMQK4_qjEQ&feature=youtu.be






Enjoy .....


Tuesday, 2 September 2014

Samba server installation step by step on CentOS 6.x or redhat 6.x


Samba server installation step by step on CentOS 6.x  or redhat 6.x.

Samba is a client/server system that implements network resource sharing for Linux & Windows computers. Through Samba server Printer can be shared linux & windows machine.



To install the samba package,enter the following command:

# yum install samba samba-client samba-common

Check the version of installed samba software by using this command:


# smbd --version
  Version 3.6.9-167.el6_5

Configure the samba service, so that, it will start automatically at boot time:


# chkconfig smb on
# chkconfig nmb on

Add these Iptables rules, so that samba will work perfectly:


# iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
# iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
# iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
# service iptables save


Backup the smb.conf file, then delete it and create the new one:


# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
# rm /etc/samba/smb.conf
# touch /etc/samba/smb.conf
# vi /etc/samba/smb.conf

Add these lines,in your smb.conf file (or change it according to your requirement):

#======================= Global Settings =====================================

[global]

workgroup = WORKGROUP

security = share

map to guest = bad user

#============================ Share Definitions ==============================

[MyShare]

path = /home/samba/share

browsable =yes

writable = yes

guest ok = yes

read only = no

:wq

# service smb restart
# service nmb restart

Change permission for samba share:


# chmod -R 0777 /home/samba/share


Access the samba share from windows(where 192.168.1.15 address of my samba server):






Add and manage Samba users and groups

Add a group in your CentOS server:

# useradd smbuser
# groupadd smbgrp
# usermod -a -G smbgrp smbuser
# smbpasswd -a smbuser

Create a new share, set the permission on the share:

# cd /home/samba/
# mkdir secure
# chown -R arbab:smbgrp secure/
# chmod -R 0770 secure/
# vi /etc/samba/smb.conf

*******Add the newly created samba share in smb.conf file:**********

[Secure]

path = /home/samba/secure

valid users = @smbgrp

guest ok = no

writable = yes

browsable = yes

:wq

# service smb restart
# service nmb restart

Check the syntax error with testparm:


# testparm
Testing from Windows Machine:




Crontab Examples on Linux { Centos ,Redhat, Fedora, ....etc }


Crontab Examples on Linux { Centos ,Redhat, Fedora, ....etc }

Using cron you can execute a shell-script or Linux commands at a
specific time and date. For example a sysadmin can schedule a backup
job that can run every day.

How to add a job to the cron?

# crontab –e

0 5 * * * /root/bin/backup.sh

This will execute /root/bin/backup.sh at 5 a.m every day.

Description of Cron fields

Following is the format of the crontab file.

{minute} {hour} {day-of-month} {month} {day-of-week}
{full-path-to-shell-script}

• minute:              Allowed range   0 – 59
• hour:                 Allowed range   0 – 23

• day-of-month:    Allowed range   0 – 31
• month:              Allowed range   1 – 12.    1 = January. 12 = December.
• Day-of-week:    Allowed range     0 – 7.    Sunday is either 0 or 7.

Crontab examples

1. Run at 12:01 a.m. 1 minute after midnight everyday. This is a good
time to run backup when the system is not under load.

      1 0 * * * /root/bin/backup.sh

2. Run backup every weekday (Mon – Fri) at 11:59 p.m.

      59 11 * * 1,2,3,4,5 /root/bin/backup.sh

Following will also do the same.

     59 11 * * 1-5 /root/bin/backup.sh

3. Execute the command every 5 minutes.

     */5 * * * * /root/bin/check-status.sh

4. Execute at 1:10 p.m on 1st of every month

     10 13 1 * * /root/bin/full-backup.sh

5. Execute 11 p.m on weekdays.

     0 23 * * 1-5 /root/bin/incremental-backup.sh


Crontab Options
The following are the available options with crontab:

• crontab –e : Edit the crontab file. This will create a crontab, if it
  doesn’t exist
• crontab –l : Display the crontab file.
• crontab -r : Remove the crontab file.
• crontab -ir : This will prompt user before deleting a crontab.


Sunday, 31 August 2014

To install FTP Server step by step on CentOS 6.x or Redhat 6.x

To install FTP Server step by step on CentOS 6.x or REDHAT 6.x 

FTP server is used to transfer files between server and clients. All major operating system supports ftp. FTP is the most used protocol over internet to transfer files. Like most Internet operations, FTP works on a client/ server model. FTP client programs can enable users to transfer files to and from a remote system running an FTP server program.

In this blog you learn, To install & Configure FTP server Step by Step on Centos 6.X or Redhat 6.X .  
 Now , install some package on Centos 6.X

# yum install vsftpd*  



Than run command 
# getsebool -a | grep ftp
# setsebool -P  ftp_home_dir on



Now,  Edit /etc/vsftpd/vsftpd.conf file . Uncomment and edit the bold line .
# vi /etc/vsftpd/vsftpd.conf

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to centos FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
use_localtime=YES


:wq

Now, Create User on  Ftp server .
# useradd ravi
# passwd ravi



Now, Add this user on /etc/vsftpd/userlist.
# vi /etc/vsftpd/userlist



 # service vsftpd restart 
 # chkconfig vsftpd on



Now , Open Browser type ftp://IPftpServer , username or password .
ftp://192.168.1.5



You can also try through FileZilla .

Type HOSTIP , User Name , Password , Port no 21 .




Enjoy your FTP server .......