Linux common instructions, etc.

Introduction to Linux

The Linux kernel was originally written by Finn Linus Torvalds as a hobby at the University of Helsinki.

Linux is a free-to-use and freely disseminated Unix-like operating system. It is a multi-user, multi-task, multi-thread and multi-CPU operating system based on POSIX and UNIX.

Linux can run major UNIX utilities, applications, and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the network-centric design idea of ​​Unix, and is a multi-user network operating system with stable performance.

Linux system boot process

When linux starts, we will see a lot of boot messages.

The startup process of the Linux system is not as complicated as you think. The process can be divided into 5 stages:

  • Booting of the kernel.
  • run init.
  • system initialization.
  • Create a terminal.
  • User logs in to the system.
init程序的类型:

SysV: init, CentOS 5之前, 配置文件: /etc/inittab。
Upstart: init,CentOS 6, 配置文件: /etc/inittab, /etc/init/*.conf。
Systemd: systemd, CentOS 7,配置文件: /usr/lib/systemd/system、 /etc/systemd/system。

system catalog

  • /bin :
    bin is the abbreviation of Binaries (binary files), this directory stores the most frequently used commands.

  • /boot:
    Stored here are some core files used when starting Linux, including some connection files and image files.

  • /dev:
    dev is the abbreviation of Device (device), this directory stores the external devices of Linux, and the way to access devices in Linux is the same as the way to access files.

  • /etc:
    etc is short for Etcetera (etc.), this directory is used to store all configuration files and subdirectories required for system management.

  • /home :
    the user's home directory. In Linux, each user has its own directory. Generally, the directory name is named after the user's account, such as alice, bob, and eve in the above figure.

  • /lib :
    lib is the abbreviation of Library (library) This directory stores the most basic dynamic link shared library of the system, and its function is similar to the DLL file in Windows. Almost all applications need to use these shared libraries.

  • /lost+found :
    This directory is usually empty. When the system is shut down illegally, some files are stored here.

  • /media :
    The linux system will automatically identify some devices, such as U disk, CD-ROM, etc. After identification, Linux will mount the identified device to this directory.

  • /mnt :
    This directory is provided by the system to allow users to temporarily mount other file systems. We can mount the CD-ROM drive on /mnt/, and then enter this directory to view the contents of the CD-ROM drive.

  • /opt :
    opt is an abbreviation for optional, which is the directory where additional software is installed on the host. For example, if you install an ORACLE database, you can put it in this directory. Default is empty.

  • /proc :
    proc is the abbreviation of Processes (process), /proc is a pseudo file system (that is, a virtual file system), which stores a series of special files of the current kernel running state. This directory is a virtual directory, which Is the mapping of system memory, we can get system information by directly accessing this directory.
    The content of this directory is not on the hard disk but in the memory. We can also directly modify some files in it. For example, we can block the ping command of the host through the following command, so that others cannot ping your machine:

    echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
    
  • /root :
    This directory is the home directory of the system administrator, also known as the super-authorized user.

  • /sbin :
    s means Super User, which is the abbreviation of Superuser Binaries (Super User Binaries), which stores the system management programs used by system administrators.

  • /selinux :
    This directory is unique to Redhat/CentOS. Selinux is a security mechanism, similar to the Windows firewall, but this mechanism is more complicated. This directory is used to store selinux-related files.

  • /srv :
    This directory stores data that needs to be extracted after some services are started.

  • /sys

    This is a big change in the Linux 2.6 kernel. A new file system sysfs in the 2.6 kernel is installed in this directory.

    The sysfs file system integrates the information of the following three file systems: the proc file system for process information, the devfs file system for devices, and the devpts file system for pseudo-terminals.

    The filesystem is a visual reflection of the kernel device tree.

    When a kernel object is created, corresponding files and directories are also created in the kernel object subsystem.

  • /tmp :
    tmp is the abbreviation of temporary (temporary) This directory is used to store some temporary files.

  • /usr :
    usr is the abbreviation of unix shared resources (shared resources), this is a very important directory, many applications and files of the user are placed in this directory, similar to the program files directory under windows.

  • /usr/bin:
    Applications used by system users.

  • /usr/sbin:
    The more advanced management programs and system daemons used by superusers.

  • /usr/src:
    The default directory for the kernel source code.

  • /var :
    var is the abbreviation of variable. This directory stores things that are constantly expanding. We are used to placing those frequently modified directories in this directory. Includes various log files.

  • /run :
    is a temporary file system that stores information since the system was started. When the system restarts, the files in this directory should be deleted or cleared. If you have a /var/run directory on your system, it should point to run.

In the Linux system, there are several directories that are more important. Usually, you need to be careful not to delete or arbitrarily change the internal files.

/etc : As mentioned above, this is a configuration file in the system. If you change a file in this directory, it may cause the system to fail to start.

/bin, /sbin, /usr/bin, /usr/sbin : This is the default directory of the system where executable files are placed. For example, ls is in the /bin/ls directory.

It is worth mentioning that /bin, /usr/bin are instructions for system users (general users except root), while /sbin and /usr/sbin are instructions for root.

/var : This is a very important directory. There are many programs running on the system, so each program will generate corresponding logs, and these logs will be recorded in this directory, specifically in the /var/log directory, in addition The default placement of mail is also here.

Use of vi/vim

Basically vi/vim is divided into three modes, namely command mode (Command mode) , input mode (Insert mode) and bottom line command mode (Last line mode) . The functions of these three modes are:

Command mode:

The user has just started vi/vim and entered command mode.

Keystrokes in this state are recognized by Vim as commands, not characters. For example, if we press i at this time, a character will not be entered, and i is regarded as a command.

The following are some commonly used commands:

  • i Switch to input mode to enter characters.
  • x deletes the character at the current cursor position.
  • : Switch to bottom line command mode to enter commands on the bottom line.

To edit text: Start Vim, enter command mode, press i to switch to input mode.

Command mode only has some basic commands, so you still have to rely on the bottom line command mode to enter more commands.

input mode

Press i in command mode to enter input mode.

In input mode, the following keys are available:

  • Character keys and Shift combinations to enter characters
  • ENTER , carriage return, line feed
  • BACK SPACE , the backspace key, deletes the character before the cursor
  • DEL , delete key, delete the character after the cursor
  • Arrow keys , move the cursor in the text
  • HOME / END , move the cursor to the beginning/end of the line
  • Page Up / Page Down , page up/down
  • Insert , switch the cursor to input/replace mode, the cursor will become a vertical line/underline
  • ESC , exit input mode, switch to command mode

Bottom Line Command Mode

In the command mode, press : (English colon) to enter the bottom line command mode.

The bottom line command mode can enter single or multi-character commands, and there are many commands available.

In bottom-line command mode, the basic commands are (colons have been omitted):

  • q to quit the program
  • w save file

The bottom line command mode can be exited at any time by pressing the ESC key.

yum common commands

  • \1. List all updatable software inventory command: yum check-update
  • \2. Update all software command: yum update
  • \3. Install only the specified software command: yum install <package_name>
  • \4. Update only the specified software command: yum update <package_name>
  • \5. List all installable software inventory command: yum list
  • \6. Remove package command: yum remove <package_name>
  • \7. Find the package command: yum search
  • \8. Clear cache command:
    • yum clean packages : clear the packages in the cache directory
    • yum clean headers : clear the headers in the cache directory
    • yum clean oldheaders : clear old headers in cache directory
    • yum clean, yum clean all (= yum clean packages; yum clean oldheaders) : clear the packages and old headers in the cache directory

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325309496&siteId=291194637