Linux.com

Community Blogs



Linux: chroot Command Examples To Fix System

I am a new Linux and Unix user. How do I change the root directory of a command? How do I change the root directory of a process such as web-server using a chroot command to isolate file system? How do I use a chroot command to reset a forgotten Linux password, reinstall the bootloader, jail apps and more? 

Read more: Linux and Unix chroot command examples

 

Minify and Compress CSS & Javascript Files At a Linux Shell Prompt

How do I minify and compress CSS & JS files on Linux or Unix-like system using shell prompt on my server? How can I minify JavaScripts and stylesheets at shell prompt so they can download faster over the Internet without using any online tools?

Read more: Minify and Compress CSS & Javascript Files At a Linux Shell Prompt

 

Build Faster WordPress Sites with Nginx – In 3 Lines!

There are a number of competing web servers but nginx is probably your best bet, conceived relatively recently in 2002 by Igor Sysoev, nginx was built from the ground up with the explicit goal of handling a large number of concurrent connections. In simple terms, whereas Apache creates a new process for each new connection (visitor/http request) nginx offloads requests to worker processes and allows for asynchronous resource allocation. What this means in practice is a much faster, more efficient server environment and in turn a faster website.

Sounds great, right. But how would you go about setting  this up? Luckily, the nginx & WordPress experts over at rtcamp have build an awesome script (easyengine) for taking a stock Ubuntu VPS image, installing the required server components and a fresh WordPress install with pre-configured support for caching, in basically 3 system commands!


Read more: https://gplclub.org/build-faster-wordpress-sites-nginx-3-lines/

 

Static Vs Dynamic IP Address

An Internet Protocol (IP) address is a numerical identifier that is assigned to every device or machine in a computer network. If you are planning to start your own Internet business, using a virtual private network VPN or VOIP, you need to be adequately informed about IP addressing. We all (should) know – there are static and dynamic IP addresses. But when should you use them?

What is a Dynamic IP Address?

A dynamic IP address changes each time you boot your machine or network device. It also changes when you dial into your Internet service provider. Some ISPs change your IP each time you log on to their network while some make the changes periodically.

Most dynamic IP addresses are assigned using the Dynamic Host Configuration Protocol (DHCP). The router on your home network assigns IP addresses to your computers and other network devices as you put them on. Private IP addresses usually have this format: 192.168.0.x. Your router's IP address will usually be 192.168.0.1 while your computers will be assigned numbers ranging from 192.168.0.2 to 192.168.0.254.

In situations where you need to remotely administer a particular computer on a network, you may need to reserve a particular address for it. To assign static IPs to certain computers and dynamic IPs to others on the same network, you should reserve the IPs for the specific machines on the DHCP server. This will help you to administer the network centrally without the need to assign static IPs manually. It will also prevent the occurrence of IP conflicts.

When Should You Use Dynamic Ips?

Dynamic IPs will be good for anyone who uses their computer or home network for the following:

* To browse the Internet and upload or download files
* To send and receive email through a mail server or via a web based email service like yahoo mail, hotmail or gmail.
* To use online chat services or instant messaging
* To use FTP servers or web servers that only require access from your LAN or corporate network but do not require access from the Internet.




What is a Static IP Address?

A static IP address is a fixed IP address that is manually assigned to a device on a network. It is called a static IP because it is not changed each time the device is switched on. Static addresses remain the same each time you connect to the network or send a message.

When Should You Use a Static IP?

Static IP addresses provide greater reliability for applications such as voice over Internet protocol (VOIP). If you run a service that permits incoming audio or video, you may need to use a static IP. For example if you have an on-site IP-PBX, you will need to have at least one static IP address.

A static IP will also be required if you have a machine that functions as a server and requires external access from the users online. This includes running a web server, e-mail server, FTP server, or DNS server. A static IP allows you to enjoy faster upload speeds which boost the efficiency of these services.

If you intend to host a gaming website or you want to use Play Station, X-Box or a VPN to provide secure access to files from your corporate network server, you should also consider buying a public static IP address.


How to Set Up a Static IP in Linux?

Here are the steps you should take to assign a static IP address on a Linux system.

1. Make sure you are logged on as root
2. Create a backup copy of the /etc/network/interfaces file on your machine. You can easily restore the backup if something goes wrong.
3. Edit the /etc/network/interfaces file. From the text console, you can load this file into the famous vi editor.
4. Scroll down the file until you locate the network interface card. An Ethernet connection is usually identified by eth0 or wlan0 while a wifi connection is identified as wifi0.
5. Replace “ iface eth0 inet dhcp “ with “ iface eth0 inet static “.
6. Add these lines: (you can replace the address and dns nameserver with your own configuration)

