More Small Tools

lsblk

When I get on a new system, one of the first things I want to know is how the storage is laid out. Also, in the wake of a filesystem issue (e.g., it’s not mounted), I want a tool to discover the problem. The simple lsblk  command can help in both cases.

As you examine the command, it seems fairly obvious that ls plus blk will “list all block devices” on the system (Figure 5). This is not the same as listing all mounted filesystems, which is accomplished with the mount command, which lists all network filesystems, as well.

Figure 5: Output from the “lsblk” command.

The default “tree” output shows the partitions of a particular block device. The block device sizes, in human-readable format, are also shown, as is their mountpoint (if applicable). A useful option is -f , which adds filesystem output to the lsblk output (Figure 6).

Figure 6. Output from the “lsblk -f” command.

kill

Sometime in your administrative career, you will have to use the kill command, which sends a signal to the application to tell it to terminate. In fact, you can send a whole host of signals to applications (Table 1). These signals can accomplish a whole host of objectives with applications, but the most useful is SIGKILL.

Table 1: Process Signals

SIGHUP SIGUSR2 SIGURG
SIGINT SIGPIPE SIGXCPU
SIGQUIT SIGALRM SIGXFSZ
SIGILL SIGTERM SIGVTALRM
SIGTRAP SIGSTKFLT SIGPROF
SIGABRT SIGCHLD SIGWINCH
SIGIOT SIGCONT SIGIO and SIGPOLL
SIGFPE SIGSTOP SIGPWR
SIGKILL SIGSTP SIGSYS
SIGUSR1 SIGTTIN  
SIGSEGV SIGTTOU  

I call SIGKILL the “extreme prejudice” option. If you have a process that just will not die, it’s time to use SIGKILL:

$ kill -9 [PID]

Theoretically, this should end the process specified.

If for some crazy reason the process won't die (terminate), and you need it to die, the only other action I know of to take is to shut down the system. Many times this can result in a compromised configuration when the system is restarted, but you might not have much choice.

As with whereis and which , I can promise that you will have to use kill -9 to stop a process. Sometimes, the problem is the result of a wayward user process, and one way to find that process is to use the commands mentioned in this article. For example, you can use the watch command to monitor the load on the system. If the system is supposed to be idle but watch -n 1 uptime shows a reasonably high load, then you might have a hung process using resources. Also, you can use watch in a script to find user processes that are still running on a node that isn't accessible to users (i.e., it has been taken out of production). In either case, you can then use kill -9 to end the process(es).

Related content

comments powered by Disqus