Important instructions and usage in linux

1. What permissions do you need to enter the directory, and what permissions do you need to perform additions, deletions, and checks (cd, touch, ls, rm, mv, etc.) to change files in the directory.
Linux permission management:
(1) The owner of the file and file directory—- u
(2) Users of the group where the owner of the file and file directory is located—-g
(3) Other users—-o
write picture description here
Illustrate the meaning of each field Types of
write picture description here
file access permissions
a), basic permissions


i. Read (r/4): Read has the right to read the contents of the file for a file; for a directory, it has the right to browse the information in the directory ii. Write (w/2): Write for a file, It has the right to modify the content of the file; for the directory, it has the right to delete the file in the mobile directory. iii. Execute (x/1): execute has the right to execute the file for the file; iv. "—" means not having this permission b), the special permission i.suid (s/4) can only be applied to executable files, allowing any user to execute ii.sgid as the owner of the file when executing the file (s/2) can only be applied to executable files, so that when any user executes an executable file, it will be executed as a member of the owning group
iii. The sticky bit (t/1) can only be applied to directory files, and will When a user deletes in a directory, he can only delete the objects he owns
(a) By adding the read, write, and execute operations to the cd command, it can be known that X (execution authority) is required to execute the cd command
write picture description here
(b) Through the tauch command The addition of read, write, and execute operations shows that X (execution authority) and W (write authority) are required to execute the tauch command
write picture description here
(c) By adding the read, write, and execute operations of the ls command, it can be known that the ls command needs X ( Execute permission) and r (read permission)
write picture description here
(d) By adding the read, write, and execute operations of the rm command, it can be seen that r (read permission), w (write permission) and x (execution permission) are required to execute the rm command
write picture description here

2. Understand the following important directories under Linux /proc, /sys, /SElinux, /bin, /usr/lib, /usr/local, /var, /tmp
/proc
/proc: The Linux kernel provides a mechanism for accessing the kernel's internal data structures and changing kernel settings at runtime through the /proc file system. The proc file system is a pseudo file system that only exists in memory and does not occupy external memory space. It provides an interface for accessing system kernel data in the manner of a file system.
Users and applications can get system information through proc, and can change some parameters of the kernel. Since system information, such as processes, changes dynamically, when a user or an application reads a proc file, the proc file system dynamically reads the required information from the system kernel and submits it. Not all of the files or subfolders listed below exist on your system, depending on your kernel configuration and loaded modules. In addition, there are three very important directories under /proc: net, scsi and sys. The Sys directory is writable and can be used to access or modify kernel parameters, while net and scsi depend on kernel configuration. For example, if the system does not support scsi, the scsi directory does not exist.
In addition to those described above, there are also some numbered directories, which are process directories. Each process currently running in the system has a corresponding directory under /proc. The PID number of the process is the directory name. They are the interfaces for reading process information. The self directory is the information interface for reading the process itself, which is a link.
Subfile or subfolder
/proc/buddyinfo How many blocks are available for each order in each memory area, related to memory fragmentation issues
/proc/cmdline The parameter information passed to the kernel when starting
/proc/cpuinfo cpu information
/proc /crypto All installed encryption ciphers and details used by the kernel
/proc/devices Loaded devices and categories

