Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
In Linux and Networking Last updated: August 28, 2023
Share on:
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

Middleware was the fourth hottest skill to get hired in 2017, and there is no reason to go down in the coming years.

If you recently started working on WebSphere or any other product suite of Middleware, then one of the very first things to get familiar is widely used Linux commands.

In this article, I will talk about some of the often-used Linux commands by WebSphere or Middleware administrator on a daily basis.

Finding SystemOut.log

If you are working on the existing environment and if an administrator has redirected SystemOut.log to some other location then it would be challenging to find it.

#find / -name SystemOut.log

Tips: if you have multiple file systems then it may take time to search. So best would be to replace / with the actual file system where you think the log would be. Let’s say you believe log is in /opt file system so you can do this.

#find /opt –name SystemOut.log

Know which process is holding a specific port number

Quite often you will have to deal with port conflict issues, especially in the shared environment.

If there is a situation to find out which process is holding port number then here is how you can know.

#netstat –anlp | grep 443

Ex

[root@Chandan ~]# netstat -anlp | grep 443
tcp       0     0 0.0.0.0:443                 0.0.0.0:*                   LISTEN     20924/nginx        
[root@Chandan ~]#

Note: Above example shows nginx with PID 20924 is holding 443 port.

Server boot time

If you are performing auto-startup troubleshooting and would like to know when the server was rebooted, you can use this command.

#who –b
[root@Chandan ~]# who -b
         system boot Jun 28 01:11
[root@Chandan ~]#

who -b command will give you the exact date and time of server reboot.

Alternatively, you may also use up time to check how long the server is up.

[root@Chandan ~]# uptime
01:20:27 up 14 days, 9 min, 1 user, load average: 0.00, 0.00, 0.00
[root@Chandan ~]#

Check CPU/Memory utilization in runtime

If you are having a performance issue, then you might want to know the current CPU/Memory utilization.

This will help you to find out which process is taking high CPU/Memory in real-time.

#top
top - 01:16:21 up 14 days, 5 min, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 70 total,   1 running, 69 sleeping,   0 stopped,   0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.3%si, 0.0%st
Mem:   502220k total,   454920k used,   47300k free,   143476k buffers
Swap:       0k total,       0k used,       0k free,   245412k cached
PID USER     PR NI VIRT RES SHR S %CPU %MEM   TIME+ COMMAND                      
29121 root     20   0 15008 1260 992 R 0.3 0.3   0:00.02 top                     1 root     20   0 19232 1136 860 S 0.0 0.2   0:25.18 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:00.00 migration/0                  4 root     20   0     0   0   0 S 0.0 0.0   0:01.21 ksoftirqd/0

Tips: look for the CPU/Memory section for the first few PID to find out the utilization.

Alternatively, you may also use the free command to find out total and free memory.

#free –m
[root@Chandan ~]# free -m
             total       used       free     shared   buffers     cached
Mem:           490       444         46         0       140       239
-/+ buffers/cache:         64        425
Swap:           0         0         0
[root@Chandan ~]#

As you can see above, there is 490 MB total memory, and only 46 MB memory is available.

There is another command called SAR (System Activity Report), which is also very helpful to find the CPU and Memory stats.

To check the CPU utilization

#sar

To check the Memory utilization

sar -r

Kill the process

Sometimes the process doesn’t stop gracefully if it’s hung or defunct. In this scenario, you can kill the process manually.

#kill PID

If above doesn’t help, you can use -9 to kill the process forcefully.

#kill -9 PID

Note: PID is your process ID

Compression & Extraction

Most often you will have to deal with compressing the files as housekeeping activity for a file system.

Compression

gzip command can be used to compress the files.

#gzip filename

Tips: if you have multiple files to be compressed, you can use gzip * which will compress all the files available in that working directory.

Extraction 

gunzip command will help you to extract the gz file.

#gunzip filename

Tips: you can use gunzip * which will help you to extract all gz file in that working directory.

Total CPU, Memory, File System

Often asked to provide server information, if you are working on migration or capacity planning.

Here is the quick command to help you to find out total CPU, Memory, and File system details.

CPU information

Find out CPU Cores, MHz, CPU manufacturer, Model Name and much more by using

#cat /proc/cpuinfo

Tips: if you have a high-end server then output of the above command will be long. So you can use grep to filter out the required information. Ex, just to find out cores, you can use

#cat /proc/cpuinfo | grep cores

Memory information

To find out the total available memory, you can use one of the following commands.

First one….

#free –G

This will show you total, free & cached memory

Second one…

#cat /proc/meminfo

This will show you much more information along with total memory.

File System information

