Sunday, July 29

Introduction of Linux FTP Server


The File Transfer Protocol (FTP) is used as one of the most common means of copying files between servers over the Internet. Most web based download sites use the built in FTP capabilities of most web browsers and therefore server oriented operating systems usually include an FTP server application as part of the software suite. Linux is no exception.
Here we will show you how to convert your Linux Machine into an FTP server using the default Very Secure FTP Daemon (VSFTPD) package. 

FTP Overview

FTP relies on a pair of TCP ports to get the job done. It operates in two connection channels as I'll explain:
FTP Control Channel, TCP Port 21: All commands you send and the ftp server's responses to those commands will go over the control connection, but any data sent back (such as "ls" directory lists or actual file data in either direction) will go over the data connection.
FTP Data Channel, TCP Port 20: This port is used for all subsequent data transfers between the client and server.
In addition to these channels, there are several varieties of FTP.

FTP frequently fails when the data has to pass through a firewall, because firewalls are designed to limit data flows to predictable TCP ports and FTP uses a wide range of unpredictable TCP ports. You have a choice of methods to overcome this. 

Package Required: vsftpd

Introduction Of IPTABLES


Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Several different tables may be defined. Each table contains a number of built-in chains and may also contain user-defined chains.
Each chain is a list of rules which can match a set of packets. Each rule specifies what to do with a packet that matches. This is called a 'target', which may be a

Targets

A firewall rule specifies criteria for a packet and a target. If the packet does not match, the next rule in the chain is the examined; if it does match, then the next rule is specified by the value of the target, which can be the name of a user-defined chain or one of the special values ACCEPT, DROP, QUEUE or RETURN.

ACCEPT means to let the packet through. DROP means to drop the packet on the floor. QUEUE means to pass the packet to user space. (How the packet can be received by a user space process differs by the particular queue handler. 2.4.x and 2.6.x kernels up to 2.6.13 include the ip_queue queue handler. Kernels 2.6.14 and later additionally include the nfnetlink_queue queue handler. Packets with a target of QUEUE will be sent to queue number '0' in this case. Please also see the NFQUEUE target as described later in this man page.) RETURN means stop traversing this chain and resume at the next rule in the previous (calling) chain. If the end of a built-in chain is reached or a rule in a built-in chain with target RETURN is matched, the target specified by the chain policy determines the fate of the packet.

Set Default Chain Policies

Saturday, July 21

How to Extend and Reduce Logical Volume


The biggest advantage of logical volume manager is that you can extend your logical volumes any time you are running out of the space. To increase the size of a logical volume by another 800 MB you can run this command:

1. How to Extend

# lvextend -L +800M/G <LV path>
The command above does not actually increase the physical size of volume, to do that you need to:
# resize2fs  <LV path>
The above method we use for online resizing and below is by unmounting.

Wednesday, July 18

Linux/Unix sort command examples

This is a small tutorial on how to use sort command to sort a file. Sorting is very useful when dealing with DB files, CSV, xls, log files in fact a text file too. By default sort command will sort according to alphabets. First sort tries to sort according to single character, if it finds the first character same in two lines, then it moves to sort second character. Suppose I have a following word list in a file
cat filename.txt
abc
cde
hij
klm
kle
ble
This will be sorted first with first char. When it finds both the char same in this example klm and kle start with same characters, so it tries to sort with third character which is different in them. The output of sort  as below
sort filename.txt
abc
ble
cde
hij
kle
klm

How to setup More Than One IP address on single NIC in Linux

Setting up two IP address on single NIC
There are some times we require two IP address to set up so that we can make a Linux box as a router. It can be possible without even having two NIC cards. We can configure more than two different IP address on single Network Card as shown below:
This example is on Ethernet.
STEP 1: Setting up first IP address. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 on Red-hat Linux box and give the following entries as shown.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
  • DEVICE=eth0
  • BOOTPROTO=static
  • IPADDR=192.168.1.10
  • NETMASK=255.255.255.0
  • NETWORK=192.168.1.0
  • ONBOOT=yes

Tuesday, July 17

How to view/list only directories in Linux

This is a small post for Linux beginners . Viewing folders can be achieved by two ways in linux/UNIX
  1. Through ls command
  2. Through find command
With ls we have to use grep to get the directory listings..
Ls –l | grep ^d
Through find command
find . -type d
Example

23 Linux cd command examples


This is a basic post to show you what we can do with cd command to reduce your time spending at terminal by using alias, tips and some shortcuts.cd(Change Directory) is a basic command which is used to change your working directory from one to other. Here are some productivity tips and some less known tips to you people. Feel free to comment on this.
Example1: Change working directory to /abc/xyz
pwd
/home/surendra
cd /abc/xyz
pwd
/abc/xyz

Friday, July 13

File System of Linux

The Linux file system is usually thought of in a tree structure. On a standard Linux system you will find the layout generally follows the scheme presented below.
The Directory Structure in Unix & Linux are a unified Directory Structure where in all the directories are unified under the "/" Root file system. Irrespective of where the File System is physically mounted all the directories are arranged hierarchically under the Root file system.
The Linux Directory Structure follows the "File system Hierarchy Structure (FHS)" maintained by the Free Standards Group although most of the distributions sometimes tend to deviate from the standards.