/proc/dma List of ISA DMA channels registered for use
/proc/execdomains Execution domains currently supported by the Linux kernel
/proc/fb List of framebuffer devices, including number and drivers controlling them
/proc/filesystems Types of filesystems currently supported by the kernel
/proc/interrupts The number of interrupts per IRQ in the x86 architecture
/proc/iomem The current mapping of each physical device in system memory
/proc/ioports The range of registered ports used for the input and output of a device
/proc/kcore represents the system's Physical memory, stored in the core file format, which shows the number of bytes, which is equal to the RAM size plus 4kb
/proc/kmsg Record the information generated by the kernel, which can be processed by /sbin/klogd or /bin/dmesg
/proc/loadavg Load status based on CPU and IO status in the past period of time, related to uptime command
/proc/locks Kernel locked file list
/proc/mdstat Multiple hard disks, RAID configuration information (md=multiple disks)
/proc/meminfo Information about RAM usage
/proc/misc Drivers registered on other major devices (device number 10)
/proc/modules List of all modules loaded into the kernel
/proc/mounts All mounts used in the system
/proc/mtrr System Memory Type Range Registers (MTRRs) used
/proc/partitions Block allocation information in partitions
/proc/pci List of PCI devices in the system
/proc/slabinfo All active slab cache information in the system
/proc/stat All CPU activity information
/proc/sysrq-trigger Use the echo command When writing this file, the remote root user can execute most system-request critical commands as if they were executed from the local terminal. To write to this file, /proc/sys/kernel/sysrq must not be set to 0. This file is also not readable by root
/proc/uptime how long the system has been running
/proc/swaps swap space usage
/proc/version Linux kernel version and gcc version
/proc/bus system bus (Bus) information such as pci/
/proc/driver driver information such as usb
/proc/fs file system information
/proc/ide ide device information
/proc/irq interrupt request device information
/proc/net network card device information
/proc/scsi scsi device information
/proc/tty tty device Information
/proc/net/dev Display network adapters and statistics
/proc/vmstat Virtual memory statistics
/proc/vmcore Kernel panic memory image
/proc/diskstats Get disk information
/proc/schedstat Kernel scheduler statistics
/proc/zoneinfo Display memory space statistics, useful for analyzing virtual memory behavior
The following is the information of process N in the /proc directory
/proc/N Process information with pid N
/proc /N/cmdline Process start command
/proc/N/cwd Link to process current working directory
/proc/N/environ Process environment variable list
/proc/N/exe Link to process execution command file
/proc/N/fd Contains process All related file descriptors
/proc/N/maps Process-related memory mapping information
/proc/N/mem refers to the memory held by the process, unreadable
/proc/N/root Links to the root directory of the process
/proc /N/stat Status of the process
/proc/N/statm Status of memory used by the process
/proc/N/status Process status information, more readable than stat/statm
/proc/self Link to currently running process
/ sys
/sys: sysfs is a new virtual memory-based file system designed in the Linux kernel. Its function is somewhat similar to that of proc, but in addition to the same function of viewing and setting kernel parameters as proc, there are also Unified device model for Linux for management purposes. Exporting kernel data using sysfs is more uniform and better organized than the proc filesystem, and its design draws many lessons from proc.
/bin: executable binary file /usr/lib: /lib directory mainly stores some library files.
/etc file system
The /etc directory contains various system configuration files, some of which are described below. Others you should know which program they belong to and read the man page for that program. Many network configuration files are also in /etc.
/etc/rc or /etc/rc.d or /etc/rc?.d: Scripts or directories of scripts that are run when a runlevel is started, or changed.
/etc/passwd : User database with fields giving username, real name, user home directory, encrypted password and other information about the user.
/etc/fdprm : Floppy disk parameter table to describe different floppy disk formats. Can be set with setfdprm. See the setfdprm help page for more information.
/etc/fstab : Specifies a list of filesystems that need to be automatically mounted at startup. Also includes information about swap areas enabled with swapon -a.
/etc/group: Similar to /etc/passwd, but instead of user information, it describes group information. Include various data for groups.
/etc/inittab : Configuration file for init.
/etc/issue : Contains the user's output at the login prompt. Usually includes a short description of the system or a welcome message. The specific content is determined by the system administrator.
/etc/magic : The configuration file for "file". Contains descriptions of different file formats, based on which "file" guesses the file type.
/etc/motd : motd is the abbreviation of message of the day, which is automatically output after the user successfully logs in. The content is determined by the system administrator. Often used for notification information, such as warnings about planned shutdown times.
/etc/mtab : List of currently mounted filesystems. Initialized by a script (scritp) and updated automatically by the mount command. Used when a list of currently mounted filesystems is required (eg the df command).
/etc/shadow : The shadow password file on systems where shadow password software is installed. The shadow password file moves encrypted passwords from the /etc/passwd file to /etc/shadow, which is only readable by the superuser (root). This makes it more difficult to decipher the password, thereby increasing the security of the system.
/etc/login.defs : Configuration file for the login command.
/etc/printcap : Like /etc/termcap , but for printers. The syntax is different.
/etc/profile , /etc/csh.login , /etc/csh.cshrc : Files executed by bourne or cshells at login or startup. This allows system administrators to establish a global default environment for all users.
/etc/securetty : Identify the secure terminal, ie which terminal allows superuser (root) logins. Usually only virtual consoles are listed, so that it is impossible (at least difficult) to break into the system via a modem or network and gain superuser privileges.
/etc/shells : Lists available shells. The chsh command allows the user to change the login shell within the scope specified in this file. The service process ftpd that provides
a machine's ftp service checks if the user's shell is listed in the /etc/shells file, if not, the user will not be allowed to log in.
/etc/termcap : Terminal Capability Database. Describes what "escape sequence" controls are used by different terminals. Do not directly output escaped
/var filesystem when writing programs
/var contains data that is to be changed while the system is normally running. Usually the size of the directory where the data resides is frequently changed or expanded. Originally, some contents in the /var directory were in /usr, but in order to maintain the relative stability of the /usr directory, we put those directories that need to be changed frequently into /var. Each system is specific, i.e. not shared with other computers over the network.
/var/catman : Contains formatted help (man) pages. The source files for help pages are generally stored in /usr/man/catman; some man pages may have preformatted versions in /usr/man/cat. Other man pages need to be formatted the first time they are viewed, and the formatted version is stored in /var/man, so that others do not need to wait for formatting when viewing the same page again. (/var/catman is often cleaned up, just like the temporary directory.)
/var/lib: Holds files that are changed during normal operation of the system.
/var/local: Stores variable data for programs installed in /usr/local (ie, programs installed by system administrators). Note that
even locally installed programs use other /var directories, such as /var/lock, if necessary.
/var/lock : Lock files. Many programs follow the convention of creating a lock file in /var/lock to support the particular device or file they are using. When other programs notice the lock file, they will no longer use the device or file.
/var/log : log (log) files for various programs, especially login (/var/log/wtmplog records all logins and logouts to the system) and syslog (/var/log/messages records store all core and system programs information) . The files in /var/log often grow indefinitely and should be purged periodically.
/var/run: Holds information files about the system that are valid until the next system boot. For example, /var/run/utmp contains information about the currently logged in user.
/var/spool: Directory for "spooling" programs such as mail, news, print queues, and other queue work directories. Each different spool has its own subdirectory under /var/spool, eg user mailboxes are stored in /var/spool/mail.
/var/tmp: Allows larger or longer-lived temporary files than /tmp. Note that the system administrator may not allow very old files in /var/tmp.
/tmp
The /tmp file is a cache file generated by the Linux runtime, which is used to accelerate the speed of opening the file twice.
The /tmp file will be deleted by the system default command when linux is shut down.
/usr/local
/usr/local/bin houses small user-installed applications, and symbolic links to some larger applications in the /usr/local directory.
/SELinux
SELinux is a mandatory access control (MAC) security system based on a domain-type model. It is written by the NSA and designed as a kernel module to be included in the kernel, and some corresponding security-related applications are also included in the kernel. After patching SELinux, there is finally a corresponding security policy.
Know the following important commands. du, df, top, free, pstack, su, sudo(sudo -, sudo -s), adduser, password
du command
1. Command format:
du [options] [files]
2. Command function:
Displays the disk space used by each file and directory.
3. Command arguments:
-a or -all Display the size of individual files in the directory.
-b or -bytes Display directory or file size in bytes.
-c or --total In addition to displaying the size of individual directories or files, also display the sum of all directories or files.
-k or --kilobytes output in KB (1024bytes).
-m or --megabytes Output in MB.
-s or --summarize only display totals, only the last summed value.
-h or --human-readable Use K, M, G as units to improve the readability of information.
-x or --one-file-xystem is based on the file system at the beginning of processing, and skips it if it encounters other different file system directories.
-L<symlink> or –dereference<symlink> Displays the source file size of the symlink specified in the options.
-S or --separate-dirs Display the size of an individual directory without the size of its subdirectories.
-X <file> or --exclude-from=<file> Specify a directory or file in <file>.
--exclude=<directory or file> Skip the specified directory or file.
-D or --dereference-args Display the source file size of the specified symbolic link.
-H or -si Same as -h parameter, but K, M, G are converted to 1000 units.
-l or --count-links Repeats counting of hardware-linked files.
write picture description here
df command
1 . Command format:
df [options] [files]
2. Command function: The df command is used to display the available disk space on the disk partition. The default display unit is KB. You can use this command to obtain information such as how much space is occupied by the hard disk and how much space is left.
3 Command parameters
-a or –all: include all file systems;
–block-size=<block size>: display the number of blocks with the specified block size;
-h or –human-readable: with readability A higher way to display information;
-H or –si: same as the -h parameter, but it is calculated in 1000 Bytes instead of 1024 Bytes;
-i or –inodes: Display inode information;
-k or –kilobytes: specify a block size of 1024 bytes;
-l or –local: only display the file system on the local side;
-m or –megabytes: specify a block size of 1048576 bytes;
–no-sync: get disk usage information Do not execute the sync command before, this is the default value;
-P or –portability: use the POSIX output format;
–sync: execute the sync command before getting the disk usage information;
-t <file system type> or –type =<filesystem type>: Display only the disk information of the specified filesystem type;
-T or --print-type: Display the type of the filesystem;
-x<filesystem type> or --exclude-type=<filesystem type>: Do not display disk information for the specified file system type;
–help: display help;
–version: display version information.
top command
1. Command format: top [options]

