Trending December 2023 # How Does Size Command Work In Linux? # Suggested January 2024 # Top 15 Popular

You are reading the article How Does Size Command Work In Linux? updated in December 2023 on the website Kientrucdochoi.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 How Does Size Command Work In Linux?

Definition of Linux Size

The size command in Linux will allow listing the section size and the total size of the object files or the archived files in its argument list. In this tutorial, we will discuss its syntax, how to size command is used in Linux, its options, and its usages with different examples.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax of size command in Linux:

We can use the size command in Linux in a different format with different options, as shown below:

[–help] [–common] [objfile…]

How Does Size Command Work in Linux?

Size commands in Linux can be used in different ways with its options. Below are the options that can be used with the size command in Linux and its description.

Options Description

We can select the output style by mentioning the format either in SysV or Berkeley.

To display the numbers in order of octal, decimal, or hex.

-t        –totals To print the total size for Berkeley format only.

–common To print the total size of *COM* syms

 To set the binary object file format

 To scan the options from object-file

-h        –help To display the list of options available in the size command.

-v        –version To display the version of the program.

Examples of Linux Size Command

Following are the examples are given below:

1. To Get the Default Size Output

Syntax:

size directory_name

Example:

size /usr/var/log

The above result is in Berkeley format, and we can also get the same output in three different commands, as shown below:

2. Default File Option

In the current directory, it will check for ‘a.out’ file and calculate the size, displaying the result in Berkeley format.

Syntax:

size

Example:

size

3. To Get the Output in SysV Format

The output, when generated in SysV format, will print different sections along with the size and address of each section name.

Syntax:

size –format=SysV dir_name

Example:

size --format=SysV /usr/var/log

4. To Specify the Output Value in Decimal

When we pass the option ‘-d’ with the argument list, we will get the result in decimal value format as given in the example below.

Syntax:

size -d dir_name

Example:

size -d /usr/var/log

5. To Specify the Output Value in Octal Format

When we pass the option ‘-o’ with the argument list, we will get the result in octal value format as given in the example below.

Syntax:

size -o dir_name

Example:

size -o /usr/var/log

6. To Specify the Output Value in Hex Format

When we pass option ‘-x’ with the argument list, we will get the result in hex value format as given in the example below.

Syntax:

size -x dir_name

Example:

size -x /usr/var/log

7. Option –radix

For decimals, we can use the number format as –radix=10.

Syntax:

size –radix=10 /dir_name

Example:

size --radix=10 /usr/var/log

Radix option in the size command is used to specify the format number instead of using decimal, hex, or octal. For decimals, we can use the number format as –radix=10.

Syntax:

size –radix=10 /dir_name

Example:

Radix option in the size command is used to specify the format number instead of using decimal, hex or octal. For octal, we can use the number format as –radix=8.

Syntax:

size –radix=8 /dir_name

Example:

size -o /usr/var/log

Radix option in the size command is used to specify the format number instead of using decimal, hex, or octal. For hex, we can use the number format as –radix=16.

size --radix=16 /dir_name

Example:

size --radix=16 /usr/var/log

We can use only format numbers as 10,8,16 for decimal, octal, and hex, respectively. When we use other format numbers, we will get an error saying “Invalid radix.” Below is an example of an invalid radix format.

size --redix=12 /usr/var/log

8. To Display the Common Symbol Count

The common option allows printing the total number of all common symbols in the object file. By default, the format will take Berkeley file format; this will also be used to include in the value for column “bss.”

Syntax:

size -A --common /dir_name

Example:

size -A --common /usr/var/log

Option -A is used for SysV format. In the above example, the last line having *COM* will give the value.

9. To Display the Total in Berkeley Format

The option -t (or –totals) allows in displaying the new line at the end of the result that will print the value of all the object files that are in the list.

Syntax:

size -t /dir_name

Example:

size -t /usr/var/lo*

Conclusion

