What is Linux?
Linux is an open-source operating system (OS) similar to Windows and macOS. Here’s a breakdown of what that means:
- Operating System (OS): Linux is the software underneath all the other programs on your computer, managing the communication between hardware (like CPU, memory, storage) and software applications. It’s the foundation that makes everything work together.
- Open-source: The source code for Linux is freely available for anyone to see, modify, and distribute. This openness fosters a large community of developers who contribute to its improvement and create various versions of Linux tailored to different needs.
Here are some critical characteristics of Linux:
- Free and open-source: As mentioned earlier, Linux is free to use and modify, making it a cost-effective and customisable option.
- Security: Linux is known for its significant features and permission systems, making it less vulnerable to malware than other operating systems.
- Stability: Linux is known for its strength and uptime. Servers running Linux often go for months or even years without needing a reboot.
- Versatility: Linux powers various devices, from personal computers to supercomputers, servers, and even embedded systems like routers and smartwatches. Android’s most popular mobile operating system is based on the Linux kernel.
While the technical term “Linux” refers to the core component (the kernel), most people use it to refer to the entire operating system experience, which typically includes a desktop environment, utilities, and applications. Many different versions of Linux, called distributions (distros), cater to various user needs and preferences. Some popular distros include Ubuntu, Mint, Fedora, and Debian.
How can you list all processes running longer than an hour in Linux?
Here’s how you can list all processes that have been running longer than an hour in Linux:
ps -eo pid,etimes,command | awk '$2 > 3600'
![AWK-List-Process-KrishnaG-CEO](http://64.227.143.152/wp-content/uploads/2024/03/AWK-List-Process-KrishnaG-CEO-1024x650.webp)
Explanation:
ps
: This is the command used to display information about running processes.e
: This option tellsps
to list all processes (not just those for the current terminal).o
: This option allows us to specify the output format forps
.pid
: This specifies the process ID (identifier).etimes
: This specifies the elapsed time since the process started, in seconds.command
: This specifies the command name and its arguments.awk
: This is a pattern-scanning and processing language used to filter the output ofps
.$2
: This refers to the second column in the output ofps
(the elapsed time).> 3600
: This compares the elapsed time with 3600 seconds (1 hour).print $0
: This prints the entire line if the elapsed time exceeds 1 hour.
Alternatively, you can shorten the command to:
ps -eo pid,etimes,command | awk '$2 > 7200 {print}'
![AWK-PID-KrishnaG-CEO](http://64.227.143.152/wp-content/uploads/2024/03/AWK-PID-KrishnaG-CEO-1024x650.webp)
This achieves the same result but uses a different awk
syntax.
Understanding the output:
The command will print lines with the process ID (PID), elapsed time (in seconds), and the command name for all processes that have been running longer than an hour.
UNIX – The OS is a family of multitasking, multi-user computer operating systems. It’s considered the grandparent of many operating systems we use today, including Linux. Here’s a breakdown of UNIX:
- Origin: Developed in the late 1960s at Bell Labs by Ken Thompson, Dennis Ritchie, and others.
- Multitasking and Multi-user: UNIX allows multiple programs to run and support multiple users simultaneously on a single system. This was a significant improvement compared to its predecessors.
- Command-line Interface (CLI): Traditionally, UNIX has relied on a text-based command-line interface (CLI) for users to interact with the system. While some versions now offer graphical user interfaces (GUIs), the CLI remains a core aspect of UNIX.
- Modular Design: UNIX is built on a modular design philosophy. The system’s core is the kernel, which manages hardware resources like memory and processors. Small, specialised programs that work together provide the rest of the functionalities. This modularity makes UNIX flexible and powerful.
- Open Source vs. Proprietary: Both UNIX open-source and proprietary versions are available. The original AT&T UNIX was proprietary, but its influence led to the development of free and open-source variants like Linux and BSD.
While Linux is often referred to as a type of UNIX, it’s technically an open-source implementation inspired by the core philosophies of UNIX. There are also other commercially available UNIX variants like Solaris and HP-UX.
Here’s a breakdown of the critical differences between UNIX and Linux:
![UNIX-Linux-KrishnaG-CEO](https://krishnag.ceo/wp-content/uploads/2024/03/UNIX-Linux-KrishnaG-CEO-jpg.webp)
- Source Code:
- UNIX: Mostly proprietary. Different vendors (like HP, IBM, and Oracle) have their versions with their licensing terms.
- Linux: Open-source. The source code is freely available for the public to see, modify, and distribute. This openness is a significant strength of Linux.
- Cost:
- UNIX: Requires a license to use, which can be expensive depending on the vendor and version.
- Linux: Free to use and distribute.
- Development:
- UNIX: Developed and maintained by individual vendors.
- Linux: Developed by a large community of programmers around the world. This collaborative approach fosters faster innovation and broader adaptation.
- User Interface:
- UNIX: Traditionally focused on the command-line interface (CLI). While some versions offer GUIs, the CLI remains central.
- Linux: Offers a broader range of choices. Many Linux distributions come with user-friendly graphical desktops (like GNOME and KDE) alongside the command line.
- Usage:
- UNIX: Primarily used in high-end servers and workstations due to its stability and security.
- Linux: More versatile. It is used on servers, desktops, and embedded systems (like routers) and even forms the foundation for Android, the most popular mobile OS.
Here’s an analogy: Think of UNIX as a recipe book with specific instructions and ingredients controlled by a single chef (the vendor). Linux is like an open-source cookbook where anyone can contribute recipes (code), leading to a wider variety of dishes (distributions) tailored to different tastes (user needs).