My Cloud Journey — Week 2: Exploring Linux Operating Systems

Asif Khan - Oct 1 - - Dev Community

Introduction

Welcome to the second week of my journey into the realm of cloud computing. This week, I learned about the world of Linux, an operating system renowned for its robustness, flexibility, and open-source nature. My focus will be on understanding the Linux command line by mastering essential commands, and exploring fundamental concepts that form the backbone of Linux systems.

Most Essential Linux Commands

1. whoami

This command prints the username of the current user. It's a quick way to verify your user identity, especially when working with multiple user accounts.

2. man

The manual (man) command displays the user manual of any command you run. For example, man ls will show the manual for the ls command. It's an invaluable resource for understanding command usage, options, and examples.

3. clear

Clears the terminal screen, providing a clean slate for new commands and output.

4. pwd

Prints the current working directory, showing the full path to your present location in the filesystem.

5. ls

Lists the contents of a directory. With various options, you can modify the output to show hidden files ls -a, detailed file information ls -l, and more.

6. cd

Changes the current directory. For example, cd /home will move you to the /home directory.

7. mkdir

Creates a new directory. For instance, mkdir projects creates a directory named "projects".

8. touch

Creates an empty file or updates the timestamp of an existing file. Example: touch file.txt

9. rmdir

Removes an empty directory. If the directory contains files, you must delete them first or use rm -r to remove the directory and its contents.

10. rm

Removes files or directories. Use caution with this command, especially with the -r (recursive) option, as it can delete entire directories and their contents.

11. open (xdg-open [filename])

Opens a file or URL using the default application associated with it. This command is handy for opening documents, images, and web links directly from the terminal.

12. mv

Moves or renames files and directories. For example, mv file.txt /home/user/docs moves 'file.txt' to the specified directory.

13. cp
Copies files or directories. The -r option allows you to copy directories recursively.

14. head

Displays the first few lines of a file. By default, it shows the first 10 lines, but you can specify the number of lines to display with the -n option.

15. tail

Shows the last few lines of a file. Similar to head, you can use the -n option to specify the number of lines.

16. date

Displays or sets the system date and time. For example, dateshows the current date and time.

17. > (redirecting + overwrite)

Redirects the output of a command to a file, overwriting the file if it exists. Example: echo "Hello World!" > file.txt .

18. >> (redirecting + appending)

Redirects the output of a command to a file, appending to the file if it exists. Example: echo "New Line" >> file.txt .

19. cat

Concatenates and displays the content of files. It's often used to quickly view file contents.

20. less

Allows you to view the content of a file one screen at a time, making it easier to read large files.

21. echo

Displays a line of text or variable value. It's commonly used in scripts to output messages or variable values.

22. wc

Prints the number of lines, words, and characters in a file. Useful for counting text data.

23. | (Piping)

Pipes the output of one command as input to another command. For example, ls | grep txt filters the ls output to show only files containing "txt".

24. sort

Sorts lines of text in files. It can sort alphabetically or numerically, depending on options used.

25. diff

Compares two files line by line, showing differences between them. Useful for finding changes in configuration files or source code.

26. grep

Searches for patterns in files. For example, grep "error" logfile.txt finds all occurrences of "error" in the specified file.

27. du

Displays disk usage of files and directories. The -h option provides human-readable output (e.g., KB, MB, GB).

28. df

Reports the amount of disk space used and available on filesystems. The -h option provides human-readable output.

29. history

Shows a list of previously executed commands. You can re-run commands from this history using ! followed by the command number.

30. ps

Displays information about currently running processes. The aux options provide detailed process information.

31. top

Provides a dynamic, real-time view of system processes, including CPU and memory usage.

32. kill

Terminates a process by its process ID (PID). For example, kill 1234 stops the process with PID 1234.

33. killall

Terminates all processes matching a specified name. For example, killall firefox stops all instances of Firefox.

34. gzip

Compresses files using the GNU zip algorithm, reducing file size. For example, gzip file.txt creates file.txt.gz.

35. tar

Archives multiple files into a single file. It can also compress archives. For example, tar -czvf archive.tar.gz /path/to/directory creates a compressed archive.

36. nano

A simple, user-friendly text editor for the terminal. It's great for quick edits and scripting.

37. alias

Creates shortcuts for commands. For example, alias ll='ls -la' creates a shortcut ll for ls -la.

38. xargs

Constructs argument lists and executes commands. It's useful for passing multiple items as arguments to a command.

39. ln

Creates links between files. The -s option creates symbolic (soft) links, which are shortcuts to the target file.

40. who

Displays who is currently logged into the system, providing information about active users.

41. su

Switches to another user account. For example, su switches to the root user.

42. sudo

Executes commands with superuser privileges, allowing authorized users to perform administrative tasks.

43. passwd

Changes user passwords. For example, passwd changes the password for the current user.

44. chown

Changes file ownership. For example, chown user:group file.txt changes the owner and group of file.txt.

45. jobs, fg, bg

jobs: Lists background jobs.
fg: Brings a background job to the foreground.
bg: Sends a foreground job to the background.

File Permissions

1. chmod

Changes file permissions. Permissions are represented as read (r), write (w), and execute (x). For example, chmod 755 file.txt sets read, write, and execute permissions for the owner, and read and execute permissions for others.

