Author: Andrew Mora

How to: Basic Bash Administration Tools On Linux (df, fdisk, top, free, iostat, ifconfig, sensors, stat, nmap, and netstat)

Andrew Mora June 29, 2015 by under Cloud Hosting 0 Comments
Verified and Tested 02/26/15

Introduction

This tutorial is a brief rundown of the BASH shell commands and tools that come in handy for the Linux administrator. Focus more on tools for administration, as opposed to the basic usage of Linux based Operating Systems. While this article is being written in the context of distros based on RHEL 4+ and Debian 6+, many of these commands may also be found on BSD, FreeBSD, any other Unix systems. Depending on your Operating system, each command’s flags may differ, or may no exist for the respective Operating System.

Prerequisites

RHEL 4+ and Debian 6+ based Operating Systems, including CentOS and Ubuntu. If you do not have a server, you can start up a reliable Linux server from Atlantic.Net in under 30 seconds.

Basic Bash Administration Tools

I will be providing a Need, coupled with the BASH command that can satisfy this need. Keep in mind that each command may have several many more functions and command line options available than the examples I’ll be showing below. I’ll be sticking to the basic commands that attain the bare minimum output you desire. I encourage all of you read the Manual page for each command.

I need to:

Find out how much hard drive space I have left| Command: df

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        79G  2.2G   73G   3% /
tmpfs           939M     0  939M   0% /dev/shm

List my available hard drives| Command: fdisk

# fdisk -l

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00015f65

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       10444    83884032+  83  Linux

View my systems resources(running tasks, CPU utilization)| Command: top

# top
top - 10:44:56 up 101 days, 25 min,  1 user,  load average: 0.00, 0.01, 0.00
Tasks:  99 total,   1 running,  98 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.0%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1922380k total,  1627448k used,   294932k free,   164252k buffers
Swap:        0k total,        0k used,        0k free,  1267812k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 8655 root      20   0 15032 1068  808 R  2.0  0.1   0:00.01 top
    1 root      20   0 19232 1420 1140 S  0.0  0.1   0:35.85 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:02.20 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:02.05 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:20.04 watchdog/0

View my systems memory utilization| Command: free

# free -m
             total       used       free     shared    buffers     cached
Mem:          1877       1589        288          0        160       1238
-/+ buffers/cache:        190       1686
Swap:            0          0          0

View my systems disk activity| Command: iostat

