Understanding the Differences Between Linux and RTOS

Follow+Star Public Account Number, don’t miss out on exciting content

Understanding the Differences Between Linux and RTOS

Author | arvin
Source | CSDN (ID: CSDNnews)

Do you know which operating system is the most popular in the world? It is Linux! It generally runs on servers and supercomputers, and the millions of servers behind the websites we access daily are likely running Linux. In this article, we will learn what Linux is, where it comes from, commonly used Linux knowledge, and the commands you need to navigate this exciting platform.

1

What is Linux?
Like Windows or Apple’s macOS, Linux is also an operating system. An operating system is a collection of software that manages different devices and application software on a computer. For example, some of the software is responsible for shutting down and starting the computer, while other software provides an interface for interaction with devices like keyboards and mice.

Learning to use the Linux system is a great opportunity to familiarize yourself with the command line, which is the most straightforward way to communicate with a computer. Additionally, as you try different projects, you will learn about software repositories, package management, file permissions, user management, and more. If you have experience with npm and GitHub, then package management and software repositories may already be familiar concepts to you.

2

Why is Linux so Popular?
Linux stands out in enterprise computing, big data, and science (think supercomputers). The main reasons are as follows:
  • Linux is free. You don’t have to pay to use Linux; you can freely view, edit, and distribute the source code. When you buy a computer with Windows or macOS, the cost of those operating systems is already included in the price.

  • Linux is flexible. Linux is used in many different types of computers, including smart toasters and refrigerators, other IoT devices, internet routers, Android smartphones, and more. You can install Linux on your laptop or desktop right now without any setup required to get it up and running! This flexibility is made possible because the Linux operating system is designed to be simple for basic tasks while also having more advanced tools available. You can assemble a version of Linux customized for your device and optimized for your needs.

3

Unix Philosophy

Linux is a “Unix-like” operating system, which means that most of its features are derived from Unix and generally follow Unix design principles. An ideal Unix program is simple, modular, and extensible. Unix programs do well at accomplishing specific tasks and are designed to work well with other programs without relying too heavily on them. The system becomes powerful by leveraging the collaboration of programs rather than because any single program is super powerful.

One of my favorite things about Linux is that everything is a file. The commands and programs you run in the terminal are abstracted as files. The desktop icons used to quickly open your favorite applications are also abstracted as files. How does the system check for application updates? That’s written in files too. Everything that could lead to confusion can be resolved with files. Linux is transparent, dynamic, and elegant. You can imagine being able to customize your Linux installer while having complete control over the system, getting rid of what you don’t want, which is really cool!

These principles accurately illustrate the flexibility of Linux. No wonder it is used in many applications.

4

Everything is a File, Files are the Final Destination of Everything

