LINUX - MANAGING LINUX COMPONENTS

Guidelines for Troubleshooting Process Issues

Use the following guidelines when troubleshooting process issues.

TROUBLESHOOT PROCESS ISSUES

When troubleshooting process issues:

  • Gather information about a process, including its process ID (PID) and state.
  • Use ps to print information on all running processes, including CPU usage. For example, a process consuming over 50% of the CPU may cause performance issues, and is worth investigating further.
  • Use top to retrieve a dynamic and interactive list of all running processes.
  • Use systemd-analyze blame to determine what startup processes are slowing down boot operations.
  • Use lsof to identify which processes have open files.
  • Use nice and renice to prioritize certain processes over others.
  • Use fg and bg to manage foreground and background processes.
  • Use nohup to keep a command running even after logging off.
  • Use kill and its associated commands to terminate problem processes.

 

Configuring Localization Options

Scenario

One of your colleagues is located remotely—in London, England. Just like you, he needs to be able to log in to Develetech's Linux servers in order to administrate them. The server he needs to remotely administrate is located in the US, even though it primarily services users in Great Britain. So, you'll set this server to use the time zone in London, as well as change the language and keyboard layout settings to those of Great Britain. This will make it easier for your English colleague to work within the environment and for the server to operate within the correct time zone.

Objectives

Completing this activity will help you to use content examples from the following syllabus objectives:

  • 1.6 Given a scenario, configure localization options

Retrieve your system's current date and time information.

  1. Log in as student01 with Pa22w0rd as the password.

  2. Enter timedatectl to display time configuration information.

  3. Verify that you are given information such as:

    • The local time.
    • The universal time.
    • The real-time clock (RTC) time (i.e., hardware clock).
    • The time zone.
    • Network Time Protocol (NTP) information.
    • Daylight savings time (DST) information.

Find the time zone for London.

  1. Enter timedatectl list-timezones to list the time zones.

  2. Verify that there are several pages of time zones available.

    Time zones are categorized by global region, then typically by city or small nation. This information is pulled from the time zone files and directories in /usr/share/zoneinfo

  3. Press q to quit and return to the prompt.

  4. Enter timedatectl list-timezones | grep London to filter the results.

    The relevant time zone is in the format Europe/London.

  5. Enter sudo timedatectl set-timezone Europe/London to change the time zone to London's current time zone.

  6. Enter timedatectl again to display the updated time configuration information.

  7. Verify that the time zone has changed and that the local time reflects this change.

    The time zone that is set will depend on the time of year. From the last Sunday in March to the last Sunday in October, the time zone will be British Summer Time (BST). The rest of the year, London is on Greenwich Mean Time (GMT), otherwise referred to as UTC.

  8. Verify that the universal time is either the same as the local time or is one hour behind, depending on the time of year.

    The universal time is synonymous with GMT/UTC and is used as a global reference point.

  9. Examine the RTC time.

    This is the hardware clock, and it is set by the OS. Many Linux distros set this to UTC by default, including CentOS. You'll leave this as-is.

  10. Enter date to confirm the date and time on the system.




Find the appropriate locale settings for Great Britain.

  1. Enter localectl status and note your system's current language locale and keyboard layout.

    Take note of these values if your locale and keyboard layout are not US. You will need to revert to these values at the end of the activity.

  2. Enter localectl list-locales to display available locale information.

  3. Page through the list of available locales until you get to the locales that start with en_ (English language).

  4. Find the en_GB.utf8 locale.

    This is a locale for Great Britain that uses UTF-8 encoding.

  5. Press q to quit.

  6. Enter localectl list-keymaps to display keyboard mapping information.

  7. Verify that you can find a keyboard layout named gb indicating Great Britain.

