Category Archives: Linux

Beginner’s Guide to understand SSH and Setting up SSH On Ubuntu

This article covers the SSH client on the Linux Operating System.

Note: This article is one of the top tutorials covering SSH on the Internet. It was originally written back in 1999.

There are a couple of ways that you can access a shell (command line) remotely on most Linux/Unix systems. One of the older ways is to use the telnet program, which is available on most network capable operating systems. Accessing a shell account through the telnet method though poses a danger in that everything that you send or receive over that telnet session is visible in plain text on your local network, and the local network of the machine you are connecting to. So anyone who can “sniff” the connection in-between can see your username, password, email that you read, and commands that you run. For these reasons you need a more sophisticated program than telnet to connect to a remote host.

SSH, which is an acronym for Secure SHell, was designed and created to provide the best security when accessing another computer remotely. Not only does it encrypt the session, it also provides better authentication facilities, as well as features like secure file transfer, X session forwarding, port forwarding and more so that you can increase the security of other protocols. It can use different forms of encryption ranging anywhere from 512 bit on up to as high as 32768 bits and includes ciphers like AES (Advanced Encryption Scheme), Triple DES, Blowfish, CAST128 or Arcfour. Of course, the higher the bits, the longer it will take to generate and use keys as well as the longer it will take to pass data over the connection.

Slide1                                      Slide1

These two diagrams on the left show how a telnet session can be viewed by anyone on the network by using a sniffing program like Ethereal (now called Wireshark) or tcpdump. It is really rather trivial to do this and so anyone on the network can steal your passwords and other information. The first diagram shows user jegadezz logging in to a remote server through a telnet connection. He types his username jegadezz, which are viewable by anyone who is using the same networks that he is using.

The second diagram shows how the data in an encrypted connection like SSH is encrypted on the network and so cannot be read by anyone who doesn’t have the session-negotiated keys, which is just a fancy way of saying the data is scrambled. The server still can read the information, but only after negotiating the encrypted session with the client. 

Client-Side Installation 

To install SSH client on Ubuntu by by executing the following command: 

sudo apt-get install openssh-client

Getting SSH installed is really easy, and only takes a few other bits of information to get going. On the computer which you’d like to use to connect to other computers, you’ll need to install the OpenSSH client if it isn’t already. On Ubuntu systems this can be done with sudo apt-get install openssh-client. Once that installation completes, you’re already good to go with one computer. 

To install SSH server on Ubuntu by by executing the following command: 

sudo apt-get install openssh-server

On every computer that you want to connect to, you’ll need to install the server-side part of the software if it isn’t already. You can do so on Ubuntu systems with the command sudo apt-get install openssh-server. Once this is installed, all of the needed software is installed. 

Follow Innovation Begins Here on Twitter,Facebook , Google+ &Linkdin.

Ncurses – Software emulator

Lnux on the desktop is making great progress. However, the real beauty of Linux and Unix like operating system lies beneath the surface at the command prompt. ncurses picks his best open source terminal application.

ncurses (new curses) is a programming library that provides an API which allows the programmer to write text-based user interfaces in a terminal-independent manner. It is a tool kit for developing “GUI-like” application software that runs under a terminal emulator. It also optimizes screen changes, in order to reduce the latency experienced when using remote shells.

ncurse_example_1

Great tools for terminal based on ncurses:

CMUS:

cmus is a music player that I admire the most when it comes to command-line because it’s really powerful and has a lot of nice features. It is built with ncurses and therefore providing a text-user interface. cmus is indeed feature-rich, with several view modes and Last.fm song submission support via scripts.

Cmus_1

Finch:

Finch comes bundled with Pidgin, the popular IM client. Finch offers the same functionality that Pidgin offers, only that it does it in a terminal by using the ncurses library. It supports IM protocols like Yahoo, Google Talk, XMPP (Facebook), WLM (Windows Live Messenger) .

@%Finch

htop

htop is an interactive process viewer tool using ncurses which has the great benefit that it allows to scroll up and down the list of processes, and it also uses graphs and colors.

htop

There are plenty of tools available based on ncurses like moc,aview,convert,lynx.

Follow Innovation Begins Here on Twitter,Facebook , Google+ & Linkdin.

Computer Boot Up Sequence

A computer without a program running is just an inert hunk of electronics. The first thing a computer has to do when it is turned on is start up a special program called an operating system. The operating system’s job is to help other computer programs to work by handling the messy details of controlling the computer’s hardware. For starting the OS computer follow some set of sequence is called Boot UP Sequence.

BIOS:

Basic Input/Output System, the BIOS, ROM BIOS, or System BIOS is a chip located on all motherboards that contain instructions and setup for how your system should boot and how it operates. The BIOS includes instructions on how to load basic computer hardware and includes a test referred to as a POST (Power On Self Test) that helps verify the computer meets requirements to boot up properly. If the computer does not pass the POST, you will receive a combination of beeps indicating what is malfunctioning within the computer.

