The Linux Commands Series: Part IV

Ghost Rider
4 min readDec 11, 2021

du, df, basename, dirname, ps, top, kill, killall, jobs, bg

I intend to write a series of VI blog posts describing the most used Linux Commands. This blog is the first of the series. I hope you all enjoy the reading.

Citation/References/Credit will be mentioned at the end of the post.


This command will calculate the size of a directory as a whole:


The default number which pops up is in bytes, and for size, in megabytes and gigabytes, we can use options -m and -g, respectively:

du -m

du -g

To calculate the size of each file in the current directory, use du *:

du *

For human-readable format, we can use the -h option and -a for each file size in the directories:

du -h <directory name>

du -ah <directory name>


This command is used for disk usage information:


You can use the -h option for human-readable format:

df -h

You can also specify a file's name or a directory name for information on the disk space it lives on:

df <directory name>


Suppose you have a path to a file, it gives the last segment of the path, i.e., the file name:

Example: "/Users/Ghost/file.txt"

basename /Users/Ghost/file.txt

It provides "file.txt" as output.

If you have a path for a directory, for example, "/Users/Ghost/," it gives directory name:

basename /Users/Ghost/, output: Ghost


This command gives the directory name of a path; for example, let's say you have /Users/Ghost/file.txt,

dirname /Users/Ghost/file.txt, output: /Users/Ghost/


This command lists the processes initiated by the current user.

The above is a screenshot of the process from my system. It's a terminal instance I initiated.

If you want to view all the processes of all other users, use the option' a', and to view processes that are not initiated by a terminal, use 'x':

ps ax

Sample Output:

In order to view all the processes with full-fledged command listing on a new line instead of a cut version, use 'ww' option:

ps axww

Sample Output:


This command lists all processes running in real-time. The information on the terminal dynamically updates.

It gives a lot of information such as the command state (sleeping or running), CPU utilization and memory consumption and etc.

By default, all the processes are sorted by CPU utilization in descending order.

Inroder to quit, you can type letter ‘q’ or ctrl-C.



You can use the "kill" command to kill a process using its PID (Process ID).

kill <PID>

There are other usages with the "kill" command:

kill -STOP <PID>

STOP command is sent to the operating system kernel, and it immediately stops the process but does not terminate it.

kill -CONT <PID>

CONT command is used to resume a stopped process.

kill -KILL <PID>

KILL command is sent to the operating system kernel, and it stops and terminates the process immediately.

kill -INT <PID>

INT command is the same as ctrl-C in the terminal, and it terminates the process.


This command is similar to "kill" but it kills multiply processes at once. For example, if you have multiple instances of a program running, then use this command to kill them all:

killall <program name>


We can use '&' to run any command in the background, for example, top &.

In order to view these programs running in the background, we can use the "jobs" command. You can also use "-l" option to view the PID of the program.

jobs -l

sample output: [1]+ 12554 Stopped (tty output): 22top

We can run the program on the terminal instead of in the background using command fg and the program number:

fg 1

Or kill the process using the kill command.


Let's say you have suspended(paused not terminated) a program 'top' in the background using ctrl-Z, and you listed the program using the "jobs" command:


‘press’ ctrl-Z


Sample Output: [1]+ 12554 Stopped (tty output): 22top

You can resume program #1 using the command "bg":

bg 1

Note: Remember to use the man command for more intel on a particular command.

This is the end of this blog post. I will publish a blog post in this series once a week.


Please follow me for more interesting content.



Ghost Rider

I am a geek and technologist, at-least that’s what I would like call myself. I love anonymity. Let’s rock and roll!