Software Engineer should know Unix


Introduction

Let’s continue on the topic of things that a software engineer should know. Today, we are going to talk a little about Unix and we can tag this article part of Operating Systems.

Unix originated in the 1970s at AT&T’s Bell Labs as a simplified alternative to the complex Multics operating system. The original Unix combined a kernel with essential user-space utilities and became influential when AT&T, restricted from commercializing Unix due to antitrust rules (AT&T was a monopoly in Telecom back then and was not allowed to sell Software), freely distributed its source code to universities and researchers. The University of California, Berkeley modified this code to create BSD (Berkeley Software Distribution), adding innovations like TCP/IP networking and the vi editor. Meanwhile, AT&T’s own Unix evolved into System V, a commercial product, which led to competing Unix variants like SunOS and Microsoft XENIX.

To address this growing fragmentation, standardization efforts emerged — notably POSIX (an IEEE standard) and the Single UNIX Specification, overseen by The Open Group, which also manages the UNIX trademark. While traditional Unix systems like macOS, BSD variants, and Oracle Solaris retain ties to original Unix code, Linux emerged independently in the early 1990s as a new kernel designed for Intel PCs. Although Linux contained no Unix code, combining it with GNU’s (GNU is not Unix) user-space tools created GNU/Linux, which mimicked Unix behavior closely and became the dominant Unix-like platform.

Today, macOS is a certified UNIX system under The Open Group’s standards, while GNU/Linux and BSD systems are technically Unix-like but widely accepted as part of the broader Unix ecosystem. Despite these distinctions, many people casually refer to all POSIX-compliant systems as “Unix,” given their shared features and compatibility.

So if you learn basics of Unix, you can work on any Unix like system and currently Linux and MacOS are the most popular Unix like systems.

What constitutes Unix?

  • Kernel: The core of the Unix operating system, responsible for managing hardware resources and providing essential services to user-space programs.
  • User-space utilities: A collection of command-line tools and applications that interact with the kernel to perform tasks like file management, process control, and network communication.
  • Shell: A command-line interpreter that allows users to interact with Unix systems by typing commands and executing scripts. Popular Unix shells include sh, csh, ksh, bash, and zsh.
  • Filesystem: A hierarchical structure for organizing files and directories, with a root directory (/) at the top. Unix filesystems support symbolic links, permissions, and other advanced features. The most common filesystems are UFS, ZFS, and ext4.
  • System Utilities: A set of programs that manage system resources, configure hardware, and perform administrative tasks. Examples include init, systemd, cron, and syslog. Core system utilities are typically located in /bin, /sbin, and /usr/sbin directories.
  • Development Tools: Compilers, interpreters, and libraries for building software on Unix systems. Popular tools include gcc, make, gdb, and autotools. Development tools are typically located in /usr/bin and /usr/local directories. gcc, make, gdb, and autotools are some of the popular development tools.
  • Networking: Protocols and utilities for connecting Unix systems to networks and the internet. Unix systems support TCP/IP networking, DNS resolution, and network services like SSH, FTP, and HTTP. ping, ifconfig, netstat, ssh, ftp, and curl are some of the popular networking tools.
  • Text Processing Tools: Utilities for manipulating text files and streams, including searching, filtering, and transforming data. Popular text processing tools include grep, sed, awk, and sort. grep, sed, awk, and sort are some of the popular text processing tools.
  • User Management: Tools for creating, modifying, and deleting user accounts on Unix systems. User management utilities include useradd, usermod, userdel, and passwd. useradd, usermod, userdel, and passwd are some of the popular user management tools.
  • Disk Management: Utilities for managing disk partitions, filesystems, and storage devices on Unix systems. Disk management tools include fdisk, mkfs, mount, and df. fdisk, mkfs, mount, and df are some of the popular disk management tools.
  • Process Management: Tools for monitoring, controlling, and interacting with processes running on Unix systems. Process management utilities include ps, top, kill, and nice. ps, top, kill, and nice are some of the popular process management tools.
  • Daemon Management: Utilities for managing background services and daemons on Unix systems. Daemon management tools include systemctl, service, and init.d scripts. systemctl, service, and init.d are some of the popular daemon management tools.
  • Inter Process Communication: Mechanisms for communication between processes on Unix systems, including pipes, signals, sockets, and shared memory. Inter-process communication tools include pipe, signal, socket, and shm. pipe, signal, socket, and shm are some of the popular inter-process communication tools.
  • Documentation: Manuals, guides, and documentation for Unix systems. man, info, and help are some of the popular documentation tools.

many others which I am not aware of and at this point in time it is hard to distinguish if they are part of Unix or Unix compliant systems but you get the idea.

Basic Unix Commands