Configure the appropriate locale settings for Great Britain.

  1. Enter sudo localectl set-locale "LANG=en_GB.utf8"

  2. Enter sudo localectl set-keymap gb

  3. Enter localectl status and verify that the language locale and keyboard layout are both set to Great Britain.

  4. On your keyboard, press the Backslash key and verify that it types a number symbol (#).

    This is due to layout differences between US and GB/UK keyboards.

    This will, of course, only work if you're using a US keyboard.

For classroom purposes, revert the locale settings.

  1. Enter sudo localectl set-locale "LANG=en_US.utf8"

    Press the Up Arrow until you retrieve the command you used to set the locale to Great Britain. Then you can just replace the text.

    If your original language and keyboard layout are something other than US, you will need to enter your original values instead.

  2. Enter sudo localectl set-keymap us

  3. Enter localectl status and verify that the original locale options are set.


Managing Services

Scenario

As a Linux administrator at Develetech, you know that you will be implementing, managing, and reconfiguring different services. You'll be leveraging systemd, and in particular, the systemctl command and its associated subcommands, to manage these services. You decide to start by switching targets from CLI to GUI, and then making the default target GUI so that users will always boot into that environment by default. Then, you'll practice managing the SSH and firewall services by putting them through the service management lifecycle of starting, stopping, enabling, and disabling them.

Objectives

Completing this activity will help you to use content examples from the following syllabus objectives:

  • 2.4 Given a scenario, manage services

Verify that your system is using systemd and not the older SysVinit method.

  1. In the terminal window, enter ps -e | grep -i init to check for the init process.

  2. Verify that the init process was not found.

  3. Enter ps -e | grep -i systemd to check for the systemd process.

  4. Verify that the systemd process was found and has a process ID of 1.

    wqc5h7d0.jpg

    If PID 1 is init, then the system is using the older SysVinit startup method. If PID 1 is systemd, then the system is using the newer method.

View the target files that specify the services that will start when the system starts

  1. Enter cat /usr/lib/systemd/system/multi-user.target

    Observe that the multi-user.target requires the basic.target—i.e., the target files build upon each other.

  2. Enter cat /usr/lib/systemd/system/graphical.target

    Observe that the graphical.target requires the multi-user.target—this further illustrates how the target files build on each other. In addition, the graphical.target calls or "wants" the display-manager.service, which initiates the GUI.

  3. Enter systemctl --type=service to view the current target's services.

  4. Press q when you're finished.

Switch between the CLI target and the GUI target, then set the GUI target as the default.

  1. Enter sudo systemctl isolate multi-user.target to switch back to the command-line interface.

  2. Sign in as student01 using Pa22w0rd as the password.

  3. Enter sudo systemctl isolate graphical.target to switch to the graphical user interface.

  4. Sign in as student01 and open a terminal.

  5. Enter sudo systemctl set-default graphical.target to set the GUI as the default environment.

Examine the systemctl subcommands.

  1. Type systemctl and then type a space, and then press Tab twice.

    You can use this trick with some commands to list all of their available subcommands.

    Be sure to add a space after the command and before pressing Tab.

    Note the stop, start, restart, status, enable, and disable subcommands in particular.

Manage the SSH service on your server.

  1. Enter sudo systemctl status sshd.service to check the status of sshd.

  2. Verify that the sshd service is running.

    cxt8h726.jpg

  3. Enter sudo systemctl stop sshd.service to stop the SSH service.

  4. Verify that the sshd service is stopped.

    qm7zcf91.jpg

  5. Enter sudo systemctl start sshd.service to start the sshd service again, then check its status to ensure it is running.

Disable, and then re-enable, the firewalld service.

  1. Enter sudo systemctl status firewalld.service to verify the status of the firewalld service.

  2. Verify that the firewalld service is running.

  3. Enter sudo systemctl disable firewalld.service to disable the firewalld service.

  4. Verify that the firewalld service is still running.

    The enable and disable subcommands do not affect the current status of the service, but rather the startup status.

  5. Reboot the server, log back in to the GUI with your student01 account, and verify that the firewalld service is not running.

  6. Start the firewalld service again.

  7. Use the systemctl command to enable the firewalld service.

Troubleshooting Process Issues

Scenario

Some users have complained that processes on the Linux server are taking longer than normal to complete. You discover several processes that are not needed are still running and were never successfully terminated. You need to manage the system processes and the processes issued by other users. In addition, you'll see if there are any problem processes that are consuming too many resources or are causing delays in the boot process.

Objectives

Completing this activity will help you to use content examples from the following syllabus objectives:

  • 4.2 Given a scenario, analyze system properties in order to optimize performance

  1. Enter ps to list only the processes running on the current terminal.

  2. Verify that only the processes started by your account are listed.

  3. Enter ps -e to list all the processes running on the system.

  4. Verify that more processes are listed as compared to the output of the standard ps command.

Discover the process ID number of a process for which you know the name.

  1. Enter pgrep sshd to display the PID for the sshd service.

    Note the process ID number of the sshd service.

Issue a background command.

  1. Enter sleep 300 & to pause the system for 300 seconds.

  2. Enter the PID of the sleep 300 & command in the text box below:

  3. Enter ps to display the processes running under your account.

  4. Verify that the sleep command is in the list of running processes.

Terminate the sleep command.

  1. Enter kill 18014 by using the PID for the sleep command.

  2. Enter ps to check the status of the sleep command.

  3. Verify that the sleep command is not in the list of running processes.

Explore more process information with the top command.

  1. Enter top to open the process management tool.

  2. Press M to reorganize the output by memory usage.

  3. Press P to reorganize the output by CPU usage.

  4. Press q to exit the top program.

  5. Discover what files are open, and which processes opened them.

  6. Enter lsof

  7. Enter lsof -u student01 to see files opened by a specific user.

View boot performance information.

  1. Enter systemd-analyze

    The results of the systemd-analyze command break the startup process into three parts: how long it took the kernel to start, how long it took the initrd image to load, and how long user startup applications and services took to start. The command also shows the total amount of time the startup took. This information can be used in troubleshooting long startup times.

  2. Enter systemd-analyze blame to see which processes take the longest to start during boot.

  3. Press q.

Troubleshooting CPU and Memory Issues

Scenario

You want to identify some basic tools to help manage system components. Specifically, you'll review processor and memory usage to see if the results match expected performance.

Objectives

Completing this activity will help you to use content examples from the following syllabus objectives:

  • 4.1 Given a scenario, analyze system properties and remediate accordingly

Gather information on the CPU.

  1. Enter less /proc/cpuinfo to display processor information.

  2. Press q to quit.

  3. Enter uptime to see how long the system has been up and view basic performance information on the CPU.


Use sar to gather system information.

  1. Enter sar -u to retrieve basic performance information.

  2. Enter sar 2 6 to retrieve information every two seconds, for a total of six queries.

  3. Enter sar -S to retrieve swap space usage information.

Gather information on system memory.

  1. Enter less /proc/meminfo to display memory information.

  2. Press q to quit.

  3. Enter free to gather basic memory usage information.

  4. Enter free -m to see the memory usage measured in megabytes.

  5. Enter free -h to see memory usage in human-readable format.

Use the vmstat command to gather virtual memory usage information.

  1. Enter vmstat 5 3 and wait for the report to finish.

  2. Enter vmstat -d 5 3 to see the information organized on a per-storage device basis.

Use the vmstat command to gather virtual memory usage information.

  1. Enter vmstat 5 3 and wait for the report to finish.

  2. Enter vmstat -d 5 3 to see the information organized on a per-storage device basis.





Comments

Popular posts from this blog

Install Gophish and Start Your Phishing Campaign

[LINUX] - SECURING LINUX SYSTEMS

Hướng dẫn cách đọc và hiểu thông số firewall - tường lửa