2. Command function: The top command can dynamically view the overall running status of the system in real time. It is a practical tool that integrates multi-party information to monitor system performance and running information. The interactive interface provided by the top command can be managed with hotkeys.
3 Command parameters
-b: operate in batch mode;
-c: display complete command;
-d: screen refresh interval;
-I: ignore the failure process;
-s: secret mode;
-S: accumulation mode;
-i <time>: set the interval time;
-u<username>: specify the user name;
-p<process number>: specify the process;
-n<time>: the number of times of cyclic display. To view other important instructions, please click the link below

http://man.linuxde.net/top

How to use commands to install gcc/g++, gdb, vim
(1) Install vim
First, enter vi in ​​the command line to check the information of vim:
write picture description here
enter ls -a to check whether there are configuration files such as .vimrc and .viminfo, the results are as follows:
write picture description here

(2) Configure gcc/g++
Centos uses yum to configure gcc and g++. To install gcc, enter: yum -y install gcc on the command line, and press Enter to install gcc. To install g++ , you need to enter: yum -y install gcc-c++ on the command line, you can run g++

write picture description here
(3) Configure GDB
1. In the Linux system, open the webpage http://ftp.gnu.org/gnu/gdb/ , the following interface will appear:
write picture description here
Here are the compressed packages of some gdb tools, then, we Select one of the versions to download. If you select the gdb-7.10 version after downloading
, enter: tar xzvf gdb-7.10.1tar.gz in the command window, after decompression, you can view gdb-7.10.1
Enter the decompressed directory: cd gdb-7.10.1
Enter the command: ./configure , use dir to view after completion
Enter the command: make to compile GDB
Enter make install to install GDB
use: gdb -v to view GDB version information, confirm whether the installation is correct

Guess you like

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