🔵Linux Fundamentals

📁 Directories Structure

Understanding the Linux directory structure is crucial for efficient navigation and file management. Key directories include:

/bin: Essential user command binaries (e.g., ls, cp , mv).
/boot: Boot loader files and kernels.
/dev: Device files (representing hardware devices).
/etc: Host-specific system-wide configuration files.
/home: User home directories.
/lib: Essential shared libraries and kernel modules.
/media: Mount point for removable media (e.g., USB drives).
/mnt: Temporarily mounted filesystems.
/opt: Optional application software packages.
/proc: Virtual filesystem providing process and kernel information.
/root: Home directory for the root user.
/run: Runtime data for processes started since the last boot.
/sbin: System binaries (e.g., fdisk, ifconfig, iptables).
/srv: Data for services provided by the system.
/sys: Virtual filesystem providing information about devices, drivers, and kernel features.
/tmp: Temporary files (usually cleared on reboot).
/usr: Secondary hierarchy containing read-only user data and programs.
/var: Variable data (e.g., logs, databases, mail).

Understanding this structure is crucial for efficient system navigation and management.

💿 Installation

I practiced installing Linux both on a virtual machine using VMware and directly on a host system. This hands-on experience is invaluable for understanding system setup and configuration. The process involves downloading a Linux distribution ISO, creating a virtual machine, and following the installation prompts.

🔧 Boot Process

The Linux boot process involves several stages:

  • BIOS/UEFI: Power-on self-test (POST) initializes hardware and locates bootloader.
  • Bootloader (GRUB): Loads Linux kernel from disk into memory.
  • Kernel Initialization: Mounts the root filesystem (initrd if used), starts init process.
  • Init Process: Executes startup scripts (rc scripts or systemd units).
  • Runlevel or Target: Switches to default runlevel or target (e.g., multi-user.target).
  • Service Initialization: Starts essential system services (e.g., networking, logging).
  • User Login: Displays login prompt or starts graphical environment (X server or Wayland).
  • User Session: Loads user-specific configurations and applications.

Understanding File Permissions

Types of Permissions

  1. Read (r): Allows reading of the file's contents or viewing of a directory's contents.
  2. Write (w): Allows modifying or deleting the file, or adding/removing files within a directory.
  3. Execute (x): Allows executing the file as a program or script, or entering (accessing) a directory.

File permissions control who can read, write, or execute a file. Permissions are set for three groups: owner, group, and others.
Here's what each part of -rw-r - r - represents:

  • The first character (-) indicates the file type (- for a regular file).
  • The next three characters (rw-) represent the owner's permissions (read and write).
  • The next three (r - ) represent the group's permissions (read only).
  • The last three (r - ) represent others' permissions (read only).

Package Management

I explored various package managers, anaging software packages is essential for system maintenance. Different distributions use different package managers:

  • APT (Debian/Ubuntu): sudo apt update and sudo apt install [package-name].
  • PACMAN (Arch-based systems): sudo pacman -Syu and sudo pacman -S [package-name].
  • DNF (Fedora): sudo dnf update and sudo dnf install [package-name].
  • FLATPAK & SNAP: Universal package formats that work across different distributions.

These tools simplify software installation, updates, and removal, which is crucial for maintaining cloud systems.

🖥️ Linux Distributions and Desktop Environments

To gain a comprehensive understanding of the Linux ecosystem, I experimented with multiple distributions:

Distributions: Debian, Ubuntu (Unity, Studio, Server), elementary OS, Linux Mint, Pop! OS, Kali Linux, MX Linux, Arch Linux, EndeavourOS, Garuda Linux, Manjaro OS, Fedora, CentOS, and openSUSE Tumbleweed.

Each distribution has its unique characteristics, package management systems, and target use cases. This exploration helps in choosing the right distribution for specific cloud infrastructure needs.

My favourite is the Arch Linux due to its complexity and GNOME Desktop Enviornment.

I also experimented with various desktop environments:

  • Cinnamon: Known for its traditional desktop metaphor and customizability.
  • GNOME: A modern, minimalist desktop environment focused on simplicity.
  • KDE Plasma: Highly customizable and feature-rich.
  • XFCE: Lightweight and fast, ideal for older hardware.
  • Hyprland: A dynamic tiling Wayland compositor, offering a unique approach to window management.

Understanding these environments is crucial for setting up user-friendly cloud workstations and remote desktops.

Conclusion

Week 2 has provided a solid foundation in Linux, covering essential commands, understanding the directory structure, mastering file permissions, and exploring various distributions and desktop environments. This knowledge is crucial for anyone aspiring to become a proficient cloud architect. Linux has been a eye opener to me. The versatility and power of Linux make it an ideal platform for cloud computing.

Next week, I plan to explore virtualization, another fundamental of cloud computing.

I'm excited to continue this journey and see how our Linux knowledge translates into cloud architecture. If you have any questions about this week's topics or suggestions for future discussions, please share them in the comments below!
Until next week, keep exploring the vast world of Linux!

Asif Khan - Aspiring Cloud Architect | Weekly Cloud Learning Chronicler

LinkedIn/Twitter/GitHub

. . . . . . . . . . . . . . . . . . . . . .