As you start working with Unix, you will find that you use some commands more frequently than others. Some of the most common Unix commands include:

  • ls: List directory contents.
  • cd: Change the current directory.
  • pwd: Print the current working directory.
  • mkdir: Create a new directory.
  • rmdir: Remove an empty directory.
  • cp: Copy files and directories.
  • mv: Move or rename files and directories.
  • rm: Remove files and directories.
  • cat: Concatenate and display file contents.
  • more: Display file contents one screen at a time.
  • less: Display file contents with advanced features.
  • head: Display the beginning of a file.
  • tail: Display the end of a file.
  • grep: Search for patterns in files.
  • find: Search for files and directories.
  • chmod: Change file permissions.
  • chown: Change file ownership.
  • ps: Display information about processes.
  • kill: Terminate processes.
  • top: Display system resource usage.
  • df: Display disk space usage.
  • du: Display directory space usage.
  • tar: Create and extract tar archives.
  • gzip: Compress and decompress files.
  • ssh: Securely connect to remote systems.
  • scp: Securely copy files between systems.
  • sync: Synchronize cached writes to disk.
  • rsync: Synchronize files between systems.
  • wget: Download files from the internet.
  • curl: Transfer data with URLs.
  • man: Display manual pages.
  • info: Display information pages.
  • apropos: Search manual pages.
  • whatis: Display one-line manual page descriptions.
  • history: Display command history.
  • alias: Create command aliases.
  • export: Set environment variables.
  • echo: Display messages.
  • date: Display or set the system date and time.
  • cal: Display a calendar.
  • bc: Perform arithmetic calculations.
  • wc: Count lines, words, and characters.
  • sort: Sort lines of text.
  • uniq: Remove duplicate lines.
  • cut: Extract columns from text.
  • paste: Merge lines of text.
  • sed: Stream editor for text.
  • awk: Pattern scanning and processing language.
  • diff: Compare files line by line.
  • patch: Apply changes to files.
  • tar: Create and extract tar archives.
  • gzip: Compress and decompress files.
  • bzip2: Compress and decompress files.
  • zip: Compress and decompress files.
  • unzip: Extract files from a ZIP archive.
  • file: Determine file type.
  • stat: Display file status.
  • ln: Create links between files.
  • mount: Mount filesystems.
  • umount: Unmount filesystems.
  • df: Display disk space usage.
  • du: Display directory space usage.
  • fdisk: Partition table manipulator.
  • mkfs: Create a filesystem.
  • fsck: Filesystem consistency check.
  • dd: Convert and copy files.
  • lsof: List open files.
  • netstat: Display network connections.
  • ss: Display socket statistics.
  • ping: Test network connectivity.
  • traceroute: Display network path to a destination.
  • dig: DNS lookup utility.
  • host: DNS lookup utility.
  • whois: Display domain registration information.
  • ifconfig: Configure network interfaces.
  • route: Display or modify the IP routing table.
  • iptables: Configure firewall rules.
  • systemctl: Manage system services.
  • service: Manage system services.
  • ps: Display information about processes.
  • top: Display system resource usage.
  • kill: Terminate processes.
  • nice: Set process priority.
  • renice: Change process priority.
  • jobs: Display background jobs.
  • bg: Move a job to the background.
  • fg: Move a job to the foreground.
  • cron: Schedule periodic tasks.
  • at: Schedule one-time tasks.
  • systemd: Manage system services.
  • init: System initialization process.
  • shutdown: Shut down the system.
  • reboot: Restart the system.
  • halt: Halt the system.
  • poweroff: Power off the system.
  • uname: Display system information.
  • hostname: Display or set the system hostname.
  • uptime: Display system uptime.
  • dmesg: Display kernel messages.
  • lsmod: Display loaded kernel modules.
  • modprobe: Load and unload kernel modules.
  • insmod: Load kernel modules.
  • rmmod: Unload kernel modules.
  • lsblk: List block devices.
  • blkid: Display block device attributes.

It’s not easy to remember all these commands and I know I have listed far too many but you don’t need to remember them get go but as you start using them and solve problems using them, you will remember them and you will be able to use them effectively in your daily work.

Even if you don’t remember all of them, you can always refer to the manual pages using the man command. For example, to learn more about the ls command, you can type man ls in the terminal to display the manual page for ls. The manual pages provide detailed information about each command, including its usage, options, and examples. I often use curl cheat.sh/command to get a quick help on a command. For example, curl cheat.sh/ls will give you a quick help on ls command. You can also use tldr which is a simplified and community-driven.

You can refer to the Unix Toolbox and TLDR Pages for more examples and explanations of common Unix commands. I think going through Linux Journey is also a good way to learn Unix.

Benefits of Learning Unix

First and foremost, your familiarity with Unix will make you more versatile and adaptable as a software engineer. Unix-like systems are prevalent in the tech industry, powering servers, workstations, and embedded devices across a wide range of applications. By mastering Unix, you’ll be well-equipped to work with these systems and leverage their capabilities to build, deploy, and maintain software effectively. You’ll also gain a deeper understanding of operating system concepts, file systems, networking, and security, which are essential for developing robust and reliable software. Finally, learning Unix will enhance your problem-solving skills, as you’ll become proficient at using command-line tools, shell scripts, and system utilities to diagnose issues, automate tasks, and optimize performance. I don’t think I am doing justice to Unix by listing these benefits but I hope you get the idea. Once you are able to write some shell scripts, you will be able to automate a lot of tasks and that will save you a lot of time. Overall, Unix is a fundamental skill that every software engineer should know, and mastering it will open up new opportunities for growth and success in your career.

Conclusion

In conclusion, Unix is a powerful and versatile operating system that plays a crucial role in the tech industry. By learning Unix, you’ll gain valuable skills and knowledge that will benefit you throughout your career as a software engineer. Whether you’re working on servers, desktops, or embedded devices, Unix will provide you with the tools and capabilities you need to succeed. So take the time to explore Unix, experiment with its features, and practice using its commands and utilities. You’ll be amazed at how much you can accomplish with this powerful operating system.

Version History:
- 1.0: Initial Post