# iostat 2
Linux 2.6.32-431.el6.x86_64 (nginxs)    05/11/2015      _x86_64_        (2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.11    0.00    0.05    0.02    0.00   99.83

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               0.54         0.10        35.16     863199  306833368

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.00    0.00    0.25    0.25    0.00   98.50

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               5.00         0.00        88.00          0        176

View my network interfaces and IP’s| Command: ifconfig

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:00:D1:D0:61:AF
          inet addr:209.208.xx.xxx  Bcast:209.208.xx.xxx  Mask:255.255.255.0        
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6414823 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6864133 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1325544537 (1.2 GiB)  TX bytes:1155254908 (1.0 GiB)

eth1      Link encap:Ethernet  HWaddr 00:00:0A:D0:61:AF
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:296071 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:13464542 (12.8 MiB)  TX bytes:398 (398.0 b)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:9813 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9813 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:775658 (757.4 KiB)  TX bytes:775658 (757.4 KiB)

View my hardware’s temperature readings| Command: sensors

# sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +39.0°C  (high = +76.0°C, crit = +100.0°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +39.0°C  (high = +76.0°C, crit = +100.0°C)

it8718-isa-0290
Adapter: ISA adapter
in0:         +1.07 V  (min =  +0.00 V, max =  +4.08 V)
in1:         +1.92 V  (min =  +0.00 V, max =  +4.08 V)
in2:         +3.31 V  (min =  +0.00 V, max =  +4.08 V)
in3:         +2.91 V  (min =  +0.00 V, max =  +4.08 V)
in4:         +0.34 V  (min =  +0.00 V, max =  +2.10 V)
in5:         +4.08 V  (min =  +0.00 V, max =  +4.08 V)   ALARM
in6:         +4.08 V  (min =  +0.00 V, max =  +4.08 V)   ALARM
in7:         +3.15 V  (min =  +0.00 V, max =  +4.08 V)
Vbat:        +3.25 V
fan1:       1231 RPM  (min =    0 RPM)
fan2:       1268 RPM  (min =    0 RPM)
temp1:       -55.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermistor
temp2:        -2.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermistor
temp3:       +20.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermal diode

Get permission level of a file/directory| Command: stat

# stat -c '%a' /home/testfile.txt
644

Find what ports are open on a remote/local host| Command: nmap

NOTE: You’ll likely have to install the nmap package from your YUM/APT package manager.

# nmap -p- localhost

Starting Nmap 5.51 ( http://nmap.org ) at 2015-05-11 11:07 EDT
Failed to find device eth1 which was referenced in /proc/net/route
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000011s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 65528 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
9000/tcp open  cslistener

Nmap done: 1 IP address (1 host up) scanned in 1.52 seconds

Find out what ports my server is listening on| Command: netstat

# netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:139                 0.0.0.0:*                   LISTEN      5573/smbd
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      29209/nginx
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      3557/vsftpd
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      18608/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      9400/master
tcp        0      0 0.0.0.0:445                 0.0.0.0:*                   LISTEN      5573/smbd
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      28996/php-fpm
tcp        0      0 :::139                      :::*                        LISTEN      5573/smbd
tcp        0      0 :::22                       :::*                        LISTEN      18608/sshd
tcp        0      0 ::1:25                      :::*                        LISTEN      9400/master
tcp        0      0 :::445                      :::*                        LISTEN      5573/smbd
udp        0      0 209.208.x.x:137          0.0.0.0:*                               5592/nmbd
udp        0      0 209.208.x.x:137          0.0.0.0:*                               5592/nmbd
udp        0      0 0.0.0.0:137                 0.0.0.0:*                               5592/nmbd
udp        0      0 209.208.x.x:138          0.0.0.0:*                               5592/nmbd
udp        0      0 209.208.x.x:138          0.0.0.0:*                               5592/nmbd
udp        0      0 0.0.0.0:138                 0.0.0.0:*                               5592/nmbd
udp        0      0 0.0.0.0:1194                0.0.0.0:*                               12988/openvpn

Thank you for following along this guide on Basic Bash Administration Tools, I hope that you enjoyed this guide, please check back for more updates.


How to: Python 3 and Creating a Virtual Environment(venv) in CentOS 6.7

Andrew Mora April 24, 2015 by under Cloud Hosting 0 Comments
Verified and Tested 02/26/15

Introduction

This article covers the installation of Python 3.4 on a CentOS 6.7 operating system and how to create a Virtual Environment(venv) with pyvenv for which Python 3 can run. It is important to note the directories that we are installing is Python 3.4. CentOS 6.x is dependent on Python 2.x to function properly, do not overwrite the Python 2 installation accidentally. If you still need to install Python 2, follow our how-to on this here.

Prerequisites

You’ll need to yum install the following packets to meet all the Python 3 and PIP dependencies:

– You need a CentOS 6.7 server. If you do not have a server already, you can spin up a dependable cloud server from Atlantic.Net in under 30 seconds.

– “Development Tools” “Development Libraries”

– readline-devel

– openssl-devel

Read More


How to : CentOS 6 – Creating Larger than 2TB Partition with PARTED

Andrew Mora February 27, 2015 by under Cloud Hosting 0 Comments
Verified and Tested 02/28/15

Introduction

This article will explain how to add two 3TB hard drives to an existing CentOS 6 system using PARTED and place them into a RAID1 software raid mirror.

PARTED, like fdisk, is a utility used to manipulate hard disk partitions. One advantage it has over fdisk is that it can handle provisioning disks whose volumes will span larger than ~1.9 TB in size.

Prerequisites

Most Linux operating systems deploy with PARTED preinstalled. Should it not, use your favorite package installer(apt-get, yum) to acquire the software.

Read More


How to Install File Server Resource Manager (FSRM) on Windows 2012 R2 with Quota Enforcement

Andrew Mora February 8, 2015 by under Cloud Hosting 0 Comments
Verified and Tested 12/31/14

Introduction

Installation procedure for File Server Resource Manager (FSRM) on Windows 2012 R2 and Quota Enforcement example.

Prerequisites

A server that must have access to the internet. If you do not have a server already, you can visit our Cloud Hosting page and spin a new server up in under 30 seconds.

Installing File Server Resource Manager (FSRM) on Windows 2012 R2 with Quota Enforcement

Open Server Manager -> Manage -> Add Roles and Features

Select next at that Before you begin page

Add roles and features wizard

Read More


How to: Windows Server 2012 R2 – Install DHCP

Andrew Mora February 8, 2015 by under Cloud Hosting 0 Comments
Verified and Tested 02/31/14

Introduction

Installation procedure for installing a DHCP server onto Windows 2012R2 with Server Manager.

Prerequisites

Server must have access to the internet.

Installing DHCP on Windows Server 2012 R2

Open the Add Roles and Features wizard

Server Manager -> Manage -> Add Roles and Features

Select Add roles and features from Server Manager

Server Manager: Add roles and features

Select the “Next” button until you reach “Server Roles” then proceed to select “DHCP server”

Under Server roles select DHCP Server

Server Roles: DHCP Server

Select the Next button. A popup box will appear, proceed to select “Add Features”. Make sure the “Include management tools” check box is selected.

Make sure the “Include management tools” checkbox is selected.

Add features and select management tools

Proceed to select the “Next” button until you arrive at the “Confirmation” selection page below and select “Install”

Confirm and install

Confirm and install

Select “Complete DHCP” configuration”

Select “Complete DHCP” configuration”

Once the installation is complete, you’ll be presented with a new screen. Select “Complete DHCP” configuration”

Select “Commit” as seen below. Then select “Complete DHCP” configuration”, and select “Commit”.

 

Your DHCP server is now installed and may be configured under Server Manager -> Tools -> DHCP

anet-HowtoInstallaDHCPServerintoWindows2012R2-07


How to Install and Configure GlusterFS on CentOS 6

Andrew Mora February 4, 2015 by under VPS Hosting 0 Comments
Verified and Tested 12/31/14

Introduction

Quick installation of GlusterFS on Centos 6.x. GlusterFS clusters together storage building blocks over Infiniband RDMA or TCP/IP interconnect, aggregating disk and memory resources and managing data in a single global namespace.

Prerequisites

You’ll need a separate hard disk(s) or virtual disk(s) to use as glusterfs storage mount point(s).

Read More


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources

We use cookies for advertising, social media and analytics purposes. Read about how we use cookies in our updated Privacy Policy. If you continue to use this site, you consent to our use of cookies and our Privacy Policy.