“Empowering Efficiency: Letting Computers Work for You”

Shrihari Haridas
11 min readApr 1, 2024

--

Introduction:

In today’s digital age, harnessing the power of technology is essential for optimizing productivity. By delegating tasks to computers, individuals can streamline workflows and focus on higher-value activities.

  1. How can you learn about the system or find out more information about
    it?

Ans: You can find this information by navigating to /etc/os-release

2. what is LTS:

Ans: In Ubuntu, LTS stands for Long Term Support. It refers to specific releases of the operating system that receive extended maintenance and security updates for a longer period compared to regular releases.

3. How we know anyone is logged in to the machine or who are the users (someone beside us)

Ans: You can use WHO

4. what command to see what other program are running on system

Ans: “top”

When you use the `top` command, what information do you learn about this computer?

When using the `top` command, you can gather information about CPU and memory utilization, running tasks, CPU usage, system load, and the number of active users.

You can also observe the load average displayed by the `top` command, which consists of three values. These values indicate the system’s load over the last 1 minute, 5 minutes, and 10 minutes, respectively. Understanding these load averages is crucial when working with the system because they provide insights into how busy the system has been over different time intervals, helping you gauge its performance and workload.

5. When using the `top` command, if you want to list or sort processes by memory usage, you can simply press the “M” key.

6. You can also type “1,2,3,4” while using the `top` command. When you press “1”, you’ll be able to view the CPU utilization for each individual core. This is particularly useful if your machine type is “t2.medium”, which typically has a 2-core CPU. However, you might notice that when you run the `top` command, it displays only the usage of the first CPU core by default.

You can also press “h” while using the `top` command to access the help menu and obtain more information about its usage and available commands.

If you type “Z”

So, while many users utilize the `top` command, it’s advantageous to explore its features further to access various perspectives and different views of system performance.

7. Absolutely! The `ps` command, short for “process status,” provides detailed information about running processes on the system. By using arguments like “aux” with `ps`, you can display a comprehensive list of all processes running on the system, along with additional details such as the user who started the process, CPU and memory usage, and the command associated with each process. ”ps aux”

from above image what you get to know or with this output

-> USER: This column shows the username of the owner of the process.

-> PID: This column displays the Process ID, a unique identifier assigned to each running process.

-> %CPU: This column shows the percentage of CPU time used by the process since the last update.

-> %MEM: This column displays the percentage of physical memory (RAM) used by the process.

-> VSZ: This column represents the virtual memory size of the process in kilobytes.

-> RSS: This column shows the Resident Set Size, which is the amount of physical memory (RAM) used by the process in kilobytes.

-> TTY: This column displays the controlling terminal of the process.

-> STAT: This column shows the state of the process. Common states include:

  • R: Running
  • S: Sleeping
  • T: Stopped
  • Z: Zombie (terminated, but parent process has not yet read the exit status)
  • D: Uninterruptible sleep

-> START: This column shows the time when the process started.

-> TIME: This column displays the cumulative CPU time used by the process.

-> COMMAND: This column shows the command that started the process.

want to act like a detective, exploring and scrutinizing every aspect of this computer to uncover all its details.

8. How do we determine if this is running on AWS? You know why? Because…

 ps aux | grep ssm

9. So, as we can see, the top 3 users are listed. How do you verify this? You can use the ‘who’ or ‘last’ command.

The who command displays information about users who are currently logged into the system.

The last command displays information about previous login sessions on the system.

10. The uname command in Linux is used to display basic information about the operating system.

  • Linux: Kernel name.
  • myhostname: Hostname of the system.
  • 5.4.0-91-generic: Kernel release.
  • #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021: Kernel version, including build date.
  • x86_64: Machine hardware architecture.
  • x86_64: Processor architecture.
  • x86_64 GNU/Linux: Operating system type

11. The filesystem used in Linux can vary, but common ones include ext4, XFS, and btrfs. To determine the filesystem of a particular mount point, you can use the “mount” command.

To display information about currently mounted filesystems, you can simply run the “mount” command.

12. The “ll” command is commonly used in Unix-like operating systems, including Linux, to list files and directories in a directory with detailed information such as permissions, ownership, size, and modification time.

“ll” is typically an alias for the “ls -l” command, which achieves the same result.

To determine the location of the file or program associated with the “ll” command, you can use the “which” command. This command will display the full path to the executable file, revealing where it is located in the file system.

If there are multiple Python installations on your machine, the one that gets executed first depends on the order of directories listed in the $PATH environment variable. When you execute a command, the system searches through each directory listed in $PATH from left to right until it finds the first occurrence of the executable file matching the command name.

For example, if you have Python 2 installed in /usr/bin/python2 and Python 3 installed in /usr/bin/python3, and /usr/bin appears before /usr/local/bin in your $PATH, running the command python will execute the Python 2 interpreter.

You can view the contents of the $PATH variable and their order using the command:

echo $PATH