The size command in Linux is a very important command that will allow listing the section size and the total size of the object files or the archived files in its argument list. When the object file is not specified in the parameter list, the default file name used is ‘a.out’. The output formats can be displayed in different formats, such as decimal, octal, or hexadecimal. The tutorial above explains various options and provides examples to enhance understanding of these output formats.

Recommended Articles

We hope that this EDUCBA information on “Linux Size” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

You're reading How Does Size Command Work In Linux?

Understanding Time Command In Linux

As a Linux user, you must have come across time command. It is a simple yet powerful command that allows you to measure execution time of a process. Whether you are a developer, system administrator, or just a curious user, understanding how time command works is essential for optimizing your workflow and identifying bottlenecks in your system. In this article, we will dive deep into time command in Linux and explore its various use cases.

What is time command?

The time command is a Linux utility that measures time it takes for a given command to execute. command accepts a single argument, which is command you want to measure. output of time command includes following information −

Real time − actual elapsed time, including time spent waiting for I/O and other processes.

User time − amount of CPU time spent in user-mode code.

System time − amount of CPU time spent in kernel-mode code.

The time command is available on all major Linux distributions, including Debian, Ubuntu, CentOS, and Fedora.

Using time command

To use time command, simply type “time” followed by command you want to measure. For example, to measure execution time of “ls” command, you would run −

time ls

The output will look something like this −

real 0m0.003s user 0m0.000s sys 0m0.003s

Here, real time is 0.003 seconds, user time is 0.000 seconds, and system time is 0.003 seconds. real time is most important metric since it includes all time spent waiting for I/O and other processes. user and system times are also useful for identifying performance bottlenecks, but they are less important than real time.

The time command also works with complex commands that include pipes, redirection, and other shell features. For example, you can measure execution time of a pipeline that includes “grep” and “wc” commands like this −

The output will look something like this −

1584 real 0m0.013s user 0m0.010s sys 0m0.007s

Here, pipeline returns number of lines in syslog file that contain word “error”, and time command measures execution time of entire pipeline. Note that output of pipeline itself is not included in output of time command.

Options for time command

The time command also supports several options that allow you to customize its behavior. Here are some of most useful options −

-f format − This option allows you to specify a custom output format for time command. format string should include one or more conversion specifiers, such as %E for elapsed time, %U for user time, and %S for system time. For example, to display real time and CPU time in seconds, you can run −

time -f "%E real, %U user, %S sys" ls

The output will look like this −

0:00.00 real, 0.00 user, 0.00 sys

-o file − This option allows you to redirect output of time command to a file instead of standard output. For example, to save output of time command to a file called “output.txt”, you can run −

time -o chúng tôi ls

-p − This option is used to format output for use in scripts or other programs. It prints real, user, and system times in seconds, separated by a space.

time -p ls

The output will look something like this −

real 0.003 user 0.000 sys 0.003

-v − This option allows you to save output of time command to a shell variable instead of printing it to standard output. For example, to save real time of “ls” command to a variable called “elapsed_time”, you can run −

The output will look something like this −

Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00

-a − This option allows you to display additional information about process being timed. This includes exit status of process, maximum resident set size (RSS), and number of voluntary and involuntary context switches. For example, to display this additional information for “ls” command, you can run −

time -a ls

The output will look something like this −

real 0m0.003s user 0m0.000s sys 0m0.003s exit 0 voluntary_ctxt_switches 0 involuntary_ctxt_switches 1 Additional Use Cases for time Command

Apart from measuring execution time of a single command, time command can also be used to measure performance of a system or a script.

Measuring System Performance

You can use time command to measure overall performance of a system by running a command that stresses system’s resources. For example, you can use dd command to read or write large amounts of data from or to a disk.

time dd if=/dev/zero of=/dev/null bs=1M count=1000 Measuring Script Performance

You can use time command to measure performance of a script by running it with time command. For example, suppose you have a Python script called “myscript.py” that performs a complex computation. You can measure execution time of script like this −

time python myscript.py

The output of command includes real time, user time, and system time taken to execute script.

Measuring Performance of a Loop

