Cloud Native 15 min read

Master Linux System Commands and Kubernetes Services: From Grep to Service Types

This guide walks through essential Linux command-line techniques such as grepping files, killing processes, using systemctl and iptables, troubleshooting web access issues, and provides a comprehensive overview of Kubernetes Service concepts, types, and configurations including NodePort and ExternalName.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux System Commands and Kubernetes Services: From Grep to Service Types

11. Print all lines containing string "A" in a directory

grep -rn "A" ./
# or
find ./ -name "*.*" | xargs grep "A"

12. Kill all processes whose service name starts with "a" (using xargs)

ps -ef | grep "^a" | grep -v grep | cut -c 9-15 | xargs kill -9
# or
ps x | grep a | grep -v grep | awk '{print $1}' | xargs kill -9

13. Understanding systemctl

Linux service management can be done via service or systemctl . systemd is the latest init system that speeds up boot by starting fewer processes in parallel. The command systemctl manages systemd resources (Units) and is compatible with the older service command.

14. Overview of iptables

iptables is a user‑space command‑line tool that configures the underlying netfilter firewall framework; it is not a daemon itself. It provides four tables (filter, nat, mangle, raw) and several built‑in chains (INPUT, OUTPUT, FORWARD, PREROUTING, POSTROUTING) to control packet filtering, NAT, QoS, and routing decisions.

15. Adding a file to an ISO image

Use UltraISO PE (or similar ISO editing software) to open the ISO file and add the desired file.

16. Troubleshooting a page that cannot be accessed

Scenario 1: No HTTP error code (often ERR_CONNECTION_TIMED_OUT)

Server bandwidth exhausted

Cloud instance in arrears

Service not started

Port not listening

Firewall or security‑group restrictions

Use telnet IP Port to test connectivity, then check bandwidth, service status, port listening, and firewall rules.

Scenario 2: 4XX client error

Verify configuration file syntax

Ensure web service process is running

Check that document root and permissions are correct

Confirm no illegal characters (e.g., Windows line endings) in configs

Review error logs for clues

Example: a 404 error occurs when the requested URL path does not exist in the server’s document root.

Note: The same troubleshooting applies to Apache environments.

17. What is a Kubernetes Service and how to use it

A Service is an abstraction that defines a logical set of Pods and a policy to access them, typically selected by labels. It provides load‑balancing and decouples clients from individual Pod instances.

Service IP types:

ClusterIP : internal virtual IP, default type.

NodePort : exposes the Service on each Node’s IP at a static port.

LoadBalancer : provisions an external load balancer (cloud provider specific).

ExternalName : maps the Service to a DNS CNAME without proxying.

Example Deployment YAML (excerpt):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  selector:
    matchLabels:
      app: myapp
  replicas: 3
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

Example Service YAML (ClusterIP):

apiVersion: v1
kind: Service
metadata:
  name: myservice
spec:
  selector:
    app: myapp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80

Creating the Service: kubectl create -f myservice.yaml Viewing Services: kubectl get svc NodePort example (adds nodePort field, e.g., 32560):

apiVersion: v1
kind: Service
metadata:
  name: myservice
spec:
  selector:
    app: myapp
  type: NodePort
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
    nodePort: 32560

ExternalName example (no selector, maps to external DNS name):

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: prod
spec:
  type: ExternalName
  externalName: my.database.example.com

18. Resolving port conflicts in Kubernetes

If a port conflict occurs, reset the cluster with kubeadm reset.

19. Differences between Red Hat 6.x and CentOS 7.x

Desktop environment: GNOME 2 vs GNOME 3

Filesystem: ext4 vs XFS

Kernel: 2.6.x vs 3.10.x

Firewall: iptables vs firewalld

Default DB: MySQL vs MariaDB

Service management: service vs systemctl Network interface naming: eth0 vs ens192

20. Typical code release process

Jenkins pulls code from SVN or Git, tags the revision, builds if necessary, and pushes the artifacts to a release server. From there the binaries are distributed to application servers, often via rsync for PHP projects, or through scripted deployment pipelines.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxtroubleshootingsystemctl
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.