The four main functions of a PC BIOS :

POST:

Short for power-on self-test, the POST is a test the computer must complete to verify all hardware is working properly before starting the remainder of the boot process. If the computer passes the POST the computer may return a single beep and if unsuccessful generate a beep code to indicate the error and not boot.

BootStrap:

Bootstrapping, bootloader, or boot program, a bootstrap loader is a program that resides in the computers EPROM, ROM, or other non-volatile memory that automatically executed by the processor when turning on the computer. The bootstrap loader reads the hard drives boot sector to continue the process of loading the computers operating system. The term boostrap comes from the old phrase “Pull yourself up by your bootstraps”.

The boot loader has been replaced in computers that have an Extensible Firmware Interface (EFI). The boot loader is now part of the EFI BIOS.

BIOS drivers:

Low level drivers that give the computer basic operational control over your computer’s hardware.

BIOS or CMOS Setup:

Configuration program that allows you to configure hardware settings including system settings such as computer passwords, time, and date.

Different between Bios and CMOS:

The BIOS is a computer chip on the motherboard that resembles the picture to the right. This chip contains a special program that helps the computer processor interact and control the other components in the computer. These other components include disc drives, video cards, sound cards, network cards, floppy drives, USB ports, hard drives, and others. Without the BIOS, the processor would not know how to interact or interface with the computer components, and the computer would not be able to function.

The CMOS is also a computer chip on the motherboard, but more specifically, it is a RAM chip. This is a type of memory chip which stores information about the computer components, as well as settings for those components. However, normal RAM chips lose the information stored in them when power is no longer supplied to them. In order to retain the information in the CMOS chip, a CMOS battery on the motherboard supplies constant power to that CMOS chip. If the battery is removed from the motherboard or runs out of juice (e.g. a dead CMOS battery), the CMOS would lose the information stored in it. Any settings you made in the CMOS setup would be lost, and you would need to make those settings changes again after a new CMOS battery was put on the motherboard. For example, with a dead CMOS battery the time and date will reset back to the manufactured date if it has been off for a long period of time.

The BIOS program on the BIOS chip reads information from the CMOS chip when the computer is starting up, during the boot up process. You may notice on the initial start up screen, called the POST screen, an option is available to enter the BIOS or CMOS setup. When you enter this setup area, you are entering the CMOS setup, not the BIOS setup. The BIOS chip and program cannot be updated directly by a user. The only way to update the BIOS is using a BIOS flash program called a BIOS update, which updates the BIOS to a different version. These updates usually are provided by either the motherboard manufacturer or the computer manufacturer.

The CMOS setup lets you change the time and date and settings for how devices are loaded at start up, like hard drives, disc drives, and floppy drives. The CMOS setup lets you enable and disable various hardware devices, including USB ports, the onboard video card and sound card (if present), parallel and serial ports, and other devices.

MBR:

Master Boot Record, MBR is also sometimes referred to as the master boot block, master partition boot sector, and sector 0. The MBR is the first sector of the computer hard drive that tells the computer how to load the operating system, how the hard drive is partitioned.It contains information about GRUB.

GRUB:

GRUB stands for Grand Unified Boot loader. If you have multiple kernel images installed on your system, you can choose which one to be executed. In simple terms GRUB just loads and executes Kernel 4.Mounts the root file system as specified in the “root=” in grub.conf.

Grup config file:

The configuration file (/boot/grub/grub.conf), which is used to create the list of operating systems to boot in GRUB’s menu interface, essentially allows the user to select a pre-set group of commands to execute

GRUP CONFIG FILE STRUCTURE:

default=0

timeout=10

splashimage=(hd0,0)/grub/splash.xpm.gz

# section to load Linux

title Red Hat Enterprise Linux (2.4.21-1.ent)

root (hd0,0)

kernel /vmlinuz-2.4.21-1 ro root=/dev/sda2

initrd /initrd-2.4.21-1.img

# section to load Windows

title Windows

rootnoverify (hd0,0)

chainloader +1

Kernel executes the /sbin/init program

INIT – RunLevels:

Looks at the /etc/init tab file to decide the Linux run level.Following are the available run levels:

0 – halt   (Shuts down the system)

1 – Single user mode (Mode for administrative tasks)

2 – Multiuser (Does not configure network interfaces and does not export networks services)

3 – Multiuser mode with N/W (Starts the system normally)

4 – unused (For special purposes)

5 – X11 (As runlevel 3 + display manager (starts Login Screen))

6 – reboot (Reboots the system.)

INIT – RunLevels

In standard practice, when a computer enters runlevel zero, it halts, and when it enters runlevel six, it reboots.The intermediate runlevels (1-5) differ in terms of which drives are mounted, and which network services are started.

Lower run levels are useful for maintenance or emergency repairs, since they usually don’t offer any network services at all. The particular details of run level configuration differ widely among operating systems, and also among system administrators.