You can use time command to measure performance of a loop in a script by enclosing loop in curly braces and prefixing it with time command. For example, suppose you have a bash script that contains a loop that performs a complex computation. You can measure execution time of loop like this −

time { for i in {1..10000}; do # complex computation done }

The output of command includes real time, user time, and system time taken to execute loop.

Conclusion

The time command is a versatile and useful tool for measuring execution time of commands in Linux. Whether you are debugging a slow script, optimizing a database query, or just curious about how long a command takes to run, time command can provide valuable insights into your system’s performance. By mastering time command and its various options, you can become a more efficient and effective Linux user or system administrator.

How Does Annotation Work In Kubernetes?

Kubernetes Annotations

Web development, programming languages, Software testing & others

How does Annotation Work in Kubernetes?

Annotations have key/value pairs same as labels. Annotation key consists of two parts, a prefix which is optional, and a name. These two parts are separated by a slash ‘/’. The name part is mandatory and it is not longer than 63 characters. It starts and ends with alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumeric in between. The prefix is optional however if specified it must be a DNS subdomain and length must be 253 characters or less and ends with a slash (/) If automated system components such as kube-controller-manager, kube-scheduler, kube-apiserver, kubectl or any other third party automation) add annotations to the end-user Kubernetes objects, it must specify a prefix. There are two reserved prefixes ‘kubernetes.io/’ and ‘k8s.io/’ for Kubernetes core components.

We use the “annotations” keyword to add an annotation to the object. Annotations are also key/value pairs like labels as shown below:

"metadata": { "annotations": { "key1" : "value1", "key2" :  "value2", "key3" :"value3" } } Examples of Kubernetes Annotations

Let’s understand the examples of Kubernetes Annotations with Syntax.

Example 1

We have an nginx pod and we want to attach annotations like on-call person pager number, URL or name of the image registry and link of knowledge base article, etc. We can add these details under annotations under metadata primitives. There are default annotations attached by the ‘kubectl’ to every Kubernetes objects whether we attach annotations to the Kubernetes object or not. This annotation is the ‘kubectl.kubernetes.io/last-applied-configuration’. Let’s create a pod using below yaml file.

apiVersion: v1 kind: Pod metadata: name: nginx-web-server labels: env: prod app: nginx-web spec: containers: - name: nginx image: nginx ports: - containerPort: 80

After creating the pod, we use below two commands to check the attached annotation:

Syntax: 

Example 2 $kubectl describe pod nginx-web-server

$kubectl get pods nginx-web-server -o custom-columns=ANNOTATIONS:.metadata.annotations

Explanation: In the above example, there is no annotation attached to the pod however, there is an annotation attached to the pod and that is attached by Kubernetes core components as it has reserved prefix ‘kubernetes.io’ and name of the annotation is ‘last-applied-configuration’ which means it holds the last configuration applied to that object. The value of the annotation is truncated in the output we get from the first command. If we want to know or extract full value, we use the second command which output only key/value pairs of annotations.

Let’s create a pod and attach the annotations ‘oncallPager’, ‘imageregistry’, and ‘kbArticle’ as we discussed above. Below is the YAML configuration file for the same: –

apiVersion: v1 kind: Pod metadata: name: nginx-web-server labels: env: prod app: nginx-web annotations: oncallPager: 111-222-3333 spec: containers: - name: nginx image: nginx ports: - containerPort: 80

After deploying the above pod, we use the ‘kubectl describte’ command to see the attached annotations as shown in the below snapshot: –

Let’s output only annotations and see how it looks like. Here is the output: –

Explanation: In the above snapshot, the key/value pairs are not that much clear as compare to earlier output and it will be difficult to find the key/value pairs if there are many annotations attached to a Kubernetes object.

Scenarios of Kubernetes Annotations

There are many scenarios where annotations are very useful. Some use cases are as below:

We can add application build, release, or image information build number, release ID, git branch, registry address, image hashes, etc.

We can attach name, version, and build information of client library or tool for debugging purposes.

We can add user or tool/system information from where the objects originated. For example, objects can be created by automation tools like Jenkins in CI/CD model. It is very useful information who has created the Kubernetes object.