To find out file system size and usage, you can use df commands.

#df –h
[root@Chandan tmp]# df -h
Filesystem     Size Used Avail Use% Mounted on
/dev/vda1       20G 1.6G   18G   9% /
tmpfs           246M     0 246M   0% /dev/shm
[root@Chandan tmp]#

Including –h will give you output in GB which is easy to understand.

Check out IP, Subnet Mask, MAC address and errors

Probably, one of the most widely used commands to find out IP related information.

[root@Chandan tmp]# ifconfig
eth0     Link encap:Ethernet HWaddr 04:01:5A:25:57:01
          inet addr:128.199.100.162 Bcast:128.199.127.255 Mask:255.255.192.0
         inet6 addr: fe80::601:5aff:fe25:5701/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
         RX packets:1491330 errors:0 dropped:0 overruns:0 frame:0
         TX packets:1636419 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:306418374 (292.2 MiB) TX bytes:274350737 (261.6 MiB)
[root@Chandan tmp]#

As you can see above, ifconfig will show the IP addresses, Ethernet details, a hardware address (MAC), subnet mask, errors, and other information. This is an extremely useful handy command if you are looking for this information.

Tips: you can use –a with ifconfig to show all available Ethernet details. Ex:

#ifconfig –a

Network commands like wget, telnet, traceroute

If you are doing application connectivity troubleshooting then most likely you will need to use these network commands.

Check if you can access particular URL from a server

You can quickly confirm if there is any connectivity issue on your server by using wget command. Ex: if you need to check if the server can access an external website like https://geekflare.com or not, you can use below.

[root@Chandan tmp]# wget geekflare.com
--2015-07-12 02:52:56-- https://geekflare.com/
Resolving geekflare.com... 104.28.23.60, 104.28.22.60
Connecting to geekflare.com|104.28.23.60|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'
[ <=>                                                                                 ] 65,435     --.-K/s   in 0.005s
2015-07-12 02:52:56 (13.4 MB/s) - `index.html' saved [65435]
[root@Chandan tmp]#

Tips: above you can see HTTP response code is 200 means there is no issue in connectivity.

Verify if the server can connect to backend service with the particular port number

If you are connecting to some other application like web service and need to verify if you can reach them, then you can use telnet command. This is very useful for a connectivity test.

In the below example, I have checked if geekflare.com on 443 port can be reached or not.

[root@Chandan tmp]# telnet geekflare.com 443
Trying 104.28.23.60...
Connected to geekflare.com.
Escape character is '^]'.

If you see “Connected” then that confirms there is nothing wrong with connectivity/firewall. However, if you see connection failed then you know, there is something like a firewall blocking your connection.

Tracing connection details

This may not be used all the time but extremely helpful when you have a latency issue or just want to find out the connection path between your server to the destination.

Below example is to show the network path from my server to geekflare.com

[root@Chandan tmp]# traceroute geekflare.com
traceroute to geekflare.com (104.28.23.60), 30 hops max, 60 byte packets
1 128.199.127.253 (128.199.127.253) 5.110 ms 5.061 ms 128.199.127.254 (128.199.127.254) 0.418 ms
2 103.253.144.237 (103.253.144.237) 5.153 ms 0.463 ms 103.253.144.241 (103.253.144.241) 8.009 ms
3 as13335.singapore.megaport.com (103.41.12.6) 4.822 ms 13335.sgw.equinix.com (202.79.197.132) 4.819 ms as13335.singapore.megaport.com (103.41.12.6) 4.490 ms
4 104.28.23.60 (104.28.23.60) 4.454 ms 4.427 ms 4.366 ms
[root@Chandan tmp]#

Ownership modification

If you are dealing with multiple users on a server and having root permission too then most likely once in a while, you will screw with permission/ownership. Well, not to worry its part of learning.

Here is the quick way to change the ownership or permission.

Change ownership

To change ownership of a particular file, you can use the chown command as below.

#chown user:group error.log

Tips: above will change ownership of error.log to mentioned user and group. If you have a folder, then you can use –R, which will change recursively to all the files within the folder. Ex:-

#chown –R user:group somefolder

I hope the above commands help you with your work. If you are looking to learn more sysadmin skills then check out these resources.

  • Chandan Kumar
    Author
    As the founder of Geekflare, I’ve helped millions to excel in the digital realm. Passionate about technology, I’m on a mission to explore the world and amplify growth for professionals and businesses alike.
Thanks to our Sponsors
More great readings on Linux
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • Monday.com is an all-in-one work OS to help you manage projects, tasks, work, sales, CRM, operations, workflows, and more.
    Try Monday
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder