Linux, Servers

Proxy Server Configuration on Ubuntu

squii

 

A proxy server is a computer that acts as an intermediary between a desktop computer and the internet and allows a client machine to make an indirect connection to network servers and services. There are many reasons why you might want to include a proxy server on your network:

  • To share internet connection on a LAN
  • To speed up internet surfing
  • To hide the IP address of the client computer for anonymous surfing
  • To implement internet access control
  • To scan outbound content
  • To circumvent regional restrictions

Clearly some of the above reasons are perfectly fitting for a business and some, well, may not fall in line with your best practices. Regardless, knowing how to install and configure a proxy server is a must-have skill for a network administrator. So, let’s take care of that. I will demonstrate installing the Squid proxy server on Ubuntu 16.04 server.Created with GIMP

Installation

This installation and configuration will be handled completely from the command line, so open up a terminal window and prepare to type.

The first thing we want to do (as with software installation on Ubuntu) is to update apt. From your terminal window, issue the command sudo apt-get update. Once that completes, you could also run an upgrade with the command sudo apt-get upgrade. Of course, should this upgrade the kernel, you’ll want to do a reboot, so schedule this accordingly.

Once the update/upgrade is complete, install Squid with the command:

sudo apt-get install squid3

The installation will pick up the necessary dependencies (libecap3, libltdl7, squid-purge, and squid-langpack) and complete without issue.

That is all there is to the installation. Now we move on to the configuration of a basic proxy server.

Configuration

The configuration of the Squid Proxy Server is handled in the /etc/squid/squid.conf. I will show you how to configure a very basic proxy server. The first thing we need to do is uncomment the line (by removing the # character):

#http_access allow localnet

To find that line, issue the command:

sudo grep -n http_access /etc/squid/squid.conf

As you can see (Figure A), the configuration option is found on line 1186 (of my installation). Open up the squid.conf file for editing, with the command sudo nano /etc/squid/squid.conf, and scroll down to that line and remove the # character.

Created with GIMP

Next you want to look for the line:

#acl localnet src

There will be a number of them (for different network IP schemes). You will want to uncomment the one that matches your network (say 192.168.0.0/16) and alter it to your needs. Say you run your internal network on the 192.168.1.0/255.255.255.0 network. Your localnet configuration option would look like:

acl localnet src 192.168.1.0/255.255.255.0

Restart squid with the command:

sudo service squid restart

That’s it. You now have a basic proxy server up and running on port 3128 and the IP address of the system you just installed Squid on. So you would then go to your client machines and configure them (either on a per-application or OS basis) to use that newly configured proxy via IP and port.

Make it work for you

Of course, Squid can do quite a bit more than serve as a basic proxy server. If you need to get deep into the various configuration options for Squid, make sure to take a look at the official documentation, where you can find out how to configure options for third-party applications, configure options for the neighbour selection algorithm, configure various network parameters, and much more. In the meantime, you can always take a look at the /var/log/squid/access.log and /var/log/squid/cache.log to see what Squid is doing on your network.

 

 

IF you are ussing CentOs will post it in my next blog

Advertisements
Linux

Basic Vi Commands

 

basics

 

vim or vi   Run vim and open the given filename.

:w Save file.:x or SHIFT ZZ  Save and exit.

:q Exit if no changes have been made.

:q! Exit and undo any changes made.

:set nu Display line numbers.

 

Movement

h            Move left one character.
j             Move down one character.
k            Move up one character.
l             Move right one character.
w           Move forward one word.
b            Move to the start of the word.
e             Move to the end of the word.
(             Move back one sentence.
)             Move forward one sentence.
{             Move back one paragraph.
}            Move forward one paragraph.
^           Move to the beginning of the line.
$            Move to the end of the line.
<n>G    Move to the nth line.
G            Move to the last line.
gg            Move to the first line.
%             Move to the matching bracket.

Deleting

x          Delete a single character.
D         Delete the rest of the line.
dd        Delete the entire current line.
ndw     Delete the next n words.
ndd      Delete the next n lines.
:x,yd    Delete from line x through to line y.

Entering Insert mode

i      At the cursor.
a     After the cursor.
I      Before the current line.
A     After the current line.
o      Insert a new line after the current line.
O      Insert a new line before the current line.
C       Ovewrite the whold current line.
ESC   Exit Insert mode.

View more at http://ryanstutorials.net/linuxtutorial/

 

 

 

Linux

Managing Files Using Command-Line Tool – Basic Linux Command

Managing Files Using Command-Line tools – Basic Linux Commands

Objective

After Completing this section, you will be able to
  • Create Files, Directory and Sub-directory.
  • Copy Files, Directory and Sub-directory.
  • Link Files, Directory and Sub-directory.
  • Move Files, Directory and Sub-directory.
  • Remove Files, Directory and Sub-directory.

Managing Files Using Command-Line Tool – Basic Linux Command

File management involve creating, deleting, copying and moving files. Additionally, directories can be created, deleted, copied, and moved to help organize file logically. When working at the command-line, file management requires awareness of the current working directory to choose either absolute or relative path syntax as most efficient for the immediate task.

Create Directory

The mkdir command creates one or more directories and sub-directories. This command will generating error if the file name already exists or when attempting to create a directory in a parent directory that doesn’t exists. The -p (parent) option creates missing parent directory for the destination.
~]$  mkdir Documents/imp
mkdir: cannot create directory ‘Documents/imp’: No such file or directory

The mkdir failed because Documents was misspelled and the directory Documents doesn’t exists. If the user had user mkdir -p, there would be no error.
~]$  mkdir -p Documents/imp
~]$ ls
Desktop  Document  Documents  Downloads  Music  Picture  Public  Templates  Videos 
 

Copy Files

The cp command copies one or more file to become new, independent files. The Syntax of Copy command allow copying an existing file to a new file in the current or another directory, or copying multiple files into another directory. In any destination, new file name must be unique. If file name is not unique, the copy command will automatically overwrite the existing file. And if you want to copy non-empty directory, with contents, you must be use -r (recursive) option with this copy command.
~]$ cd Document
Document]$ cp imp1.txt  imp3.txt
Document]$ ls
imp imp1.txt imp3.txt
Document]$ 

Move File

The mv command renames file in the same directory, or relocates files to a new directory. Files contents remain unchanged. File moved to a different file system require creating a new file by copying the source file, then deleting the source file. Although normally, transparent to the user, large files may take noticeable longer to move.
~]$ cd Documents
~]$ ls
abhi.txt 
~]$ mv Document/imp1.txt Documents
~]$ cd Documents
~]$ ls
abhi.txt  imp1.txt

Rename files and Directory

The rm command deletes file, but not directories. If you want to delete a directory with contain sub-directory or file, you must use -r (recursive) option. If you want to delete empty directory, so you can use rmdir command to do that.

~]$ rm -r  Documents/abhi.txt
Documents]$ ls
imp1.txt
Document]$ cd ..
~]$ rm -r Documents/imp1.txt
~]$
I have tried to highlight Managing Files Using Command-Line tools (Basic Linux Command). However, this is not end of it.
Linux

Linux File System Hierarchy

Linux File System Hierarchy

Objectives :

After completing this section, you should be able to understand fundamental file system layout, organization, and the location of key file types.

The Linux File System Hierarchy

All files in a Linux system are stored on file system which are organized into a single inverted tree of directories, known as a Linux File System Hierarchy . This tree is inverted because the root of the tree is said to be the top of the hierarchy, and the branches of the directories and sub-directories stretch below the root.
Linux File System Hierarchy
Linux File System Hierarchy
The directory / is the root directory at the top of the file system hierarchy. The / character is also used as a directory separator in file names. For example, if etc is a sub-directory of the / directory, we could call that directory /etc. Likewise, if the /etc directory contained a file name issue, we could refers to that file as /etc/issue.
Sub-directory of / are used for standardized purpose to organize files by type and purpose. This makes it easier to find files. For example, in the root directory, the sub-directory /boot is used for storing files needed to boot the system.
  Note