Wednesday, July 11

"find" and "grep" command


"find" command is used to search for files. you can specify many options with it like files created today or having size greater then you specified. Normally we also combine find with xargs or exec to issue commands on files returned by find.
examples of find command:
* find top 10 largest files in /var:
$ find /var -type f -ls | sort -k 7 -r -n | head -10

* find all files having size more than 5 GB in /var/log/:
$ find /var/log/ -type f -size +5120M -exec ls -lh {} \;
* find all today’s files and copy them to another directory:
$ find /home/me/files -ctime 0  -print -exec cp {} /mnt/backup/{} \;

How To Create & Manage LVM in Linux

server1:~# fdisk -l
Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


fdisk /dev/sda

server1:~# fdisk /dev/sda

The number of cylinders for this disk is set to 10443.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

What is LVM In Linux

The logical volume manager allows you to create and manage the storage of your servers in a very useful manner; adding, removing, and resizing partitions on demand.


There several pieces of terminology that you'll need to understand to make the best use of LVM. The most important things you must know are:
  • physical volumes
    • These are your physical disks, or disk partitions, such as /dev/hda or /dev/hdb1. These are what you'd be used to using when mounting/unmounting things. Using LVM we can combine multiple physical volumes into volume groups.
  • volume groups
    • A volume group is comprised of real physical volumes, and is storage used to create logical volumes which you can create/resize/remove and use. You can consider a volume group as a "virtual partition" which is comprised of an arbitary number of physical volumes.
  • logical volumes
    • These are the volumes that you'll ultimately end up mounting upon your system. They can be added, removed, and resized on the fly. Since these are contained in the volume groups they can be bigger than any single physical volume you might have.

Tuesday, July 10

What is a sticky Bit and how to set it in Linux

Sticky bits are mainly set on directories.
If you give 777 (full permission) to any directory then all users can delete,modify all files and directories so to avoid this we use sticky bit. by using it, all users can create and modify their own directories or files not others 
If the sticky bit is set for a directory, only the owner of that directory or the owner of a file can delete or rename a file within that directory.

The following two commands are used  to apply sticky bit on any directory  

chmod +t directory_name 
OR 
chmod 1777 directory_name

Sunday, July 8

Some Linux Interview Questions and Answers--4


There are seven fields in the /etc/passwd file. Which of the following lists all the fields in the correct order? 
Choose one:
a. username, UID, GID, home directory, command, comment
b. username, UID, GID, comment, home directory, command
c. UID, username, GID, home directory, comment, command
d. username, UID, group name, GID, home directory, comment
Answer: b
The seven fields required for each line in the /etc/passwd file are username, UID, GID, comment, home directory, command. Each of these fields must be separated by a colon even if they are empty.
Which of the following commands will show a list of the files in your home directory including hidden files and the contents of all subdirectories?
Choose one:
a. ls -c home
b. ls -aR /home/username
c. ls -aF /home/username
d. ls -l /home/username


Answer: b
The ls command is used to display a listing of files. The -a option will cause hidden files to be displayed as well. The -R option causes ls to recurse down the directory tree. All of this starts at your home directory.
In order to prevent a user from logging in, you can add a(n) ________at the beginning of the password field. 
Answer: asterick

Some Linux Interview Questions and Answers--3


What key combination can you press to suspend a running job and place it in the background?
ctrl-z

Using ctrl-z will suspend a job and put it in the background.
The easiest, most basic form of backing up a file is to _____ it to another location. 
copy

The easiest most basic form of backing up a file is to make a copy of that file to another location such as a floppy disk.
What type of server is used to remotely assign IP addresses to machines during the installation process? 
A) SMB
B) NFS
C) DHCP
D) FT
E) HTTP


Some Linux Interview Questions & Answers---2


In order to run fsck on the root partition, the root partition must be mounted as readonly

You cannot run fsck on a partition that is mounted as read-write.
In order to improve your system's security you decide to implement shadow passwords. What command should you use? 
pwconv

The pwconv command creates the file /etc/shadow and changes all passwords to 'x' in the /etc/passwd file.
Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command? 
passwd boba

Some Linux Interview Questions and Answers----1


You need to see the last fifteen lines of the files dog, cat and horse. What command should you use?

tail -15 dog cat horse

The tail utility displays the end of a file. The -15 tells tail to display the last fifteen lines of each specified file.
Who owns the data dictionary? 
The SYS user owns the data dictionary. The SYS and SYSTEM users are created when the database is created.
You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it, use the _________ utility. 
zcat

How to Create a Swap Partition after installation


How to Create a Swap Partition after installation

Or

How to increase size of Swap Partition

Check swap by:
·         #swapon –s
·         #cat /proc/swaps

There are two following methods for same

Method I:--

By Partition:

  1. Create partition with partition ID 82 (which is ID of Linux swap)

How to Create an Encrypted Partition


How to Create an Encrypted Partition

Case I:--

In GUI Mode:

