Page 42 - Raspberry Pi as a Foundation for Boosting Computer and Technology Literacy
P. 42

3  Fundamentals of the Linux system and terminal usage

                Table 3.3  Frequently used commands for system monitoring
                Command                        Description
                ps                             List all running processes
                killall                        Kill process by name
                df                             Get info on mounted file systems
                free                           Get info on free and used memory
                top                            Display Linux processes
                htop                           Enhanced version of top


                  Killing a process without running a CLI program can also be very
                useful, particularly if it is part of a chain of other commands or within
                a shell script.
                  ps -u -x
                  killall lxterminal
                  This can be accomplished by first running a ps command with the
                -u and -x flags to display all processes belonging to the current user.
                Then, find the name of the process inside the output (e.g. “lxterminal”)
                and pass it as an argument to the killall command to terminate it.
                  Above are some of the frequently used commands for managing
                processes, monitoring CPU and RAM usage, and checking mounted
                storage (Table 3.3).

                Network commands
                A very popular way to check if a device is connected to the Internet or
                if a specific website is currently available is to use the ping command.
                For instance, one could try to ‘ping’ a Google server:

                  ping google.com
                  Thus, if the command returns successful ‘pings’, which are small in-
                dividual packets of data, then the website is available, and the device
                has access to the Internet (Figure 3.16).
                  In table 3.4 are some of the frequently used commands related to
                connectivity and networks.







                Figure 3.16  Example of the ping command


                            42
   37   38   39   40   41   42   43   44   45   46   47