To determine the location of the first occurrence of a command in your $PATH, you can use the which command:

which python

Typically, “ll” is set as an alias for the “ls -l” command to provide a more concise way of listing files with detailed information. You can use the following command to see if “ll” is aliased and what it’s aliased to:

alias ll

In Linux and Unix-like operating systems, an alias is a feature that enables users to create shortcuts or alternate names for commands or command sequences. This functionality is useful for customizing commands, simplifying frequently used commands, or rectifying common typing errors.

Aliases are a tool for personalizing your system to make it more convenient and efficient for your individual needs.

13. now go to /var/log and type “ll -lstr”

In Linux and Unix-like systems, the “lstr” command, when used with its default settings, displays the contents of a file in a long list format with the newest files shown at the bottom. This feature is useful because it provides a quick way to identify the most recently modified files. For example, when monitoring log files like “syslog,” where new lines are typically appended to the end, “lstr” will show the latest information at the bottom of the output.

To view the newest information in a file like “syslog,” you can use commands like “tail syslog” or “head syslog” to respectively display the last or first few lines of the file. Additionally, to view a specific number of lines from the end of the file, you can use “tail -200 syslog” to display the last 200 lines, for instance.

14. So, you can notice that something has occurred, and it’s complaining about it. You might see an error message saying “No EC2 Instance role found.” This error message is trying to indicate what the problem is, but nobody seems to be addressing it.

so lets do something interesting

grep "ERROR EC2RoleProvider" syslog
grep "ERROR EC2RoleProvider" syslog | wc -l

So, in total, there are 108 occurrences where the error message “No EC2 Instance role found” appears when using the “word count” command.

wc syslog

its lines, word, character count in syslog

15. How can we know or check if something bad is happening on the computer? We want to listen to the computer like a doctor. It’s providing a lot of information; how do we need to find out?

Ans: Of course, you can use the `top` command to observe how processes are utilizing the CPU, or you can also use the `htop` command for a more interactive and visually appealing display.

Also, a crucial aspect is to observe what’s happening by accessing the “/var/log” folder, where all system and application logs are stored. Alternatively, you can follow step number 14.

16. The cloud-init-output.log file is an important log file in cloud environments using the cloud-init service. It captures the output of the cloud-init process during the initial configuration of a cloud instance.

more cloud-init-output.log

“less” is more better version the “more” using less you can go forward & backward you can find strings

? key

with “?” you can go backward and using “/” you can go forward and let the computer find it for you

17. Why do people use Microsoft? They handle all this work for computers. Are you working for the computer, or is the computer working for you? Computers excel at repetitive tasks and data processing. Humans are not as adept at that. Humans may not be good at spotting details, but they are capable of learning how to communicate and collaborate with computers. Only then can truly remarkable things be achieved.

18. lets do something interesting type first “ll” and then “ll | sort” you see the difference like when you use the sort, it will sort first collum to you on alphabetical order

ll | awk '{print $3}'

This command will search for lines in `file.txt` containing the word “pattern”, and for each match, it will print the first and second fields of that line.

ll | awk '{print $3}' | sort -u

-u give the unique ones and remove duplicated once. just show me once time

awk is a powerful tool for text processing and is commonly used in shell scripts, one-liners, and in conjunction with other Unix utilities to perform various text manipulation tasks. It offers a wide range of features and can be customized to suit different text processing needs.

19. lets do one interesting thing type “ps aux”

ll 
ll | awk '{print $9}'
ls

So, when you use the “ll” command, it counts the columns, and in awk, I’m printing 9 columns. If you compare the outputs of “ll” and “ls,” you’ll notice they’re the same. This demonstrates that there are often multiple ways to achieve the same result. While some methods may seem more complicated, command-line tools often offer simpler solutions.

so this is a simple version of ll is ls and its gives you only the file name

20. Just because the computer can do the work doesn’t necessarily mean you can make it do the work.

21. You can accomplish many tasks with “awk”; it’s a powerful programming language and an essential tool.

23. Now, suppose you have “n” number of pods in Kubernetes, and you only want to select the running pods. In this case, you can use…

k get pods -A | grep Running

If you want to select pods that are not running in Kubernetes, you can use a single argument after `grep` to filter out every line that indicates a running pod. This would ignore every line mentioning running pods and display only the lines representing pods that are not running.

k get pods -A | grep -v Running

Let’s delegate the task to the computer. If you’re feeling tired, you can instruct the computer to show you the pods but ignore the ones that are running. You can specify that you only want to see the pods that are not running.

Conclusion:
By embracing automation and leveraging the capabilities of modern technology, individuals can unlock new levels of efficiency and productivity. Letting computers do the work allows for greater focus, reduced manual effort, and ultimately, more time to pursue meaningful endeavors.

--

--

Shrihari Haridas

Hello everyone, I am Shrihari Haridas I am a Cloud & DevOps Engineer, I work with most of DevOps Tools like, Jenkins, Git, Docker, etc.!& for Cloud AWS