Learn Linux terminal commands
Linux directory Architecture
/Bin command binary file
/Boot stores the files that must be read when the system starts, including the core (kernel ).
/Boot/GRUB/menu. lst grub settings
/Boot/initrd core solves the RAM disk required by zookeeper
/Dev system peripheral devices
/ETC system settings file
/Etc/dir_colors set color
/Etc/hostname: Set the node name of the user.
/Etc/networking only indicates yes indicating that the network exists
The/etc/host. conf file describes how your system queries node names.
/Etc/hosts: set the table for the user's own IP address and name
/Etc/hosts. Allow settings allow inetd machines to use
The/etc/hosts. Deny setting cannot be used by machines that use inetd.
/Etc/inetd. conf: configure the system network daemon inetd.
/Etc/protocols: Set the protocols supported by the system
/Etc/named. boot sets the local server as the name server configuration file
/Etc/sysconfig/network-scripts/ifcfg-eth0 set IP
/Etc/resolv. conf set DNS
The configuration file of/etc/X11 X Window, Xorg. conf or xf86config.
/Etc/fstab records the file system to be mounted upon startup
/Etc/inittab: Set the runlevel that the INIT process will set when the system starts.
/Etc/issue records information displayed before Logon
/Etc/group: Set the user's group name and related information
/Etc/passwd account information
/Etc/shadow password information
/Etc/sudoers can be the configuration file of the sudo command
/Etc/securetty to set which terminals can be logged on by the root user
/Etc/login. defs default configuration when all users log on
/Etc/exports: Used to set NFS
The/etc/init. d/scripts of all servers are stored here, for example, to be dynamic or to disable
/Etc/xinetd. d/This is the configuration items of the servers managed by the super daemon.
Additional parameter settings for the/etc/modprobe. conf kernel module
/Etc/syslog. conf log setting file
/Home user's home directory
/Library used by the Lib System
/Lib/modules kernel related modules
/Var/lib/RPM kit installation
When the/lost + found system is abnormal, some missing fragments are placed under this category.
/Mount point of MNT peripherals
/Media is similar to/mnt
/Opt additional software installed on the host
/Proc virtual directory, memory ing
/Proc/version kernel version
/Proc/sys/kernel system kernel function
/Root system administrator's home directory
/Sbin Command executed by the system administrator
/Srv the resources required for these services
/Tmp is usually used by the user or the program that is being written when the case is stored.
/Usr maximum directory, storing applications and files
/Usr/x11r6: X-window directory
/Usr/src: Linux source code
/Usr/include: System header file
/Usr/openwin: store Sun's openwin
/Usr/man online user manual
Description of binary file that/usr/bin users can parse rows
/Usr/local/bin users can parse the contents of binary file
Function libraries used by the/usr/lib System
The function library used by the/usr/local/lib System
/Usr/sbin commands that can be executed by the system administrator
/Usr/local/sbin commands that can be executed by the system administrator
/Var Log File
/Var/log/secure records the data access cases of the system, such as POP3, ssh, telnet, and FTP.
/Var/log/wtmp reporter information of the login user, last
/Var/log/messages indicates the dynamic transmission information generated by the system.
When/var/log/boot. log is enabled or when some services are active
/Var/log/maillog upload users' logs for access or use sendmail and POP3
/Var/log/cron record the content of the crontab routine Server
/Var/log/httpd,/var/log/news,/var/log/mysqld. Log,/var/log/samba,/var/log/procmail. log:
The difference is that different website services are recorded.
Some common basic commands:
Uname-a view kernel version
Ls-AL: Display Properties of all files
PWD displays the current path
CD-returns the last directory Cd ~ Returns the home directory.
Date S: set the time and date
Cal display calendar Cal 2006
Man & info help manual
Locale displays all available fonts locale-A in the current font/etc/sysconfig/i18n setting file
Lang = en english font
Sync writes data synchronously to the hard disk
Shutdonw-H now & Half & poweroff Shutdown
Startx & init 5 enters the graphic interface
/Work &? Work: Search for document content up and down
Chgrp changed the archive group chgrp testing install. Log
Chown changed its owner chown root: Root install. Log
Chmod change attribute chmod 777 install. Log READ = 4 Write = 2 execute = 1
CP copy CP filename
Rm delete file Rm-RF filename force delete file
Rmdir Delete folder
Rename MV 123.txt 222.txt
Create a folder using mkdir
Touch file creation update current time
Cat displays cat from the first line | more pages
NL adds a row number before the content
More & less side flip
Head-N filename: displays row N content
Tail-N filename: The last n rows of content displayed
Od display non-pure document
DF-H display partition Space
Du: displays the directory or file size.
Fdisk partition settings fdisk-L/dev/hda display hard disk partition status
Mkfs creates various file systems mkfs-T ext3/dev/ram15
Fsck checks and fixes Linux Files
Ln hard link ln-S software Link
Whereis SEARCH Command
Find find/-name "***.***"
Which viewing tool
Whoami displays the current user
Gcc-V view GCC version
Delete chattr-I filename cancel prohibition
Lsattr show hidden attributes
Updatedb updates the database
Mke2fs format mkfs-T ext3
Dd If =/etc/passwd of =/tmp/passwd. Bak backup
Mount: list all partitions in the system.
Mount-T iso9660/dev/CDROM/mnt/CDROM mounting Disc
Mount-T vfat/dev/fd0/mnt/Floppy mount a floppy disk
Mount-T vfat-O iocharset = utf8, umask = 000/dev/hda2/mnt/hda2 mount the FAT32 Partition
Mount-t ntfs-o nls = utf8, umask = 000/dev/hda3/mnt/hda3 Mount NTFS partitions
Linux-NTFS project: http://linux-ntfs.sourceforge.net/
Ifconfig displays or sets network devices
Service Network restart Nic
Ifdown eth0 disable Nic
IFUP eth0 enable Nic
History history! 55. Execute 55th commands
Stty terminal stty-
Fdisk/MBR Delete grub
At least one execution schedule
Crontab adopts the regular Command [e] to edit, [l] to display, and [R] to delete a task.
& Background running program tar-zxvf 123.tar.gz & ---------> background running
View jobs in the background
FG transfers the background program to the foreground FG n ------> N is a number, you can specify the program
BG enables the work to run in the background
Kill End Process kill-9 PID  force end,  Normal end, [l] list available kill Signals
PS aux viewing background programs
Top view background programs top-D 2 update every two seconds top-D 2-p10604 watch a PID
Top-B-N 2>/tmp/top.txt -----> perform the top information twice, and then output the result to/tmp/top.txt.
Pstree uses the tree chart to display the program [a] using ASCII to connect, [u] listing PID, [p] listing account
Killall must be deleted from a certain service killall-9 httpd
Free Display memory status free-M --------> displayed in MB
Uptime displays the current system boot time
Netstat displays the network status netstat-tulnp ------> Find the network operator and its PID that have been listened to on the current system
Dmesg displays the boot information demsg | more
Nice sets priority nice-n-5 VI & -----> use root to give nice-5, which is used for copying row vi
Renice adjusted priority
Runlevel displays the current runlevel
Lsmod displays the modules loaded into the system
Modinfo displays information about the kernel module
Insmod loading Module
Modprobe automatically processes the load-able Module
Rmmod Delete Module
Check chkconfig and set various system services chkconfig -- list -----> to list various service statuses.
Ntsysv sets various services of the system
Cpio backup file
*. Z compress program zookeeper case;
*. Bz2 Bzip2 program zookeeper case;
*. GZ gzip program upload history case;
* The resources packaged by the. Tar program have not been deleted;
* .Tar.gz tar program packaging example, which has passed the gzip example
Compress filename compressed file plus [-D] uncompress
Gzip filename compression plus [-D] decompress zcat 123.gz to view the compressed file content
Bzip2-Z filename compression plus [-D] unzip bzcat filename.bz2 to view the compressed file content
Tar-CVF/home/123.tar/etc package without compression
Tar-xvf 123.tar unpacks
Tar-zxvf/home/123.tar.gz unzip with Gzip
Extract tar-jxvf/home/123.tar.bz2 with Bzip2
Tar-ztvf/tmp/etc.tar.gz view tar content
Common VI usage
General mode edit mode command mode
H left a, I, R, O, A, I, R, O: W save
Enter edit mode under J: W! Force save
On K, DD deletes the current row of the cursor: Q! Do not save and exit
L right NDD Delete n rows: WQ! Save and exit
0 move to the beginning of the row YY copy the current row: E! Restore original file
$ Copy n rows to the end of the row: W filename save
H. paste P and P at the top of the screen: Set nu to set the row number.
M screen center U undo: Set Nonu cancel row number
L click [CTRL] + R at the bottom of the screen to redo the last action ZZ and save and exit.
The last line of the G file [CTRL] + Z is paused and exited: Set nohlsearch permanently disables the highlighted display
/Work downward search: SP opens two documents at the same time
? Work: Search [CTRL] + W for two documents
Move Gg to the first row of the file: nohlsearch temporarily disables highlight
Alias displays all current command aliases alias LM = "ls-Al" command aliases unalias lm cancelling command aliases
Type is similar to which
Exprot to set or display environment variables
Exprot Path = "$ path":/sbin Add/sbin path
Echo $ path: Display path
Bash entry subroutine
Name = Yang variable
Unset name cancel variable
Echo $ name: DISPLAY variable content
Myname = "$ name its me" & myname = '$ name its me' when the single quotation mark $ name loses the variable content
CIW =/etc/sysconfig/network-scripts/set the path
Env: list all environment variables
Echo $ random
Set shell settings
PS1 = '[/u @/h/W/A #/#]/$' specifies the character to be prompted.
[Root @ Linux ~] # Read [-pt] variable ----------- read the input variables on the keyboard
-P: the backend can be followed by a prompt character!
-T: the backend can be connected to the "seconds !』
Declare declares shell Variables
Ulimit-A displays all restrictions
Ls/tmp/Yang & Echo "exist" | echo "not exist"
This means that when ls/tmp/yang completes the row, if it is correct, Echo "exist" will be executed. If there is a problem, Echo "not exist" will be performed"
Echo $ PATH | cut-d': '-F 5 uses the separator to read the content of section 5th.
Export | cut-C 10-20 read 10th-20 bytes
Last | grep 'root'
CAT/etc/passwd | sort display
CAT/etc/passwd | WC displays "lines, words, and bytes 』
[Root @ test root] # grep [-acinv] 'search for character string' filename
-A: Search for data in the binary classification case by text encoding.
-C: count the number of times that the 'search for character string' is found.
-I: Ignore the difference in the size of the shard, so the size of the Shard is the same
-V: indicates the reverse selection, that is, the row without the 'search character string' content!
Grep-N '123.txt search for the character ----------- search for a specific string
Grep-n't [EA] st'123.txt search for test or taste characters --------- use  to search for a collection character
Grep-n '[^ g] oo '123.txt search for oo ----------- selected from G before [^]
Grep-n '[0-9] '123.txt search for numbers with 0-9
Grep-n '^ The '123.txt Search Start With the row ----------- start of the row search ^
Grep-n' ^ [^ A-Za-Z] '123.txt search does not start with an English letter
Grep-n' [A-Z] $ '123.txt search for rows ending with a-Z ---------- search at the end of a row $
Grep-N 'G .. d' 123.txt Search Start with G and end with D character ---------- any character.
Grep-N 'ooo * '123.txt search contains at least two oo characters --------- duplicate character *
Sed text stream editor uses script commands to process text files
AWD mode scan and processing language
NL 123.txt | sed '2, 5d 'Delete content from the second row to the fifth row
Differences between diff and files
CMP compares two files
Format the file to be printed by PR
/Etc/passwd SYSTEM account information
/Etc/shadow account password information is encrypted by MD5 32-bit
Add "*" in front of the password column 『*』『! "Forbidden to use an account
/Etc/group system group information
Newgrp change logon Group
Useradd & adduser create new user ---------> useradd-M test automatically create the user's login directory
Useradd-m-g pgroup test ---------> specify the level
/Etc/login. defs UID/GID
Passwd Change Password -----------> passwd Test
Userdel Delete account -----------> userdel-r Test
Change the shell [-L] used when logging on to the system using CHSH to display the available shell; [-S] modify your own shell.
Chfn changes the information displayed by the finger command
Finger finds and displays user information
ID Display User ID -----------> ID Test
Groupadd add Group
Groupmod is similar to usermod.
Groupdel Delete Group
Su test changes Su-to root and uses the root environment variable.
Sudo executes commands in other identities
Visudo edit/etc/sudoers and add a line "test all = (all) All 』
% Wheel all = (all) All users in all the wheel groups in the system can use sudo.
% Wheel all = (all) nopasswd: all users in the wheel group do not use the nopasswd password.
User_alias admpw = vbird, dmtsai, vbird1, and vbird3 are added to the admpw group.
Admpw all = nopasswd :! /Usr/bin/passwd,/usr/bin/passwd [A-Za-Z] *,/
! /Usr/bin/passwd root can change the user password, but cannot change the root password (add it before the command! Cannot represent)
Pam (Pluggable Authentication Modules, embedded Mode)
Who & W view who is online
Last recent host login information
Lastlog recent logon time read/var/log/lastlog
Talk with other users
Write sending information write test [CTRL] + D send
Mesg sets the write permission for the terminal. mesg n prohibits receiving mesg y.
Wall sends a message to all users. Wall this is q test
Mail write mail
/Etc/default/useradd home directory default settings
Quota displays the space used by the disk and the limit quota-guvs -----> shows the current limit of the root user's quota.
Quotacheck checks disk space usage and limits. quotacheck-avug -----> performs a preview of all partitions in the/etc/mtab containing the partition supported by quota.
[-M] force Scan
Quota must be an independent partition. There must be two files, quota. User and quota. Group. Add the following to/etc/fstab:
/Dev/hda3/home ext3 defaults, usrquota, kgquota 1 2
The chmod 600 quota * setting is complete and the restart takes effect.
Edquota edits the quota [u] user of a user or group, [g] group, [p] copy, and [T] sets the grace period.
Edquota-A Yang edquota-P Yang-u young -----> copy
Quotaon enable disk space limit quotaon-auvg --------> activate all filesystems with quota
Quotaoff disk space limit quotaoff-A --------> the quota limit is disabled.
Repquota-AV: Query quota of all filesystems with quota in the kernel system.
The main steps for quota from starting filesystem support to the end of the entire configuration are as follows:
1. Set the filesystem of partition to support quota metrics:
Quota must support the filesystem on partition. Generally, ext2/ext3 is the best support level,
I have never heard of other filesystem-type programmers! When the filesystem supports quota, the simplest option is always using/etc/fstab,
This allows the specified volume to be enabled to support the quota volume;
2. Create a quota Reporter:
Previous attempts have been made, and the entire quota drive limit is stored in aquota. User/aquota. Group,
To create these two cases, you must first use quotacheck for scanning!
3. Quota quota restrictions:
In addition, edquota is used to allocate the available space for each user or group;
4. Repeat and trigger quota:
After setting the quota, we recommend that you perform the quotacheck operation again, and then use quotaon to activate it!
Boot Process Overview
1. Import the hardware information of the bios and obtain the first token on the server;
2. Retrieve the startup information of the boot loader (Lilo, grub, spfdisk, etc.) of the First MBR on the machine;
3. Access the core information of the kernel operating system. The kernel starts to solve the problem and updates all hardware settings;
4. Run the INIT program and obtain the Run-level information;
5. init upload/etc/rc. d/rc. sysinit commit case;
6. External topology of the animation core (/etc/modprobe. conf );
7. init each batch (scripts) of the run-level line );
8. init upload/etc/rc. d/rc. Local upload;
9. Click the/bin/login program and wait for the user to log on;
10. log on to the console and start using shell to control the host.
In/etc/rc. d/rc3.d, start the instance starting with S, stop the instance starting with K, and then the number indicates the execution order.
Grub VGA settings
Color/Resolution 640x480 800x600 1024x768 1280x1024 bit
256 769 771 773 775 8 bit
32768 784 787 790 793 15 bit
65536 785 788 791 794 16 Bit
16.8 M 786 789 792 795 32 bit
./Configure check system information./configure -- help | more help information
Make clean clear the files left before
Make install Installation
Rpm-Q -----> check whether rpm-Ql is installed ------> query all directories of this suite
Rpm-Qi -----> description of the query suite rpm-QC [d] -----> configuration file and description file
Rpm-IVH ----> install rpm-V --------> check whether the kit has been updated.
Rpm-e ------> Delete rpm-uvh -------> Upgrade and install
-- Nodeps -----> force installation -- Test -----> test installation