PDF Download Link Here:Boot Up sequence

Follow Innovation Begins Here on Twitter, innovationBeginsHere, Facebook , Google+ & Linkdin.

Copyright © 2015[InnovationBeginsHere].All Rights Reserved.

The Linux/Unix File system hierarchy standard

The file system hierarchy standard defines the directory 
structure of Unix and Unix based operating systems.
Linux-Directory-Structure
/ - Root Directory
The root directory is the top-level directory in the FHS,
All other directories are sub-directories of root.
Every single file and directory starts from the root directory.
Only root user has write privilege under this directory.
/bin – User Binaries
Contain binary executables.
Common Linux/Unix commands you need to use in single-user modes 
are located under this directory.
Commands used by all the users of the system are located here.
Example:
 Cat, ls, rpm, cp
Note:
A binary file is a computer file that is not a text file,it 
may contain any type of data,encoded in binary form for 
computer storage and processing purposes.
/boot - Boot Loader Files
Contains boot loader related files.
Kernel initrd, vmlinux, grub files are located under /boot.
Example:
 initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic.
Note:
A boot loader is a program written to load a more complex kernel. 
The boot loader ultimately has to Bring the kernel (and all the
kernel needs to bootstrap) into memory,provide the kernel with 
the information it needs to work correctly, Switch to an 
environment that the kernel will like, Transfer control to the kernel.
/etc - Configuration Files
Contain configuration files required by all programs.
This also contains startup and shutdown shell scripts used
to start/stop individual programs.
Example:
 /etc/resolv.conf, /etc/logrotate.conf.
Note:
configuration files, or config files configure the initial 
settings for some computer programs. They are used for user
applications, server processes and operating system settings.
The files are often written in ASCII (rarely UTF-8) and 
line-oriented, with lines terminated a newline or carriage 
return/line feed pair, depending on the operating system. 
They may be considered a simple database.
/dev – contain device file
Contain device files.
These include terminal devices, usb, or any device attached
to the system.
Example:
 /dev/tty1, /dev/usbmon0.
/home - Home Directories
Home directories for all users to store their personal
files.
Example:
 /home/user, /home/user1.
/lib - System Libraries
Contains library files that supports the binaries located 
under /bin and /sbinLibrary filenames are either ld* or 
lib*.so.*
Example:
 ld-2.11.1.so, libncurses.so.5.7
/sbin - System Binaries
Just like /bin, /sbin also contain binary executables. But, 
the linux commands located under this directory areused 
typically by system aministrator, for system maintenance purpose.
 Example:
 iptables, reboot, fdisk, ifconfig, swapon.
/Root - home directory of the root user
Contains root user files and personal settings.
/opt - Optional add-on Applications
opt stands for optional.
Contain add-on applications from individual vendors.
add-on applications should be installed under either /opt/
or /opt/ sub-directory.
Note:
Add- on Applications:
Application software is a set of one or more programs designed 
to carry out operations for a specific application. 
Application software cannot run on itself but is dependent 
on system software to execute. Examples of application software
include MS Word, MS Excel, a console game, a library management 
system, a spreadsheet system etc.
/proc - Process Information
Contain information about system process.
This is a pseudo file system contains information about
running process. For example: /proc/{pid} directory contains 
information about the process switch that particular pid.
This is a virtual file system with text information about 
system resources. For example: /proc/uptime
/mnt - Mount Directory
Temporary mount directory where system admin can mount file
systems.
/tmp – Temporary Files
Directory that contains temporary files created by system and users.
Files under this directory are deleted when system is rebooted.
/usr – User Programs
Contains binaries, libraries, documentation, and source code for 
second level programs./usr/bin contains binary files for user 
programs. If you can’t find a user binary under /bin, look 
under /usr/bin. 
Example:
 at, awk, cc, less, scp
 ->/usr/sbin contains binary files for system
 administrators. If you can’t find a system binary under
 /sbin, look under /usr/sbin.
Example:
 atd, cron, sshd, useradd, userdel
 ->/usr/lib contains libraries for /usr/bin and /usr/sbin.
 /usr/local contains users programs that you install from
source. For example, when you install apache from source, 
it goes under /usr/local/apache
/var – Variable Files
var stands for variable files.
Variable data, including log files and printer spools.
Content of the files that are expected to grow can be found
under this directory.
This includes — system log files (/var/log); packages and 
database files (/var/lib); emails (/var/mail); 
print queues (/var/spool); lock files (/var/lock); 
temp files needed across reboots (/var/tmp).

/srv – Service Data
srv stands for service.
Contains server specific services related data.
For example, /srv/cvs contains CVS related data.

PDF Download Link Here: The Linux Filesystem Hierarchy Standard

Follow Innovation Begins Here on Twitter, innovationBeginsHere, Facebook , Google+ & Linkdin.

          Copyright © 2015[InnovationBeginsHere].All Rights Reserved.