Attaching fields managed by a declarative configuration layer as annotations help to differentiate them from default values set by clients or servers, and from auto-generated fields and fields set by auto-sizing or auto-scaling systems.

We can also attach phone or pager numbers of the responsible person or directories or link where one can find that information if something bad happens.

The link of the knowledge base article or article number can be also attached to troubleshoot known issues related to that object.

We can add pointers to logging, monitoring, analytics, or audit repositories.

Conclusion

Kubernetes are similar to labels as it also has key/value pairs, however, it cannot be queried by Kubernetes itself but there are many tools that are configured to query objects based on their annotations, for example, Prometheus, third party tools, etc. Huge annotations do not the impact internal performance of Kubernetes so there are no keys and values constrained like labels.

Recommended Articles

We hope that this EDUCBA information on “Kubernetes Annotations” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

How To Use Nano Command Line Text Editor In Linux

Nano is a simple yet powerful command line-based text editor, very popular among beginner Linux users for its simple-to-use interface. As a command-line editor, it offers a lightweight alternative to more complex graphical text editors. In this article, we will explain how you can use the nano text editor in Linux, right from installing it to editing documents with it.

How to Install Nano in Linux

Generally, the nano editor comes preinstalled on most Linux distros. If you are not sure, you can check using the following command:

nano --version

After executing the command, if you see the nano version number in the Linux Terminal, this means it is installed, and you can proceed to the next section wherein we’ve described how to use the nano editor in Linux. If you get an error like “nano: command not found,” then use the commands below to install nano depending on your distro:

For Debian-based distros:

Install on Cent OS/RHEL-based distro:

sudo yum install -y nano

For Arch-based distros:

sudo pacman -S nano

For Fedora-based distros:

sudo dnf install nano

Nano Command: Syntax and Options

Using the nano command line editor in Linux is pretty straightforward. The basic syntax to use nano text editor is:

OptionsDescription-BTo save a file and back up the previous version of it by appending a tilde (~) to the current filename.-ETo convert the typed tabs into spaces.-LTo stop adding a new line after the original text.-NDisables automatic conversion of files from Mac/DOS format to Unix format-QTo match a part of the text using regular expressions-lDisplays the line number to the left of the text area-uTo save the file in Unix format by default.

How to Open/ Create a New File with Nano

To open a file with the nano command in Linux, use this syntax:

For example, to open the file “test.txt”, use the following command:

nano test.txt

For example, to create a new file with the name “test.py”, use this command:

nano test1.txt

When the nano command is executed, it first looks for the given file name in the mentioned directory. If the file is found, it opens the file, else creates a new file with the given file name.

How to Edit a File with the Nano Editor Cut Selected Text

To select the text, head over to the beginning of the word which you want to select and press “ALT + A.” Use the arrow keys to select the text as you need.

Once you have selected the desired text, press “CTRL + K” on the keyboard to cut the selected portion of the text.

Copy Selected Text

First, select the text using “ALT + A” and the arrow keys.

Once selected, use “ALT + 6” to copy the selected text to the clipboard.

Paste Selected Text

First, navigate to the place where you want to paste the selected text using the arrow keys.

Now, press “CTRL + U” on the keyboard to paste the text from the clipboard.

Search and Replace Text in Nano

Sometimes you need to search for some specific text inside a huge document and scrolling through it is not a viable option. Fortunately, the nano command comes with a search-and-replace utility, which can work on documents formatted with Linux, Windows, macOS, etc.

To search for a specific text, press “CTRL + W,” type the text you want to search in the new search bar at the bottom of the screen and hit the Enter key. If found, the cursor will get placed at the beginning of the searched word. To move on to the next occurrence of the searched term, use “ALT + W.”

To search and replace a specific text, press “CTRL + ” on the keyboard. Enter the search term and press enter. Then, enter the term you want to replace it with on the next prompt. The cursor will move to the first position it found the search term.

You can press either ‘y’ to replace this text or ‘n’ to skip the current match and move on to the next one.

