Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Thursday, 30 November 2017

How to check system information on CentOS Linux from CLI

To check the system information of CentOS Linux from command line interface, the following commands will come in handy.

cat /proc/cpuinfo

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 45
model name      : Intel(R) Xeon(R) CPU E5-4620 0 @ 2.20GHz
stepping        : 2
microcode       : 0x710
cpu MHz         : 2200.000
cache size      : 16384 KB
physical id     : 2
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 2
initial apicid  : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx hypervisor lahf_lm ida arat pln pts dtherm
bogomips        : 4400.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

To check the memory details use the following :

vmstat -s

 3883788 K total memory
      3758516 K used memory
      2232252 K active memory
      1263620 K inactive memory
       125272 K free memory
            0 K buffer memory
       259872 K swap cache
      8191996 K total swap
      3114568 K used swap
      5077428 K free swap
    411521845 non-nice user cpu ticks
        23449 nice user cpu ticks
    116773236 system cpu ticks
   5900085167 idle cpu ticks
      1174004 IO-wait cpu ticks
         1058 IRQ cpu ticks
      7376135 softirq cpu ticks
            0 stolen cpu ticks
    234643114 pages paged in
    380977726 pages paged out
      3875967 pages swapped in
      4295358 pages swapped out
    948364036 interrupts
   1524453860 CPU context switches
   1479654445 boot time
    130969946 forks

You could also use an alternative command :

cat /proc/meminfo

MemTotal:        3883788 kB
MemFree:          119860 kB
MemAvailable:      89684 kB
Buffers:               0 kB
Cached:            64528 kB
SwapCached:       455596 kB
Active:          2526176 kB
Inactive:         993336 kB
Active(anon):    2503132 kB
Inactive(anon):   954552 kB
Active(file):      23044 kB
Inactive(file):    38784 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       8191996 kB
SwapFree:        4795948 kB
Dirty:                96 kB
Writeback:             0 kB

Listing repositories in CentOS Linux

In CentOS and Red Hat flavors of Linux, if we want to list all the configured repositories, we need to use the following command.

yum repolist

This will list information with columns like repo id, repo name, status.

Use the verbose mode with the -v switch for more detailed information.

yum -v repolist

For listing only enabled and/or disabled repositories, use the following syntax

yum repolist enabled

OR

yum repolist disabled

For listing all of the repositories (i.e enabled and disabled), use :

yum repolist all

Now, from the list of of all configured repositories, if we want to disable/enable a specific repository, use the following :

yum-config-manager --disable test-repo-name.repo

OR

yum-config-manager --enable test-repo-name.repo

Hope it helps guys. Ciao!

Wednesday, 18 October 2017

How to open specific port in firewall in CentOS Linux

Guys, if your organization is behind a firewall, the networking team usually takes care that most unused ports are blocked, unless absolutely necessary. In some cases, you may want to add an exception to the firewall rules though, to open up a specific port to allow incoming and outgoing network traffic.

In today's example, we may want to open up a port 8080 to allow TCP connections for instance. Note that these commands are specifically for the CentOS flavor of Linux. Other flavors of Linux may have different command syntax. Please check accordingly.

Firstly view the existing firewall rules using the following command

firewall-cmd --list-all

Output (Old rules):

public (default, active)
  interfaces: en0
  sources:
  services: dhcpv6-client ssh
  ports: 9005/tcp
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

As you see from the existing rules, it seems that port 9005 is open. Now let us add the port 8080 to the firewall rules using the below command. If the command is executed fine, it will display "success". Make sure to reload firewall configuration to bring the new rules into effect.

firewall-cmd --zone=public --add-port=8080/tcp --permanent
success

firewall-cmd --reload
success

In order to view the double check the firewall rules, again use the --list-all command.

firewall-cmd --list-all

Output ( Updated rules):

public (default, active)
  interfaces: en0
  sources:
  services: dhcpv6-client ssh
  ports: 8080/tcp 9005/tcp
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

As you see the port 8080 has been added to the list i.e it has been opened up.
Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker