Categories
Linux Tutorial Series

Linux Tutorial Series – 113 – Review – revisiting top’s columns

Here is the video version, if you prefer it:

Let’s look at the output produced by top and explain what does it all mean:

mislav@mislavovo-racunalo:~/Linux_folder$ top

top - 13:15:58 up 101 days, 19:37, 1 user, load average: 0.44, 0.42, 0.44

Tasks: 241 total, 1 running, 239 sleeping, 0 stopped, 1 zombie

%Cpu(s): 0.2 us, 0.1 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

MiB Mem : 7853.8 total, 127.8 free, 4300.2 used, 3425.8 buff/cache

MiB Swap: 8066.0 total, 6694.0 free, 1372.0 used. 2891.4 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

8770 mislav 20 0 3002016 320192 111444 S 1.0 4.0 5:46.85 Web Content

8357 mislav 20 0 3524552 369556 151704 S 0.3 4.6 5:26.81 firefox-esr

14417 mislav 20 0 4222052 321880 168376 S 0.3 4.0 0:31.67 anki

...

  • First we have some information about current time, how long my machine has been running and how many users are logged in (Shotts, 2019)⁠
  • load average – how many processes is your computer executing in the last minute, last 5 minutes, last 15 minutes
  • Tasks – how many tasks are there on the computer – 1 is running (meaning being actively executed), 239 are sleeping (meaning waiting for something to happen (such as data from a device) to resume their execution), 0 stopped (meaning no processes whose execution was paused manually) and 1 zombie process (zombie process is a process whose parent process doesn’t exist anymore)
  • %Cpu(s) tells us what percentage of the CPU is being used on what kinds of processes: us is for user processes, sy is for system (kernel) processes, ni is for nice (low-priority) processes, id is for the percentage of the CPU that is idle, wa is for percentage of the CPU waiting for some input/output tasks, hi is the time spent processing hardware interrupts, si is the time processing software interrupts and st is relevant to virtual environments – if you don’t know what virtual environments are, that needn’t concern you (“Linux ‘top’ command: What are us, sy, ni, id, wa, hi, si and st (for CPU usage)?,” n.d.)⁠
  • MiB Mem and MiB swap tell you how much RAM and how much swap space is being used (measured in mebibytes (“Mebibyte,” n.d.)⁠)

Let’s now look at the columns available for each process: (“A Guide to the Linux ‘Top’ Command,” n.d.)⁠

  • PID – proces ID
  • USER – user who owns the process
  • PR – process priority
  • NI – niceness (nice value) of a process
  • VIRT – total amount of memory consumed by the process (permanent storage device + RAM – the basic idea is that if the operating system runs out of RAM, it can use some memory available on the permanent storage device in addition to the RAM; this concept is called virtual memory – look it up on Google if you are interested)
  • RES – memory consumed by the process in RAM
  • SHR – amount of memory shared with other processes (processes can share memory)
  • S – process state (is the process running, is it sleeping, …)
  • %CPU – how much CPU is the process using (in percentages)
  • %MEM – how much memory is the process using (in percentages)
  • TIME+ – total time used by the process since it started
  • COMMAND – the name of the process

Hope you understand the output of top in detail now and hope you refreshed your memory!

References

A Guide to the Linux “Top” Command. (n.d.). Retrieved February 19, 2020, from https://www.booleanworld.com/guide-linux-top-command/#Understanding_top8217s_interface_the_task_area

Linux “top” command: What are us, sy, ni, id, wa, hi, si and st (for CPU usage)? (n.d.). Retrieved February 19, 2020, from https://unix.stackexchange.com/questions/18918/linux-top-command-what-are-us-sy-ni-id-wa-hi-si-and-st-for-cpu-usage

Mebibyte. (n.d.). Retrieved February 19, 2020, from https://en.wikipedia.org/wiki/Mebibyte

Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 137-139

Categories
Linux Tutorial Series

Linux Tutorial Series – 88 – Review

Here is the video version, if you prefer it:

We looked at history and variables. In particular, we looked at:

  • history is used to look at history; use CTRL + R for reverse search in history and CTRL + J to copy the command to your clipboard
  • Dot files (files whose filenames begin with a dot) are hidden by default
  • Variables are named parts of computer memory where values are stored
  • Environment variables are variables passed to the shell by the operating system
  • Shell variables are local to the shell
  • Command path stores all of the places to look for executables
  • Interactive shells require user input, non-interactive don’t
  • Login shells exist to do some things only once
  • Your Terminal application is an interactive, non-login shell
  • Place almost all changes you want permanently in .bashrc file in your home directory

Let’s carry on with our Linux journey!

Categories
Linux Tutorial Series

Linux Tutorial Series – 75 – Review

Here is the video version, if you prefer it:

We talked about command types, which there are 4 – executables, shell built-ins, shell functions and aliases, as well as the commands used to determine the type of a particular command. We also talked about finding files – both locate and find – and (hopefully) memorized the syntax find dir -name file -print.

We also covered some other stuff, but the above ones are the most important.

Categories
Linux Tutorial Series

Linux Tutorial Series – 60 – Recap

Here is the video version, if you prefer it:

A flashback – we talked about:

Redirecting input and output:

  • ls > output.txt is an example
  • Use >> to append
  • Use &> to redirect both standard output and standard error

Other stuff we talked about:

  • Pipelines are used to redirect standard output of one command to the standard input of the other command; usage: command1 | command2
  • Shell globbing (wildcards) is used to match filenames before the command is executed
  • Brace expansions – something{else,else2,else3} (no spaces between the commas)
  • Regular expressions are used to match patterns in text; for example, a* means match the character a zero or more times

Hope you refreshed your memory!

Categories
Linux Tutorial Series

Linux Tutorial Series – 50 – Recap

Here is the video version, if you prefer it:

Here are all of the commands we have learned: 

  • The general command format is: command -options arguments
  • Commands are case sensitive
  • cd directory to change the directory you are located in (current directory)
  • pwd to print the absolute path to the directory you are in
  • man command gives you the man pages of the command
  • Options can be both short (-) and long (--)
  • Use -h or --help to see a quick description of command usage
  • ls command lists directory contents
  • cp src dest copies from source (src) to destination (dest)
  • mv old new renames file with filename old to filename new
  • rm item is used to delete the item; rm -r folder to delete the folder
  • touch filename to create a new file with name filename
  • mkdir dirname to create a new directory with name dirname
  • rmdir dirname to remove a directory with the name dirname (the directory has to be empty)
  • echo message to print out the message
  • cat filename to print out the contents of the filename
  • less filename to page through the contents of the filename
  • head and tail for viewing only the first or the last portion of a file
  • sudo command to execute the command as the superuser
  • su to switch user (without an argument switches to the superuser)
  • grep pattern file for pattern matching in files
  • wc file to count the number of words (and other stuff) in a file – haven’t used it as much

Hope this refreshed your memory!

Categories
Linux Tutorial Series

Linux Tutorial Series – 23 – Recap

Here is the video version, if you prefer it:

Today let’s quickly review the things we learned:

  • Shell is a program that runs commands
  • Commands are programs you can run with options and arguments
  • date and cal are used to display the time and the calendar (this is not so important)
  • Use Up/Down arrows to search command history
  • Use Left/Right arrows to navigate to individual characters of the current command
  • Use the clear command to clear your Terminal window
  • Exit a terminal command session with exit or press CTRL + D
  • Directories are a way to organize files
  • Files are resources that contain information
  • We talked about what to expect in the directories of a typical Linux directory hierarchy
  • Parent directory is one directory “above” your current directory
  • Absolute path names start with the root folder and proceed onward
  • Relative path names start from the folder you are currently in

Hope you refreshed your memory!

Categories
Linux Tutorial Series

Linux Tutorial Series – 10 – Recap

Here is the video version, if you prefer it:

We have talked about what an operating system is – it is a very useful piece of software which enables you to communicate with the hardware conveniently. We also talked about the kernel and learned that it manages processes, memory, device drivers and system calls, as well as established that users are people that use the computer and each one has (or should have) a user account associated with him/her.

We established that there is a difference between the user space and the kernel space, as well as there being a difference between regular users and superusers. Kernel space is only accessible to the operating system, while the user space is where the user programs reside. Superusers get to execute certain commands that regular users can’t (don’t have the permission to). We learned that a Linux distribution is an operating system made from a software collection that is based upon the Linux kernel.We also talked about some Linux installation details.

Hope this served as a good review!