address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.0
dns-name-servers 216.10.119.241


If you are running Slackware or Red Hat Linux, one of the simplest methods is to log on as root and then type ifconfig/netstat at the console. You can then use the text-based menu to modify the configuration settings.

In Slackware the settings will take effect instantly. But in Red Hat you need to type “ service network restart “ and press enter.

 

 

How To Install Tomcat 7 Server on CentOS/RHEL 5/6

Apache Tomcat is an opensource webserver product of Apache Foundation like Apache HTTP server. It is used to deploying Java Servlet and JSP applications. To deploy any application in Tomcat we can simply create a war fileand deploy them. For more details about you can visit apache official site.

 

Continue to following article to Install Apache Tomcat 7 on CentOS/RHEL Servers.  

 

Linux: Log Suspicious Martian Packets / Un-routable Source Addresses

A Martian packet is nothing but an IP packet which specifies a source or destination address that is reserved for special-use by Internet Assigned Numbers Authority (IANA). You can log packets with un-routable source addresses on Linux operating system. This tutorial explains how to log spoofed packets on Debian / Ubuntu / CentOS / RHEL / Linux based server.

Linux: Log Suspicious Martian Packets / Un-routable Source Addresses

 

Linux ip Command Examples

I am a new Linux system admin user. How do I use ip command line utility to display or configure networking, routing, and tunnels on Linux operating systems? How do I configures or displays network interface parameters for a network using TCP/IP on Linux operating systems? The ip command is used to assign an address to a network interface and/or configure network interface parameters on Linux operating systems. This command replaces old good and now deprecated ifconfig command on modern Linux distributions.

Linux ip Command Examples

 

CentOS / RHEL: Yum Lock Package Version At a Particular Version

yum-plugin-versionlock plugin takes a set of name/versions for packages and excludes all other versions of those packages (including optionally following obsoletes). This allows you to protect packages from being updated by newer versions, for example. This quick tutorial explains how to install and use yum versionlock to prevent package update using yum on a CentOS or RHEL based server.

Read more: CentOS / RHEL: Yum Lock Package Version At a Particular Version

 

Configuring Apache2 to run Python Scripts

This is meant as a simple writeup to fill a gap in various "HOWTO"'s that I read when trying to setup my Apache2 server to process python scripts as CGI, though it would apply to any cgi scripts (perl scripts, compiled binaries...).
I've been developing for years (C, C++, PHP), but had never delved into python before, and I wanted to be able to have my scripts have a web interface.

