First understand the Linux Philosophy:
- Use programs that do only one task, but do it well.
- To accomplish complex tasks, use several programs linked together.
- Store information in human-readable plain text files whenever it is possible.
- There is no “one true way” to do anything.
- Prefer commandline tools over graphical tools.
Core components of a Linux system
This is executed first. When you have only one operating system installed, it simply loads the kernel. If you happen to have multiple operating systems or multiple versions of the Linux kernel installed, it allows you to choose which one you want to start.
Heart of Linux that communicates directly with the hardware. It allows programs to ignore the differences between various computers. The kernel allocates system resources like memory, processor time, hard disk space and external devices to the programs running on the computer. It separates each program from the others, so that when one of them encounters an error, others are not affected
In a typical Linux system there are various services running as processes in the background, taking care of things like configuring your network connection, responding to connected USB devices, managing user logins, managing filesystems, etc. They are often called “daemons”, because they are running silently and are mostly invisible to the user.
It also called “command line”, implements a textual interface that allows you to run programs and control the system by entering commands from the keyboard. Without a shell (or something that can replace it, like a desktop environment) making your system actually do something would be difficult. The shell is just a program; there are several different shells for Linux, each of which offering somewhat different features. Most Linux systems use the Bourne Again Shell (Bash). Linux shells support multitasking (running several programs at once).
There are several file systems that Linux-based distributions use. They are BTRFS, EXT3/4, VFS, NILFS, and SquashFS.
The hard drive of your computer has a rather simple interface. It only accepts commands like “read block no. 550923 and put it in memory address 0x0021A400”. Suppose you are editing a piece of text and want to save it on the disk. Using block numbers (addresses) to identify pieces of data, like your text, is awkward: not only would you have to tell your program where to save the file using raw block numbers, you would have to make sure that these blocks aren’t already being used for family photos, your music collection, or even your system’s kernel. To solve this, files were introduced. A file is an area of the disk which stores data and which has a name (like “test.txt”). Files are organized in collections called directories. Directories can contain other directories, in a tree-like structure. Each file can be uniquely identified by a “path,” which describes its place in the directory hierarchy.
In Linux, the top-level directory is called the root directory. Every file and directory in the system must be a descendant of the root directory.
Names of files and directories can contain all characters except the null character (which is impossible to enter from the keyboard) and the “/” character.
Devices as files (interesting topic)
Just as files can be written to and read, devices in the computer system may send and receive data. Because of this, Linux represents the devices connected to the system as files in the /dev directory. These files can not be renamed or moved (they are not stored on any disk). This approach greatly simplifies application programming. If you want to send something to another computer through a serial port, you don’t even need another program — you simply write to the file /dev/ttyS0, which represents a serial port. In the same manner the file representing the sound card (/dev/dsp) can be read to capture the sound from an attached microphone, or written to in order to produce sound through the speakers.
The user is a metaphor for somebody or something interacting with the system. Users are identified by a user name and a password. Internally, each user has a unique number assigned, which is called a user ID, or UID for short. You only need to know your UID in some rare situations. Users can additionally be organized in groups. There is one special user in all Linux systems, which has the user name “root” and UID 0. It is also called the superuser. The superuser can do anything and is not controlled in any way by the security mechanisms. Having such a user account is very useful for administrative tasks and configuring the system. In some distributions (like Ubuntu) direct access to the root account is disabled and other mechanisms are used instead.
If you have more than one user account on a Linux system, you do not need to log out and back again to switch impersonations. There are special shell commands that allow you to access files and execute programs as other users, provided you know their user names and passwords. Thanks to this mechanism, you can spend most of the time as a user with low-privileges and switch to a higher-privileged account only if you need to.
The advantage of running as a non-privileged user is that any mistakes you happen to make are very unlikely to damage the system. System-critical components can only be altered by the root user.
Each file belongs to one of the users — that is, each file has an owner. Additionally, a file can be assigned to a group of users, but the owner must be a member of that group. Each file has three kinds of permissions: read, write and execute. These permissions can be assigned to three kinds of owner relations: owner, group and other. Other includes all users who are not the owner of the file and do not belong to the group which owns the file. Only the file owner or the superuser (root) can change the permissions or ownership of a file.
This system allows precise control over who can do what on a given computer. Users can be prevented from modifying system files by removing the “write” permission from them, or from executing certain commands by removing the “execute” permission. Notice that users may be allowed to execute programs but not alter them. This is very important, since most Linux systems include a compiler that allows you to create your own programs.
File permissions are usually given as three octal digits (each from 0 to 7). The digits represent the permissions for, respectively, owner, group and other users. Each digit is the sum of permission codes: 1 for execute, 2 for write and 4 for read. For example, “755” allows everyone to read or execute the file, but only its owner can write it. “400” allows the owner to read the file, and no one else is allowed to do anything. “540” allows the owner to read or execute the file, group members to only read the file and other users to do nothing.
Some important concepts in Linux
How to create a link in Linux?
In your Linux file system, a link is a connection between a file name and the actual data on the disk. There are two main types of links that can be created: “hard” links, and “soft” or symbolic links. Hard links are low-level links which the system uses to create elements of the file system itself, such as files and directories.
A symbolic link is a special file that points to another file or directory, which is called the target. Once created, a symbolic link can be used in place of the target file name. It can have a unique name, and be located in any directory. Multiple symbolic links can even be created to the same target file, allowing the target to be accessed by multiple names.
The symbolic link is a file in its own right, but it does not contain a copy of the target file’s data.
It is similar to a shortcut in Microsoft Windows: if you delete a symbolic link, the target is unaffected. Also, if the target of a symbolic link is deleted, moved, or renamed, the symbolic link is not updated. When this happens, the symbolic link is called “broken” or “orphaned,” and will no longer function as a link.