Next, I will show you a typical system tree or file system hierarchy in Linux. You can read more about tree data structures in my other articles (https://dev.to/emtes/learning-data-structures-trees-2p5g). If you operate on your own Linux system, your directories may not be exactly the same as mine, and may have more or fewer directories. If you want to learn more about these directories (folders), type man hier in the Linux terminal and run the command to read the manual. Personally, I like to keep a search engine nearby to look up new names whose meanings I don’t know.

/ This is the root directory (folder), the root of the file system tree (data structure 😄)
/bin contains binary files and executable programs needed for system startup
/boot contains the kernel and files needed to boot the machine
/dev contains device nodes, the instructions/interfaces used with physical devices connected to the computer
/etc contains system-wide configuration files (pronounced as etsy), and configuration files for large software packages (like gtk, python, X11) are generally stored here.
/home contains directories for system users (downloads, pictures, etc. for each user)
/lib contains shared libraries necessary for the core programs that boot the computer
/lost+found contains data misplaced due to system crashes or drive errors
/media contains mount points for media devices like USB, CDs, and DVDs
/mnt is the mount point for temporary file systems (e.g., for installing system content)
/opt contains additional software packages. On my machine, Google Chrome and Minecraft Launcher store files here.
/proc contains files related to the kernel and running processes
/tmp contains temporary files that may be created while executing programs
/usr contains a secondary read-only system tree used for sharing with certain programs or for installation on other Linux systems. Many directories that exist above also exist here and contain some other files
/var contains files that change size over time, such as logs and backups
If you frequently use Linux, you may occasionally feel the need to edit or write files in some strange directories. I hope knowing the usual meanings of these directory names will help you!

5

Command Line Basics

I mentioned earlier that “the most straightforward way to communicate with a Linux machine is through the command line,” and I mean it. Next, let’s start learning some basic command line or terminal commands that will get you familiar with the system. If you are currently developing using a graphical user interface, you may find it faster and safer to perform operations from the terminal once you become familiar with the command line.

You have a program called shell (think of it as the shell surrounding the operating system kernel) between you and the terminal. The shell is the program that interprets text commands and sends them to the operating system for execution. The most common shell program is Bash, which is included in most Linux distributions. For macOS users, Apple recently switched macOS’s shell program to zsh. macOS is also a Unix-like operating system. Of course, you can change the shell at will!

6

Structure of Terminal Commands

Since the article has already covered enough, I won’t share too many commands in this article; note that the learning mode is more important. Typically, terminal commands follow a very similar and predictable structure:

program_name [–optional flags] [optional arguments]

Flags can appear after the arguments and are typically shortened to a letter and a dash, such as -f. Flags are options that change how the program behaves. For example, -h or –help are commonly used help flags that provide information about which flags are available for use when the program receives that flag.

Arguments are usually files, but they can also be strings and numbers.

You can call programs from any directory in the system, and you can use files from any directory in the system as arguments. You can do this because you can use relative or absolute paths to name files in Linux. A relative path is relative to the current directory, and you can use . to represent the current directory (which will be explained further below). An absolute path starts from the system’s root directory /, and you need to specify each level of directories to get to the desired file.

7

Command Index
  • pwd prints your current directory (print working directory)

  • cd changes the directory to the specified argument (changes directory). If no argument is provided, it defaults to the user directory, and you can also use ~ in the path to jump. . and .. represent the current directory and parent directory, respectively, and are also valid arguments for the cd command.

  • ls lists the files in the specified argument directory (list), with the default argument being the current directory, i.e., .. The -a flag can conveniently view hidden files. In Linux, you can hide files by naming them with a . at the start, as in .gitignore.

ls -a ~/Documents

8

File Operations
  • mv moves a file or directory to the specified directory (move).
mv fun-letter.text ~/Documents/letters/
You can also use mv to rename files and directories:
mv fun-letter.txt hilarious-letter.txt
This means moving it to a new named location
  • cp copies files in the specified directory (copy). Use the -r flag to recursively copy directories, and like using mv to rename files, you can use a similar method to rename files and directories.
  • mkdir creates a new directory, with the new directory name as an argument. You can also use the -p flag to create new directories under non-existent directories.
mkdir -p code/web-stuff/html notes
  • touch creates a new file, with the file name as an argument.
You will soon find yourself wanting to do more complex things, so read more about these commands and keep a cheat sheet handy 😉.

8

Daily Use of Linux

I won’t say that 2020 will be the year of Linux on the desktop world, but I want to share that many Linux distributions have been able to work out of the box, and we can install them very easily. If you are attracted by the capabilities of the Shell or are concerned about privacy risks posed by using other operating systems, or simply enjoy hacking and other technical aspects, then Linux is perfect for you. As a developer, it is also a great platform because it is designed with other developers in mind. Linux distributions (such as Ubuntu, Linux Mint, and Fedora) can boot up and run quickly. These distributions have huge community support, and community members are very willing to help others. Lastly, I want to remind you to remember to back up all important files!

———— END ————
Recommended Reading:

What are the Features of SEGGER’s Three RTOS?

How Keil MDK Stores Variables at Specified Memory Addresses

A Few Excellent Online Compilers Supporting C, C++, and More

Followthe WeChat Public Account “strongerHuang”, reply “1024” to see more content, reply “join group” to join the technical exchange group according to the rules.

Understanding the Differences Between Linux and RTOS

Long pressto go to the public account in the imageto follow

Click “Read the original” to see more shares, and feel free to share, bookmark, like, and view.

Leave a Comment

Your email address will not be published. Required fields are marked *