The first step is getting Apache2 to recognize that my .py files were to be executed and not spit out as text files.
docs.python.org has some nice HOWTOs (http://docs.python.org/3.3/howto/webservers.html) on how to think about python and the web, and apache.org has mountains of documentation (http://httpd.apache.org/docs/2.2/howto/cgi.html) relating to running CGIs. What I didn't find was a simple guide on how to set it up. I'm a developer, not a sys-admin, and while I like knowing how to configure Apache and tune my linux boxes, sometimes I just want to get my webserver up and running and start coding.

So, in case anyone was going through the same situation as me, here is my quick and dirty setup.

For reference, this setup was done on Ubuntu 13.10, using ubuntu's default apache2 installation, and python3.
I'm also assuming you know how to configure apache for a basic html site. There are lots of HOWTO's for that.

Starting the basics:

  • apache install: sudo apt-get install apache2
  • python install: sudo apt-get install python

or

  • python3 install: sudo apt-get install python3

The first step, which in my PHP experience I never had to do, is not mentionned in the guides above is to enable CGI processing in apache.

sudo a2enmod cgi

This will automatically enable mod_cgid if your server is configured with a multi-threaded MPM, which was the case for me.

Then you can either make a folder in your site's path where your cgi files will live, or configure certain directories to handle certain file types as cgi scripts.
This is described well in the apache2 doc above, but essentially you to make all files in a cgi folder be executed, you would use this conf:

<Directory /srv/www/yoursite/public_html/cgi-bin>
        Options ExecCGI
        SetHandler cgi-script
    </Directory>

and to allow .py files to be executed as scripts in a particular folder you would use this conf:

    <Directory /srv/www/yoursite/public_html>
        Options +ExecCGI
        AddHandler cgi-script .py
    </Directory>

Once you have that, if you're running python 3, you can make a python script like this one, and stick it in whichever folder is configured for cgi:

    #!/usr/bin/env python
    # -*- coding: UTF-8 -*-# enable debugging
    import cgitb
    cgitb.enable()
    print("Content-Type: text/html;charset=utf-8")
    print()
    print("Hello World!")

You can change the first line from

#!/usr/bin/env python

to

#!/path/to/your/python/binary

such as

#!/usr/bin/python3

in case the default is python and you want this script to be parsed by python3

 

Several Monitoring Metrics for Virtualized Infrastructure

To build a virtualized cloud infrastructure, four major elements play the vital role in the way to design a virtual infrastructure from its physical counterpart. These four elements are at the level of processors, memory, storage and network. In the continuity of the design, there is the life of the infrastructure, that is to say the daily operations. Is it administering the daily virtual infrastructure as they do in a physical environment? Pooling many resources involves consideration of other parameters that we will see here.

Processors performance monitoring

Although the concept of virtual (vCPU) for a hypervisor (VMware or Microsoft Hyper-V) is close to the notion of the physical heart, a virtual processor is much less powerful than a physical processor. Noticeable CPU load on a virtual server can be absolutely more important than the physical environment. But nothing to worry about if the server has been sized to manage peak loads. In contrast, maintenance of indict alert threshold often makes more sense and it is wise to adjust.

By the way, all hypervisors are not necessarily within a server farm. The differences may be at the level of processors (generation, frequency, cache) or other technical characteristics. This is something to consider as a virtual server that can be migrated to warm hypervisor to another (vMotion in VMware, Microsoft Live Motion). After a trip to warm virtual server, the utilization of the processor can then vary.

Does the alert threshold define by taking into account the context changes?

The role of the scheduler in access to physical processors is per virtual servers. You may not be able to access it immediately, because there would be more virtual servers, more access and waiting time (latency) which is important to consider. In addition, performance monitoring is not limited solely to identify how power is used, but also to be able to detect where it is available. In extreme cases it is possible to visualize a virtual server with low CPU load. This indicator of processor latency for each virtual server is an indicative of a good use of the available power. Do not believe that the power increases by adding virtual processors to the server, it is actually more complex and it is often the opposite effect of what is required to happen. Usually, you need to send this problem by analyzing the total number of virtual processors on each hypervisor.

Monitoring the memory utilization

If the memory is shared between the virtual servers running within the same hypervisor, it is important to distinguish used and unused memory. The used memory is usually statically allocated to virtual server while the unused memory is pooled. Due to this reason it is possible to run virtual servers with a total memory which also exceeds the memory capacity of hypervisor. The memory over-provisioning of virtual servers on hypervisor is not trivial. It is a kind of risk taking, betting that all servers will not use their memory at the same time. There is no concern of the type “it is” or “this is wrong”, much depends on the design of virtual servers. However, monitoring will prevent it from becoming a source of performance degradation.

A first important result is that over provisioning prevents starting of all virtual servers simultaneously. Indeed, a hypervisor verifies that it can affect the entire memory of a virtual server before starting it. It is possible to start with a timer so that everyone releases its unused memory in a specific order.

The slower memory access is second consequence. VMware has implemented a method of garbage collection (called as a ballooning) with virtual servers. It occurs when the hypervisor is set to provide memory to a virtual server when available capacity is insufficient. The hypervisor strength release memory with virtual servers. This freed memory is then distributed to servers as needed. This mechanism is not immediate; there is some latency between the request for memory allocation and its effectiveness. This is the reason it slows down memory access. This undermines the good performance of the servers.

Another consequence of the ballooning, it can also completely change the behavior of the server’s memory. Linux systems are known to use available memory and keep it cached when it is released by the process (memory that does not appear to be free). The occupancy rate of memory of such a server is relatively stable and high. This rate will decrease with ballooning and will not be stable (frequent releases and increases).

Also there are cases where used memory can be pooled between virtual servers. This appears when the ballooning is not enough. Performance is greatly degraded when it is a situation to be avoided.

 

Installing Red5 Media Server on CentOS and RHEL

Red5 Media Server is a powerful media streaming server worked on RTMP protocal. Red5 is an open and extensible platform, which can be used in Video Conferencing or Network gaming.

Read this article to How to install Red5 media server on CentOS and RHEL Systems

 
Page 3 of 9

Upcoming Linux Foundation Courses

  1. LFD320 Linux Kernel Internals and Debugging
    03 Nov » 07 Nov - Virtual
    Details
  2. LFS416 Linux Security
    03 Nov » 06 Nov - Virtual
    Details
  3. LFS426 Linux Performance Tuning
    10 Nov » 13 Nov - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board