Ordinary computer Xiaobai is not used to directly switching from Window operating system to Linux operating system for a time. The familiar mouse clicks are gone, simultaneous interpreting the use of various commands, just like the legendary hackers.
Since many programming bosses have invested in Linux, you must be eager to invest in Linux. But the road has to go step by step. Start with the simplest file directory for Linux. As for how to build a Linux operating system, I believe you must have a way.
Next, start to carefully understand the file directory of the Linux operating system (what, you don't have a Linux operating system yet??? That doesn't affect your learning (whoring) from the bottom
(I use the Linux operating system as a remote server)
mr_zhou@192 ~ % ssh root@39.108.135.218 Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-47-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Welcome to Alibaba Cloud Elastic Compute Service ! Last login: Sun Oct 31 17:52:40 2021 from 58.61.51.97 root@iZwz97xz5ndfb3m44fxpr2Z:~#
After entering the Linux operating system, your mouse suddenly disappeared, but this series of prompts. First, you need to find out what this means.
root@iZwz97xz5ndfb3m44fxpr2Z:~#
- First, root is the current user. Use the whoami command to query the current user. Root has the maximum authority. As for the authority, it can intervene in a real operating system.
- iZwz97xz5ndfb3m44fxpr2Z this long string is the host name. Use the hostname command to query the host name of course. If you think it is too ugly, you can modify it. Use the command 'hostname to modify the host name' to modify it.
- ~ this is the meaning of the path. Do you think it's strange that the path can have a tilde? Yes, it is. Use the pwd command to view the current path.
(the following is a command demonstration)
root@iZwz97xz5ndfb3m44fxpr2Z:~# whoami root root@iZwz97xz5ndfb3m44fxpr2Z:~# hostname iZwz97xz5ndfb3m44fxpr2Z root@iZwz97xz5ndfb3m44fxpr2Z:~# hostname xiaozhou root@iZwz97xz5ndfb3m44fxpr2Z:~# su root@xiaozhou:~# pwd /root root@xiaozhou:~#
Understanding the directory structure of the entire Linux file system and the functions of each directory is the most critical step in learning Linux. The root directory (/) of the Linux system is the most important (none of them), for the following two reasons:
- All directories are derived from the root directory;
- The root directory is closely related to the startup, repair and restore of the system;
Since the system needs specific startup software, core files, programs required for startup, function libraries and other file data when starting up, if the system has errors, the root directory must also contain programs that can repair the file system. (because the root directory is so important, the FHS requires that the root directory should not be placed in a very large partition, because the larger the partition, the more data you will put, so the partition where the root directory is located may have more opportunities for errors.)
The following is the Linux file system. We can see that the root directory has independent partitions.
root@iZwz97xz5ndfb3m44fxpr2Z:~# df Filesystem 1K-blocks Used Available Use% Mounted on udev 936552 0 936552 0% /dev tmpfs 192956 680 192276 1% /run /dev/vda1 61795304 8271104 50781704 15% / tmpfs 964772 0 964772 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 964772 0 964772 0% /sys/fs/cgroup tmpfs 192952 0 192952 0% /run/user/0
This is the operating system of MacOS, and the root directory is also stored in a separate partition
mr_zhou@192 ~ % df Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk3s1s1 478724992 38839968 207669072 16% 568975 2393055985 0% / devfs 705 705 0 100% 1220 0 100% /dev /dev/disk3s6 478724992 2097192 207669072 1% 1 2393624959 0% /System/Volumes/VM /dev/disk3s2 478724992 477192 207669072 1% 182 2393624778 0% /System/Volumes/Preboot /dev/disk3s4 478724992 1180160 207669072 1% 192 2393624768 0% /System/Volumes/Update /dev/disk1s2 1024000 12328 986872 2% 3 5119997 0% /System/Volumes/xarts /dev/disk1s1 1024000 14456 986872 2% 39 5119961 0% /System/Volumes/iSCPreboot /dev/disk1s3 1024000 624 986872 1% 30 5119970 0% /System/Volumes/Hardware /dev/disk3s5 478724992 224418544 207669072 52% 1277436 2392347524 0% /System/Volumes/Data map auto_home 0 0 0 100% 0 0 100% /System/Volumes/Data/home /dev/disk2s1 10485672 1923008 8524056 19% 30 52428330 0% /System/Volumes/Update/SFR/mnt1 /dev/disk3s1 478724992 38839968 207669072 16% 500193 2393124767 0% /System/Volumes/Update/mnt1
Let's take a look at the functions of various Linux directories.
-
/Root directory
catalogue | describe |
/ | The root of the first hierarchy and the root directory of the entire file system hierarchy. |
/bin | Available necessary commands (executable files) for all users, such as cat, ls, cp, and / usr/bin directory. |
/boot | Bootstrap files, such as kernel and initrd, are often a separate partition |
/dev | Necessary devices, such as: dev/null, / dev/random |
/etc | Configuration files within a specific host system. Used to store configuration files in the system. Basically all configuration files can be found here. |
/proc | The virtual file system archives the kernel and process status as text files (the system information is stored in this directory). The files in this directory can only be viewed and cannot be changed (including root) |
/home | The user's home directory, including saved files, personal settings, etc., is generally a separate partition. |
/root | The home directory of super users is generally represented by ~ |
/usr | The default software will be stored in this directory. It is used to store the second level of read-only user data; it contains most (multi) user tools and applications. |
/lost+found | When the system crashes or the machine shuts down unexpectedly, some file fragments will be generated here. When the system starts up, fsck tool will check this folder and repair the damaged file system. |
/var | Variable files, files whose contents are constantly changing in a normal operating system, such as logs, offline files and temporary e-mail files. |
- /usr directory
- /The function of the usr directory is that the default software of the system will be placed under / usr. This directory is somewhat similar to the combination of C:/windows or C:/Program file under windows
Table of contents | description | Table of contents | description |
/usr/include | /usr/include | used to store header files required for developing and compiling applications under Linux; |
/usr/lib | /usr/lib | stores some commonly used dynamic link shared libraries and static archives |
/usr/sbin | /usr/sbin | unnecessary system binaries, such as daemons for a large number of network services |
/usr/share | /usr/share | architecture independent (shared) data |
/usr/src | /usr/src | source code, such as kernel source code and its header file |
/usr/bin | /usr/bin | non essential executable (not required in single user mode); for all users. |
/usr/local | /usr/local | the third level of local data, which is specific to the host. Generally speaking, there are further subdirectories, such as bin /, lib /, share /. This is the / usr directory provided to general users, where general application software is installed |
- /etc directory
- /etc is used to store configuration files in the system. Basically, all configuration files can be found here.
Catalogue| | describe |
/etc/init.d/ | Store system startup script |
/etc/cron.hourly/ | The executable files in this directory are executed every hour |
/etc/cron.daily/ | The executable files in this directory are executed once a day |
/etc/cron.weekly/ | The executable files in this directory are executed once a week |
/etc/cron.monthly/ | The executable files in this directory are executed once a month |
/etc/passwd | One line of record corresponds to a user information. User name: Password: user ID: group ID: annotative Description: Home Directory: login Shell |
/etc/group | Similar to the passwd file, it describes not users but groups. Group name: Password: GID: list of users in the user group. |
/etc/fstab | The system will be automatically mounted after startup, and all partitions will be automatically mounted after startup |
/etc/hosts | Local domain name resolution file |
/etc/profile | Global system environment configuration variables |
/etc/issue | Prompt before each terminal login |
/etc/issue.net | Prompt before telnet remote login |
/etc/motd | Prompt after successful login (cool style can be customized) |
- /proc directory
- The function of proc directory is: proc file system is a pseudo file system, which only exists in memory and does not occupy external memory space. Because the system information, such as processes, changes dynamically, when users or applications read proc files, the proc file system dynamically reads the required information from the system kernel and submits it.
Catalogue| | describe |
/proc/meminfo | View memory information |
/proc/uptime | uptime command. Check how long the server has been running, how many users are currently logged in, and the average system load of the server in the past 1 minute, 5 minutes and 15 minutes |
/proc/cpuinfo | cpu processor related parameters |
/proc/filesystem | Currently loaded file system |
/proc/diskstats | Disk status |
/proc/stat | cpu status and process status. cpu utilization is calculated from this file |
/proc/version | Core version |
/proc/mounts | System mounted data, mount command |
/proc/modules | List of modules loaded by linux |
/proc / digital | Process information |
- /dev directory
- /The dev directory is a device that the system uses or can use. In Linux, everything is regarded as a file, so the hard disk is saved there as a file. If you are using an IDE hard disk (not SCSI), the hard disk will be called / dev/hda.
Catalogue| | describe |
/dev/tty[0-63] | Virtual terminal |
/dev/ttyS[0-3] | Serial port |
/dev/loop[0-7] | Local loopback equipment |
/dev/lp[0-3] | Parallel port |
/dev/null | Infinite data receiving device, equivalent to a black hole |
/dev/zero | Infinite zero resources |
/dev/random | Random number device |
/dev/urandom | Random number device |
/dev/stderr | -> /proc/self/fd/2 |
/dev/stdout | -> /proc/self/fd/1 |
/dev/stdin | -> /proc/self/fd/0 |
Through the above, I have a general understanding of the directory structure of Linux. Having a Linux operating system device is the next priority. You can first focus on my VX official account (the same name), install the familiar system environment, or continue to wait for my next article to bring you Linux environment installation.