The default nano command keybindings are different from the common keybindings, which the users may be accustomed to while working on other Linux GUI apps. To make things easier for beginners, the Nano text editor has a small cheat sheet right at the bottom of the screen (more on it later).

How to Save Files and Exit Nano Editor

How to exit Vim is a question that has been wreaking havoc in the lives of Linux users since its inception, as you don’t get any prompt even for basic tasks such as saving or exiting the editor. However, the nano command provides a small prompt to help users get around.

To save and exit the nano command screen and return back to the Linux shell prompt, simply press “CTRL + X” on your keyboard. If you have made any changes to the file, press ‘y’ to save the changes or press ‘n’ to discard them. You will then be asked if you want to keep the same file name or use a new name. Enter the new file name or press Enter to use the same file name.

To simply save and continue editing the document in Nano editor, press “CTRL + O” on the keyboard. Press the Enter key to use the same file name or enter the new name and then hit enter.

Nano Command in Linux: Keyboard Shortcuts

Here are some of the common shortcuts to use with the nano command that works on all operating systems, including Linux, Windows, macOS, etc:

Keyboard ShortcutDescriptionCTRL + AMoves the cursor at the beginning of the lineCTRL + EMoves the cursor at the end of the lineCTRL + YScrolls the screen up by a pageCTRL + VScrolls the screen down by a pageCTRL + GOpens nano command help windowCTRL + OSaves the current fileCTRL + WSearches for a specific text in the entire documentCTRL + KCuts the entire selected portion of text to the clipboardCTRL + UPastes the text portion from the clipboard into the documentALT + 6Copies the selected text to the clipboardCTRL + XExits the editorCTRL + _Lets you go to the specified line and column chúng tôi + AUsed to select textCTRL + GOpen help menu for nano

Frequently Asked Questions

Why do we use nano in Linux?

The nano editor is a simple easy-to-use command-line text editor, which can be handy for editing text documents on Linux distros.

Is nano easy to use?

Compared to Vim, the nano command line editor in Linux has a much easier learning curve and is easy for beginners to use in their daily workflow.

How Does Responsibility Center Work?

What is Responsibility Center?

The term “responsibility center” refers to the operational units within an organization that are accountable for the activities specially designed for them.

These units usually have their staff, goals & objectives, and policies & procedures. These units also manage matters related to revenue generated, expenses incurred, and funds invested in their activities. This arrangement is usually seen in large multinational companies, where the organizational tasks are divided into multiple subtasks. The responsibility centers assign each task to a small division or group.

Start Your Free Investment Banking Course

Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & others

Key Takeaways

Some of the key takeaways of the article are:

The responsibility center refers to the operational units within an organization that have well-defined individual targets to fulfill and are accountable for them.

Large organizations usually divide their work into smaller subgroups so that every unit achieves its goals that all add up to fulfill the overall organizational objectives.

These units have their staff, goals & objectives, and policies & procedures.

There are four significant types of responsibility centers – cost center, revenue center, profit center, and investment center.

How does Responsibility Center work?

In a large organization, all the tasks are split amongst smaller teams focusing on their respective objectives. These small units work synchronously to achieve the overall organizational goals.

Each unit has its targets and goals, which they are expected to achieve within a pre-defined timeline. These subgroups use their resources, follow procedures, prepare financial reports, and bear responsibilities. Although they function independently, they tend to contribute toward the common organizational objective.

Types of Responsibility Center

There are four significant types of responsibility centers – cost center, revenue center, profit center, and investment center.

1. Cost Center

It is a unit that allocates, supervises, segregates, and eliminates different kinds of cost-related issues of a company. The primary responsibility of a cost center is to manage the company’s costs and check its unwanted expenditures. Under the cost center, the manager is responsible for all expenses, including maintenance, production, HR, etc.

2. Revenue Centre

It is accountable for generating and monitoring revenue. The management has hardly anything to do with control over cost or investment-related issues within the organization. Comparing the budgeted revenue with the actual payment determines the performance of the revenue center.

3. Profit Centre 4. Investment Centre

