[New Star Project Linux] - common commands (1)

  • About the author: A cloud computing network operation and maintenance personnel, sharing the technology and dry goods of network and operation and maintenance every day. 

  •  Motto: Keep your head down and hurry on your way, be respectful

  • Personal homepage: Homepage of Netdou

 

Table of contents

 

foreword

1. Commonly used commands

1. The basic principles of Linux:

 User interface:

2. Command form

3. Command example: ls

ls -l: long format

4. File system

View basic server information


foreword

This chapter will explain the common commands of Linux.


1. Commonly used commands

1. The basic principles of Linux :

  • 1. Composed of small programs with a single purpose; combining small programs to complete complex tasks;
  • 2. Everything is a file;
  • 3. Try to avoid capturing the user interface; (try not to interact with the user, that is, once a program starts running, the user does not need to perform any operations, such as ls command, ifconfig command)
  • 4. The configuration file is saved in plain text format

 User interface:

is a unique application that provides a mechanism for the user to launch other applications
CLI : command prompt, the user can enter the command

shellsh,csh,ksh,bash,zsh,tcsh


GUI : Graphical user interface, usually by clicking to start the application
  • GNOME : C language
  • WHERE : C++
  • XFCE: lightweight
Terminal type : tty command can view
  • Virtual terminal ( tty1-6 ) /dev/tty# # is the number
  • Pseudo-terminal (ssh , Telnet connection is called a pseudo-terminal or a terminal opened in a graphical interface ) /dev/pts/#
  • Physical terminal ( console ) /dev/console
  • Serial terminal (print characters at a specific rate, connected through a serial interface) /dev/ttyS#
  • Graphical terminal: You can use the startx command to start startx -- :2 to start the second graphical terminal

2. Command form

Command format:
command option parameters
options:
  • Short options: - Quick and easy to type
  • Multiple options can be combined: -a -b = -ab
  • Long options: -- clear meaning

Parameters: the target of the command

Commands are divided into internal commands and external commands

 

  • Internal command: It is the command that comes with the system shell
  • External command: It is a command generated by installing other programs.
  • You can check whether the command is an internal or external command by type : type command keyword
Ways to help:
  • 1. Internal commands can be passed : help command example : help cd
  • 2. External commands can be passed : command --help For example: ls --help
  • 3. You can get command help through the man command: For example : man cd whatis to check which man chapters there are
  • 4. You can get command help through the info command: For example : info cd
  • 5. You can seek help through search engines such as Baidu \google
  • 6. You can download a linux Chinese command encyclopedia

3. Command example: ls

Common options:
  1. -h : do unit conversion
  2. -a: Show hidden files starting with .
  3. . Indicates the current directory
  4. .. indicates the parent directory - A
  5. -d: Display the properties of the directory itself
  6. -i: index node, inode
  7. -r: display in reverse order
  8. -R : recursive display

ls -l : long format

View results in long format
File type: can be viewed with the file command
  1. - : normal file (f)
  2. d: directory file
  3. b: A block device file (block) is an interface device that stores data for system access. In short, it is a hard disk
  4. c: character device file (character) is the interface device of the serial port, such as keyboard, mouse, etc.
  5. l: symbolic link file (symbolic link file )
  6. p: command pipeline file (pipe) is a special file type, its main purpose is to solve the error caused by multiple programs accessing a file at the same time
  7. s: Socket file (socket) This type of file is usually used in network data connections.
  8. PS : We can start a program to monitor the client's request, and the client can communicate data through the socket.
  9. This file type is most often seen in the /var/run directory.
File permissions: 9 digits, each group of 3 digits, each group: rwx ( read, write, execute ), r--the number of hard links to the file , the owner of the file , the group of the file , the file size ( size) in bytes
  • Timestamp (timestamp) : The last modified time (mtime), you can use the stat command to see
  • Access : access atime is changed when the file is read or executed
  • Modify : modify , mtime is changed with the change of the file content when writing the file Change : change , ctime metadata , the metadata status change is changed with the content of the inode when writing the file, changing the owner, permission or link setting Changed by change.


4. File system

FHS: filesystem hierarchy standard file system hierarchy standard
rootfs () : root filesystem /
  • /boot: Static files related to system startup, such as kernel, initrd or initramfs , and grub (bootloader)
  • /dev: Device files of all devices, device files are also called special files (only metadata, no data, is the entry of the device)
Device file:
  • Block Devices: Random Access, Data Blocks
  • Character device: linear access, in units of characters
  • Device number: major device number ( major ) and minor device number ( minor ) Devices with the same major device number are similar devices ( using the same driver )
Use the cat /proc/devices command to view the major device number of the currently loaded device driver . For example:
ls -l /dev/sr0 brw-rw---- 1 root cdrom 11, 0 4 1 08:59 /dev/sr0
11 is the main device number, 0 is the minor device number

/etc : configuration files
/home : The home directory of ordinary users, and the home directory of each user is usually /home/USERNAME by default
/root: the administrator's home directory;
/lib : Basic shared libraries and kernel module library files Essentially a library is a binary form of executable code that can be loaded into memory by the operating system for execution.
Static library , the code of the .a static library has been loaded into the executable program during the compilation process, so the size is relatively large
Dynamic library, .dll, .so (shared object) The code of the shared library is loaded into the memory when the executable program is running , and it is only simply referenced during the compilation process, so the code size is small.
/lib/modules : Kernel module files
/media : For the mount point directory of mobile devices, such as CD-ROM and U disk
/mnt : mount point directory, additional temporary file system
/opt : optional directory, the installation directory of third-party programs
/proc : The virtual file system of the kernel and process information, the pseudo file system, and the kernel mapping file, which only exist in memory. It provides an interface for accessing system kernel data in the form of a file system.
/sys : Pseudo-file system, hardware device information virtual file system interface, attribute , under this directory is the global device structure system, including all discovered physical devices registered on various buses
/tmp : Temporary files , /var/tmp
/var : variable files (content changes) /var/log log information      
/var/log log information

/bin: basic user command binary program , used for all users /sbin : system binary program, generally management commands /bin and
/sbin The core binary commands that may be used when the system itself starts and runs
/usr : shared, read-only ( Unix System Resource, the abbreviation of Unix system resources ), not suitable for additional tools placed in the /bin or /etc directory
/usr/bin Commands used by most users
/usr/sbin non-core system commands
When the /usr/bin and /usr/sbin systems are running, the user may use the command /usr/lib to complete a certain operation
/usr/local : Mainly stores those manually installed software
  1. /usr/local/bin
  2. /usr/local/sbin
  3. /usr/local/lib
  4. /usr/share/man /usr/share/doc help file

Components of the application:
Binaries, libraries, configuration files, help files
path:
  • Absolute path : Any input path starting with "/" is an absolute path
  • Relative path: Anything starting with "." or ".." is a relative path
Every absolute path can be cut into 2 parts:
  • Basename: basename /path/to/somewhere results in somewhere
  • Directory name: dirname /path/to/somewhere the result is /path/to

View basic server information

Common commands
命令含义

cat /proc/cpuinfo     查看cpu信息

cat /proc/meminfo     查看内存信息

free                  查看内存使用情况

uptime                监控CPU情况

cat /etc/redhat-release    查看发行版信息

hostname            查看主机名

ip addr             查看ip信息

ifconfig            查看ip信息

netstat             查看网络连接信息、路由表等,常用来查看端口打开情况

fdisk -l            查看硬盘信息

df                  查看设备挂载信息

 Creation is not easy, please pay attention, like, collect, thank you~ 

Guess you like

Origin blog.csdn.net/yj11290301/article/details/131586134