The following terms are encountered in describing Linux File System directory contents:
  – static is content that remains unchanged until explicitly edited or reconfigured.
  – dynamic or variable is content typically modified or appended by active  processes.
  – persistent is content, particularly configured settings, that remain after a reboot.
  – runtime is process or system-pacific content or attributes cleared during reboot.
The following table lists some of the most important directories on the system by name and purpose.
Important Linux File System Hierarchy
Location Purpose
/usr Installed software, shared libraries, include files, and static read-only program data. important sub-directories include:
/usr/bin : User commands.
/usr/sbin : System administration commands.
/usr/local : Locally customized software.
/etc Configuration files specific to the system.
/var Variable data specific to the system that should persist between boots. Files that dynamically change.
/run runtime data for processes started since the last boot. This includes process ID files and lock files, among other things. The contents of this directory are recreated on reboot.
/home Home directory where regular users store their personal data and configured files.
/root Home directory for the administrative superuser, root.
/tmp A world-writable space for temporary files. Files which have been accessed changed, or modified for 10 days are deleted from this directory automatically. Another temporary directory exists, /var/tmp, in which files that have accessed, changed, or modified in more than 30 days deleted automatically.
/boot Files needed in order to start the boot process.
/dev Contains special device files which are used by the system to access hardware.
Important

In RHEL 7, four older directories in / now have identical content as their counterparts located in /usr:
/bin and /usr/bin.
/sbin and /usr/sbin.
/lib and /usr/lib.
/lib64 and /usr/lib64.

In older version of RHEL, these were distinct directories containing different set of lines. In RHEL 7, the directories in / are symbolic links to the matching directories in /usr.

I have tried to highlight Linux File System Hierarchy. However, this is not end of it.

Linux

What is Linux?

  • Linux is an operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop.
  • The operating system manages the communication between your software and your hardware.

The OS is comprised of a number of pieces:

  • The Bootloader: The software that manages the boot process of your computer. For most users, this will simply be a splash screen that pops up and eventually goes away to boot into the operating system.
  • The kernel: This is the one piece of the whole that is actually called “Linux”. The kernel is the core of the system and manages the CPU, memory, and peripheral devices. The kernel is the “lowest” level of the OS.
  • Daemons: These are background services (printing, sound, scheduling, etc) that either start up during boot, or after you log into the desktop.
  • The Shell: You’ve probably heard mention of the Linux command line. This is the shell – a command process that allows you to control the computer via commands typed into a text interface. This is what, at one time, scared people away from Linux the most (assuming they had to learn a seemingly archaic command line structure to make Linux work). This is no longer the case. With modern desktop Linux, there is no need to ever touch the command line.
  • Graphical Server: This is the sub-system that displays the graphics on your monitor. It is commonly referred to as the X server or just “X”.
  • Desktop Environment: This is the piece of the puzzle that the users actually interact with. There are many desktop environments to choose from (Unity, GNOME, Cinnamon, Enlightenment, KDE, XFCE, etc). Each desktop environment includes built-in applications (such as file managers, configuration tools, web browsers, games, etc).
  • Applications: Desktop environments do not offer the full array of apps. Just like Windows and Mac, Linux offers thousands upon thousands of high-quality software titles that can be easily found and installed. Most modern Linux distributions (more on this in a moment) include App Store-like tools that centralize and simplify application installation. For example: Ubuntu Linux has the Ubuntu Software Center (Figure 1) which allows you to quickly search among the thousands of apps and install them from one centralized location.

 

For this course I will use the following course outline for my tutorials. We are going to be using the LPI-1 syllabus       ..click link to download   topic-101