It is primarily responsible for investment-related of the organization. The manager may need to control income and expenses in order to manage profitability, which they eventually invest in other assets.

Examples of Responsibility Center

Let us look at a simple example to decipher the role of the responsibility centers within an organization.

ABC Inc. manufactures a range of denim wear, such as pants, shirts, tops, etc. The company often invests huge capital to carry out large business operations or expand. And like any other business, it manufactures goods and sells them in the market, generating revenue.

Hunting for the best investment choice is not the same as looking for a profitable market. The former analyzes return on investment, while the latter intends to maximize profit. Large organizations subdivide tasks into small units or groups.

Importance of Responsibility Center

The process of creating responsibility centers helps an organization achieve its overall goals. In this arrangement, the tasks are segregated and tagged to many managers, allowing proper delegation and control. Without responsibility centers, it will be difficult for organizations, huge multinational companies, to manage their operations and achieve their overall organizational goals and objectives. This is because these units with an organization are analogous to the different parts of the human body.

Advantages of Responsibility Center

First, given that there is a responsibility assigned to all the units, each individual has responsibilities aligned with the roles that direct them toward a common purpose.

Since senior management tracks and reports individual performances, each individual tends to give their best performance.

It facilitates better delegation and control of organizational tasks, which is one of the objectives of management.

First, a conflict of interest may arise between the individual objectives and the organizational goals.

The management must invest a lot of time and effort to plan and meticulously chalk out the course of action.

Sometimes, the employees or managers are resistant/ reluctant to join a particular department/ segment/ role.

Conclusion

So, it can be seen that responsibility centers are essential cogs in any organizational machinery. It can help organizations grow and seamlessly manage their activities if implemented correctly and efficiently.

Recommended Articles

How To Use The Ps Command In Linux To Kill Process

When you are working, sometimes your programs suddenly freeze. Other times, the programs are still running but with a high processor or memory consumption. There is a way to fix this in Linux using the ps (Process Status) command. Here we show you how to use the ps command in Linux to list the currently running processes and their PIDs. You can then find and kill the processes consuming your resources.

Using the “ps” command

The ps command can be used on its own. It will output four columns of information:

PID: the unique identifier of the process defined by the system. It’s the value that we use to stop a process.

TTY: terminal from which the process was started.

TIME: the total amount of CPU time used by the process.

CMD: command that generates the process

Note that when you use the command without any options, it doesn’t show you much information. Here are a few ways to make it more useful.

1. List the process of all users

When some programs are installed, they sometimes also create some additional users to run the process. To list the processes of the users, use the -e option:

ps

-e

and its output:

PID TTY TIME CMD

1

? 00:00:02 systemd

2

? 00:00:00 kthreadd

3

? 00:00:00 kworker

/

0

:

0

4

? 00:00:00 kworker

/

0

:0H

5

? 00:00:00 kworker

/

u256:

0

6

? 00:00:00 mm_percpu_wq 2. List process with more information

It’s possible to have more information when you list the running process. To do this, you can use the ef option.

ps

-ef

and its output:

UID PID PPID C STIME TTY TIME CMD root

1

0

0

21

:

34

? 00:00:03

/

sbin

/

init maybe-ubiquity root

2

0

0

21

:

34

? 00:00:00

[

kthreadd

]

root

3

2

0

21

:

34

? 00:00:00

[

kworker

/

0

:

0

]

root

4

2

0

21

:

34

? 00:00:00

[

kworker

/

0

:0H

]

root

6

2

0

21

:

34

? 00:00:00

[

mm_percpu_wq

]

root

7

2

0

21

:

34

? 00:00:00

[

ksoftirqd

/

0

]

3. Filter the Process by Process ID

If you know the process ID of the running process you want to show, you can filter for it specifically with the -p flag. This can take multiple PIDs as arguments, separated by a single comma and no space.

ps

-ef

-p

1234

,

5678

,

9012

4. List the processes owned by a user

You can also list the processes that are owned by a user with the u option followed by the name of the user:

ps

-u

userName

and its output:

PID TTY TIME CMD

