`
If you find these tutorials useful, Please consider making a donation.

TheFrugalComputerLinuxLogo.png
TheFrugalComputerGuy.png
Linux Command Line 17
Processes







Linux Command Line (59) ps

ps stands for 'Process Status' or 'Print Snapshot' of the current processes.

Using the ps command with options starting with a dash will show the output using the UNIX options. Submitting the ps command options without a dash at the beginning will show the output with the BSD options.

Many different options using the UNIX and BSD options are shown in this video including 'ps aux', 'ps fax', and 'ps -efH'

The different fields of output from this command are also talked about in this video





 






Linux Command Line (60) top pt1

The top command shows a lot of information on the screen that can be very overwhelming, but the output is broken up into 4 sections.

At the top of the screen we have the 'Summary Data Area', then the 'Column Headers' line that shows what fields are below in the 'Task Information Process List' section, and then the last section is 'Messages and prompts' area that will be discussed in the top pt2 video.

In this video, the 'Summary Data Area' is focused on and talked about. The Summary Data Area shows an overall summary of what is happening on the system at the moment. Each line of the Summary Data Area is discussed and each line can be hidden or shown. Most lines have multiple options of displaying the information depending on a key-press, which are also discussed and shown in this video.

The numbers of the load average and cpu are discussed specifically when multiple cpus are on the system





 






Linux Command Line (61) top pt2

The information shown from the top command is updated every 3 seconds by default, that time can be changed, as well as the output which can filter down to a specific user and the number of lines shown.

The output is shown sorted by the percent of CPU used, but that can be changed to sort by the memory used or other columns and the sorted column can be highlighted.

There is an option to add color to the top command output, as well as customized the output color

There are also 4 different top screens available for customization of color and fields to be shown on the screen

Customizations can than be saved as the default and updated as needed or removed and the top defaults can be restored





 






Linux Command Line (62) nice

Linux users can change the nice value which will change the priority of a job. A chart in the video shows the default nice value is 0 with a priority of 20. Standard users can increase the nice value up to 19 which will raise the maximum priority to 39 (the chart in the video incorrectly shows 40, it should show as 39. There are 40 different nice values). The higher the nice value - priority number, the less available CPU that job will get. The lower the nice value and priority the more available CPU that job will get.

Privileged users can lower the nice values of their jobs and jobs submitted by Linux users. The lowest nice value they can assign is -20 which will be a priority of 0.

Jobs submitted by the Linux kernel can have a priority less than -20





 






Linux Command Line (63) kill process

We can kill a process in top by pressing the "k" key, then typing in the PID and pressing enter to confirm. Standard Linux users can only kill their own jobs. privileged Linux users can kill their own processes and other Linux users processes. Privileged users can not kill processes started by the kernel.

To kill a process from the command line we would type the full word kill then the PID of the process we want to kill. If the process does not stop, we can add -9 to the kill command to stop the process. We should always try kill before kill -9. Kill -9 could leave some files in an improper state.





 






Linux Command Line (64) Foreground Background

When we start a job in the command line, we can not type anything else in that terminal while the job is running because that job is running in the foreground.

We can send the job to the background by first pausing the job by holding down control and pressing the "z" key then typing bg for background

When a job runs in the background, we cannot hold down control and press "c" to cancel out of that job, nor can we give a program running in the background any input values until we bring it back to the foreground with fg

We can start a job in the background by adding an ampersand "&" after the command.





 






Linux Command Line (65) Screen pt1

Screen allows us to start virtual terminal Screen sessions that we can disconnect and reconnect to even if the terminal window is closed.

We can have many Screen session running at the same time and we can rename the screen sessions to identify each screen session.

To let Linux know the next command is a Screen command, Screen has a prefix of holding down control and pressing the lower case "a" key.

Holding down control and pressing the "a" key and then the "d" key will detach from the current Screen session.

We can list the Screen sessions running by typing "screen -ls" in a terminal window and then "screen -r" when there is a single screen session running or "screen -r screen name" when multiple screen sessions are running.





 






Linux Command Line (66) Screen pt2

We pick up from where we left off in Screen pt1 by reattaching to the splitwindows Screen session.

In there we create new windows with the Screen prefix of holding down control and pressing "a" and then pressing "c" for create new window.

We also show three different ways to move around the different screen windows open in the screen session, and we look at how to split windows as well.





 






Linux Command Line (67) tmux pt1

tmux allows us to start virtual terminal sessions that we can disconnect and reconnect to even if the terminal window is closed.

We can have many tmux sessions running at the same time and we can rename the tmux sessions to identify each tmux session.

To let Linux know the next command is a tmux command, tmux has a prefix of holding down control and pressing the lower case "b" key.

Holding down control and pressing the "b" key and then the "d" key will detach from the current tmux session.

We can list the tmux sessions running by typing "tmux ls" in a terminal window and then "tmux attach" when there is a single tmux session running or "tmux attach -t tmux session name" when multiple tmux sessions are running.





 






Linux Command Line (68) tmux pt2

We pick up from where we left off in tmux pt1 by reattaching to the splitwindows tmux session.

In there we create new windows with the tmux prefix of holding down control and pressing "b" and then pressing "c" for create new window.

We also show three different ways to move around the different tmux windows open in the tmux session(s), and we look at how to split tmux windows as well.





 






Linux Command Line (69) tmux pt3 .tmux.conf pt1

When we start a tmux session, we notice the mouse scroll wheel does not work by default. To get the mouse scroll wheel to work at startup, we add a tmux configuration ( .tmux.conf ) file and add the command to enable the mouse every time we start a new tmux session.

We move the status bar to the top of the screen and change the color of the status bar to blue with white text.

Then we increase the status left field of the status bar to fit the entire session name of splitwindows.

We finish wit a look at how to share a tmux session with someone else logged into the same server.





 






Linux Command Line (70) tmux pt4 .tmux.conf pt2

I show how to change the session name in the tmux status line to be the output from a Linux command, then I change the color of that output.

I add the time in my timezone with back text with a yellow background to the status bar right side.

Then I add text that changes (text and color) to tell me when there is more than one pane open.

I then center the middle section of the tmux status line and discuss how those fields work and change the look to show the current window in bold.

The last thing I do in this video is to change the prefix - so instead of holding down control and pressing the "b" key, we will now hold down control and press the "a" key to submit a tmux command.





 






Linux Command Line (71) Share a tmux socket

We look at how two tmux users can share a session by sharing the same tmux socket, as suggested in the comments in video 69.