1)    Go To Application
2)    System Tool
3)    Disk Utility
4)    Select HDD --------à Select Free Space ------à Create Partition -----à Give Size
5)    Have To Check on encrypted underline device option
6)    Then Click Create then give Passphrase(Password)
7)    Then Create

Saturday, July 7

Squid Proxy Server



Squid Proxy Server

It's used to provide the internet connectivity to network connected system ny using single internet connection.
·         Package Required:- squid
·         Daemon name :--squid
·         Port Number:-- 3128
·         Path of config file:- /etc/squid/squid.conf

Key Point:--
1.    Install squid proxy
2.    on and start service by:- #service squid start
3.    Give two IPs one for internet and another for LAN

5 steps to secure your Linux server



5 steps to secure your Linux server

How would you ensure security of your production Linux Server? Should you can be happy with default configuration there in place or there’s are things which we must implement for enhancing security aspects? Of course, Yes. Here I’m writing 5 steps which I usually take to tighten security in Server. This doesn’t means these are Best thing you can do or You don’t need to do anything else. There are many ways and remember securing your Server is a never ending process, So keep an eye open and check your Server regularly.
Step 1. Disable direct root access. 
Login should be allowed using simple/wheel user and then from there you can switch to root or use sudo to execute commands under root privileges. Let’s disable direct root login:

How To Troubleshoot boot partition in Linux




How To Troubleshoot when /boot partition value has changed
or
To Troubleshoot Error 15/17

Case I:--

1.    Restart System and intrupt booting by pressing any key
2.    Press E on redhat linux title to edit
3.    Again Press E to edit parttion value
4.    After Editing Press B to boot machine

How to change Date, Time and Time Zone in Linux


In Redhat based distro, here’s a quick solution to change your time zone to PST/PDT:

$ mv /etc/localtime /etc/localtime.Old &amp;&amp; ln -s /usr/share/zoneinfo/PST8PDT /etc/localtime
Other commands:

How To Break Root Password in Linux



How To Break Root Password

Case I:--

If Bootloader don't have password or we know bootloader password
Key Points:--
1.    Select Redhat linux title and press E to edit
2.    Press E to edit kernel line
3.    then type 1 after giving single space
4.    Below Editing
5.    kernel /vmlinuz-2.6.32-71.el6.x86_64 ro ....................crashkernel=auto rhgb quiet
6.    After Editing
7.    kernel /vmlinuz-2.6.32-71.el6.x86_64 ro......................crashkernel=auto rhgb quiet 1
8.    Then Enter and boot by B

How to install linux in CLI Mode


How to install linux in CLI Mode

1.    Boot System with Linux DVD
2.    Press Esc
3.    Type/Enter:---> #linux text
4.    Enter
5.    Choose disk test
6.    follow instructions

Benefits of RHCE


Benefits to earning a Red Hat certification
  • Recognition in the industry
  • Increased customer confidence
  • Proof of knowledge and skills
  • Certification verification tool for employers
  • Use of the certification logo on business cards
  • Ability to access multiple Red Hat Certificated Professional online communities (like Facebook and LinkedIn)

Red Hat Certified Engineer — RHCE



An RHCE® certification is earned by a Red Hat® Certified System Administrator (RHCSA) who has demonstrated the knowledge, skill, and ability required of a senior system administrator responsible for Red Hat Enterprise Linux® systems. Professionals holding this certification have continually helped their companies with successful deployments and migrations.
Prerequisites

Linux and GNU



Linux and GNU

Although there are a large number of Linux implementations, you will find a lot of similarities in the different
distributions, if only because every Linux machine is a box with building blocks that you may put together
following your own needs and views. Installing the system is only the beginning of a longterm relationship.
Just when you think you have a nice running system, Linux will stimulate your imagination and creativeness,
and the more you realize what power the system can give you, the more you will try to redefine its limits.
Linux may appear different depending on the distribution, your hardware and personal taste, but the
fundamentals on which all graphical and other interfaces are built, remain the same. The Linux system is
based on GNU tools (Gnu's Not UNIX), which provide a set of standard ways to handle and use the system.

Properties of Linux



Linux Pros

A lot of the advantages of Linux are a consequence of Linux' origins, deeply rooted in UNIX, except for the
first advantage, of course:
Linux is free:
As in free beer, they say. If you want to spend absolutely nothing, you don't even have to pay the
price of a CD. Linux can be downloaded in its entirety from the Internet completely for free. No
registration fees, no costs per user, free updates, and freely available source code in case you want to
change the behavior of your system.

Introduction Of Linux



Introduction Of Linux

We will start with an overview of how Linux became the operating system it is today. We
will discuss past and future development and take a closer look at the advantages and
disadvantages of this system. We will talk about distributions, about Open Source in general
and try to explain a little something about GNU.


This chapter answers questions like:
♦ What is Linux?
♦ Where and how did Linux start?
♦ Isn't Linux that system where everything is done in text mode?
♦ Does Linux have a future or is it just hype?
♦ What are the advantages of using Linux?
♦ What are the disadvantages?
♦ What kinds of Linux are there and how do I choose the one that fits me?
♦ What are the Open Source and GNU movements?