2832

? 00:00:00 systemd

2842

? 00:00:00

(

sd-pam

)

3043

? 00:00:00 sshd

3044

pts

/

1

00:00:00

bash

18396

pts

/

1

00:00:00

ps

5. List the actives processes

It’s possible to list all the processes that are active by using the ax option:

ps

-ax

and its output:

PID TTY STAT TIME COMMAND

1

? Ss

0

:02

/

sbin

/

init maybe-ubiquity

2

? S

0

:00

[

kthreadd

]

3

? I

0

:00

[

kworker

/

0

:

0

]

4

? I

<

0

:00

[

kworker

/

0

:0H

]

6

? I

<

0

:00

[

mm_percpu_wq

]

7

? S

0

:00

[

ksoftirqd

/

0

]

6. List the active processes with the users

It’s possible to list all the active processes with the users when you add the -aux flag:

ps

-aux

and its output:

USER PID

%

CPU

%

MEM VSZ RSS TTY STAT START TIME COMMAND root

1

0.0

0.2

78132

9188

? Ss

21

:

34

0

:02

/

sbin

/

init maybe-ubiquity root

2

0.0

0.0

0

0

? S

21

:

34

0

:00

[

kthreadd

]

root

3

0.0

0.0

0

0

? I

21

:

34

0

:00

[

kworker

/

0

:

0

]

root

4

0.0

0.0

0

0

? I

<

21

:

34

0

:00

[

kworker

/

0

:0H

]

root

6

0.0

0.0

0

0

? I

<

21

:

34

0

:00

[

mm_percpu_wq

]

root

7

0.0

0.0

0

0

? S

21

:

34

0

:00

[

ksoftirqd

/

0

]

root

8

0.0

0.0

0

0

? I

21

:

34

0

:00

[

rcu_sched

]

root

9

0.0

0.0

0

0

? I

21

:

34

0

:00

[

rcu_bh

]

root

10

0.0

0.0

0

0

? S

21

:

34

0

:00

[

migration

/

0

]

7. Filter the process by the name of a program

It’s possible to retrieve the information about a specific program that is running by applying a filter on the ps result:

root

1508

0.0

2.2

1518156

90868

? Ssl

21

:

34

0

:03

/

usr

/

bin

/

dockerd

-H

fd:

//

--containerd

=

/

run

/

containerd

/

containerd.sock userkub+

18429

0.0

0.0

13144

1108

pts

/

1

S+

23

:

57

0

:00

grep

--color

=auto docker

Alternatively, you can also use the C option to filter the process by its name:

ps

-C

name 8. Display Specific Columns

In addition to the four default columns, you can get ps to display an additional column of information. For example:

ps

-e

-o

pid,

uname

,pcpu,pmem,

comm

The -o flag sets specific output display options for the ps command’s results. See a full list of standard display options for ps.

9. Display Results in Hierarchical Tree Style

ps

-e

--forest

This uses ASCII art to create a tree-style structure for displaying processes. Shows forked and children processes as descendants of the appropriate parent processes, sorting to match. To hide the “branches” of the tree, use -H in place of --forest.

11. Show All Root Processes

ps

-f

-U

root

-u

root

Execute a search for all processes running with real and effective root identifications. This shows them in the full-length format, thanks to the -f flag. You can combine it with the -o flag to customize output.

Use the kill command to stop a process

Once you have located the misbehaving process, you can use the kill command to kill a process that is running. The command sends a signal to a process that terminates it. When your programs are frozen, most of the time you will need to forcefully kill them with the -9 option.

The output of ps is an instant view. Unlike htop, It does not update itself dynamically. This means you might have to run it multiple times to get a clear picture of which process is misbehaving. To get an up-to-date view of the processes, you can try some other commands for the Linux system.

Alain Francois

A Linux system administrator passionate about Open-Source environments and working on installations, deployments for different IT solutions and cloud environments. I like to share my knowledge regarding the technologies that I can discover and use

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

Update the detailed information about How Does Size Command Work In Linux? on the Kientrucdochoi.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!