Linux Learning Notes (i)

Source: Internet
Author: User
Tags bz2 parent directory save file timestamp to date unzip extract disk usage ide hard drive

2015/12/12/DEV/HDA1 (IDE hard drive Interface)/DEV/SDA1 (SCSI hard drive interface, SATA hard drive interface) is now basically the SDA hard drive mount allocation partition must partition/root partition swap partition (swap partition, memory twice times, not more than 2GB) Recommended/ Boot (boot partition, 200MB)/root/install.log stores the packages and their version information installed in the system/root/install.log.syslog stores the event records that were left during the installation/root/ Anaconda-ks.cfg the options set during installation in the format of the Kickstart configuration file network configuration Hostonly connection to the local computer only NETWORK1 netonly not only with the local connection, but also with the Internet Network8 Bridge is used for real Real native NIC Ifconfig eth0 first nic u owner g all groups o others r Read W write x perform r-4 w-2 x-1rwxrw-r--7 6 4derectory r:ls w:touch/kmdir/rmdir/ RM Create and delete x:cd pwd Enter directory chown owner rights chgrp All group permissions for security purposes, Linux new files are unmask022 default permissions without executable permissions 777-022=755 default Find/etc-iname INI T-iname ignoring case a data block 512 bytes 0.5kfind/-size +204800 +n greater than-n less than equals Find/home-user MXR all then find-group owning group find-amin access time access-cm In file properties change-mmin file contents modify file contents were modified find/etc-cmin-5 file properties modified within 5 minutes-a two simultaneous satisfies-2 satisfies any one can-type file type F file d directory L soft connection -exec/-ok execution name {} \; Perform an action on the search results-ok will ask-inum to find files based on the I node search: Locate UpdateDB Update Vault-I case-insensitive search temporary files do not search which quick Find command in the directory where the Whereis command is located the directory where the search command is located and help group document path grep searches the file for string matching rows and outputs-I case-insensitive-V Exclude a specified character more or less display text grep-v ^#/etc/inittab start with # Help Group command Man manual View configuration information Man services1 command Help 5 configuration file help Whatis name short help letter Apropos name profile short information name--help list options info and man almost help get sheel built-in commands for group information unmask View default permissions useradd Add user passwd change user password who To view the logged-on user information tty1 indicates that the local terminal PTS0 represents the terminal number in order to differentiate the endpoint from the last representative IP address does not represent the native W get more detailed user information up contact run time 2 users current user load average:0.00 0.00 0.00 Load represents idle idle time PCPU consumes CPU time what user action now JCPU: Occupy Cpugzip compression. GZ can only be a file, cannot be a directory, does not retain the original file Gunzip extract the tar compression directory-C means package- V To display detailed information-F specify file name cc.tar.gz compressed format TAR-ZCF file for packaging and compression unzip the compressed-C to-XTAR-ZXF decompression Zip: Compressed file or directory-R can be compressed directory decompression unzip extract 2015/12/ 16bzip2 compressed file-K generates compressed file after retaining source file large file decompression TAR-CJF aa.tar.bz2 aabunzip2 extract TAR-XJF aa.tar.bz2 write Send information to the specified user wall send information to all users ping test network connectivity-c specified number of times packet loss Packet loss Rate Ifconfig view network information and network card information eth0 real NIC lo loopback address Mail view send e-mail help view h return d Delete last list directory and past login system user Information Lastlog detect the last time a particular user logged on-u 502 The UID represents the specified user traceroute to display the path between the packets to the host computer netstat display network related information-T TCP protocol-u UDP protocol-L listener-R route-n display IP address and port number-tlun view native listening port-an view all network connections in this machine-RN View the native routing table setup configures the network DHCP for * to indicate that the auto Get Services service network Restart Restart Network Service Mount Mount setting/DEV/SR0 fixed notation (mount point) mount/dev/sr0/mnt/edrom/mount the optical drive to the/mnt/edrom directory umount uninstall the device Shutdown optical machine-h shutdown time now means the-r restart-C cancels a shutdown command ha Lt shutdown the following Poweroffinit 0reboot reboot the operating level of the system 0 shutdown 1 Single User 2 not fully multiuser, without NFS service (partial Command line NFS (can implement file sharing) 3 full multiuser (full command line) 4 Unassigned 5 GUI-X116 reboot viewing system RunLevel cat/etc/inittab runlevel Query system run level N 5 N represents the previous level Logout logoff command vim no menu, only command command mode, insert mode, edit mode input i a o i a o a cursor at the end of the line insert I cursor at the beginning of the insertion Q W Save exit Set number set line Nuset Nonu cancel line number GG to first line g to last row ng to nth row N to nth row $ move to line end 0 move to beginning x Delete character dd Delete line yy is copy p is paste: R import Command execution result:!which LS lookup command The path: R!date import time Vehicleidsmap ^p i#<esc> define shortcut keys CTRL + V + P define ctrl+p shortcut keys map ^b 0x Remove the first character of the beginning of the line the set number is displayed with the row numbers: 1,4s/^/#/g Replace with #,/g from the first line to the beginning of line 4th without confirming the AB user substitution character Package classification source package open source efficiency high installation Slow error prone script Install package binary package install fast RPM package, system default package RPM package RPM command Management Httpd-2.2.15-15.el6.centos. I686.RPMHTTPD Package name 2.2.15 software release 15 software release number of times El6.centos suitable for Linux platform i686 suitable hardware platform rpm RPM package extension rpm Packet Dependency tree dependent a->b->c ring dependent A- The >b->c->a module relies on the full name of the Www.rpmfind.netyum online Management Pack: When the package is not installed, the package full name is used. and pay attention to the path. Package Name: When you operate a package that has already been installed, use the package name to search the/VAR/LIB/RPM database Rpm-ivh install the RPM Package command. So.2 Library relies on-I installLoad-v Verbose Show details-----nodeps does not detect dependencies-----------upgrade-E Erase Uninstall-Q query queries-A All-I query software information-P query not installed package information-l list-F query system file belongs to which soft Package-R Query Package dependency check-V installed packages whether the test is modified to verify the content of the 8 information is as follows: S file size Whether to modify the type of m file or file permissions (RWX) is modified 5 file MD5 Check whether the change (can be seen as the contents of the file) D device, From the code whether to change the L file path whether the owner of the U file changes whether to change whether the genus Group of the G file changes the file type C configuration file config filed ordinary file g "Ghost file" rarely see that the file should not be included in this RPM package ghost F Ilel Authorization File License filer description file Read Me extract Rpm2cpio package full name | \ Cpio-idv. File Absolute Path | Pipe break connect multiple commands \ line break convert RPM package to cpio Format command Cpio is a standard tool used to create software files and extract files from files-I copy-in mode, restore-D restore automatically new directory-v display restore process df mount size rpm Yum Online management enable IPVI Etc/myconfig/sysconfig/network-scripts/ifcfg-eth0 change Onboot to Yes and then restart service network restart/etc/ Yum.repos.d/centos-base.repo network Yum Source [Base] container name, be sure to put in [] The name container description, you can freely write mirrorlist mirror site, this can be commented out BaseURL The address of our Yum source server, the default is the official CentOS Yum source server, is available, if you feel slow can change your favorite Yum source address if this container is in effect, if not write or write enable=1 are effective, written enable= 0 is not effective gpgcheck if 1 refers to the RPM digital certificate in effect, if it is 0 does not take effect Gpgkey digital certificate of the pubic culture save location, without modifying the Yum list query all available packages list Yum Search Search server all and keyword-related packages yum-y Installation package name Install-y Auto Answer yesyum-y update package name update upgrade YUM-Y Remove package name remove Uninstall Yum grouplist list the available software group lists Yum Groupinstall software group name install the specified software group, the group name can be set by Grou plist query out Yum groupremove software group name uninstall specified software group MV Command let other network yum expire using the CD installation media source package and RPM package installation location, rpm default location is the boot file/etc/rc.d/init.d/httpd Start-Up absolute path service httpd start download source package http://mirror.bit.edu.cn/apache/httpd/Source Package save location:/usr/local/src/Software Installation Location/usr/loc al./configure compiler preparation, no installation directory specified, install to default location make compile make install build installation du-sh file name display files size script installation is the installation process written by the person to automatically install the script, just execute the script, define simple parameters, You can complete the installation. Webmin is a Web-based Linux system management interface that you can set up by graphical means, user accounts, Apache, DNS, file sharing services. Http://sourceforge.net/projects/webadmin/files/webmin/ctrl + BackSpace can be rolled back in Linux primarily through user profiles to view and modify user information. Man 5 passwd View Profile Help group/etc/passwd 1th field: User name 2nd field: Password flag x indicates a password 3rd field: UID (user ID) ID 0 Super User 1-499 System User (pseudo user) 500-65535 Normal User 4th field: GID (user initial group ID) (with additional groups) 5th field: User Description 6th field: Home directory normal User:/home/username/superuser:/root/7th fields: shell/etc/after landing Shadow Shadow file 1th field: User name 2nd field: Encryption password encryption algorithm upgrade to SHA512 hash encryption algorithm. If the password pseudo is "!!" or "*" means no password, cannot log on to the 3rd field: Password Last modified Date used January 1, 1970 as the standard, every day timestamp plus 1 4th field: two times the password modification interval (compared to the 3rd field) 5th charactersSegment: Password validity period (compared to 3rd field) 6th field: The number of days before password modification expires (compared to the 5th field) 7th field: The number of days after password expires (compared to the 5th field) 0 indicates that the password expires immediately after expiration-1 On behalf of the password will never expire 8th field: The account expiration time is used to indicate the 9th field: Reserved date-d "1970-01-01 16066 days" convert timestamp to date format/etc/ Group information file 1th field: Set name 2nd field: Group Password flag 3rd field: GID 4th field: Additional user/etc/in group Gshadow Group password file 1th field: Group name 2nd field: Group password 3rd field: Group Admin user name 4th fields: The home directory for additional user users in the group general directory:/home/user name, owner and owning group are all users, permissions 700 Superuser:/root/,  Both the owner and the owning group are root, the rights 550 user's mailbox/var/spool/mail/user name/user template directory/etc/skel each time a user is added, the system automatically creates files to the user directory, these templates useradd-u UID under Skel : Manually specify the UID number of the user-D home directory: Specify user's home directory-C user description: Manually specify user's description-G Group Name: Manually specify user's initial group-group name: Specify user's additional group-s shell manually specify the user's login shell, default is/bin/     Bash user default file/etc/default/useraddgroup=100 default group (private) home=/home home directory inactive=-1 password expiration grace number of days (shadow file 7th field) expire=   Password Expiration time (8th field) shell=/bin/bash default Shellskel=/etc/skel template directory Create_mail_spool=yes whether to create a mailbox/etc/login.defspass_max_days         99999 Password expiration (5th field) pass_min_days 0 Password modification interval (4) Pass_min_len 5 password Minimum is 5 (PAM) pass_warn_age 7 password Expiry warning (6) uid_min 500 min uiduid_max 60000 maximum Uidencrypt_method SHA512 encryption mode passwd-s query the password status of the user password, only rooT user can temporarily lock the user with-L, only the root is available to unlock the user, only the root user may use the-stdin data as the user's password through the pipe character output. Mostly written shell programming when used | The output of the first character of the pipe break, as the input of the second character echo "123" | passwd--stdin usermod Modify user information and Useradd generic chage-l list User Details password status modify user password status modified shadow file-D 0 Lamp This command actually turns the password modification date to 0. (3rd field) so that users will have to change the password userdel-r delete the user at the same time delete user home directory ID view user IDSU user Switch-: option only use "-" to represent the user's environment variables together switch-c: Only once command, not switch user identity su-root-c " Useradd test1 "WhoAmI current login is who env current user environment variable groupadd-g gid specified group idgroupmod-g gid specified group id-n new group name Groupdel Group name has initial user cannot remove additional user can delete gpasswd option group name Add User's additional group-a user name put the user into group-d username to remove ACL permissions from the group to resolve identity uncertainty. Dumpe2fs-h/dev/sda3 Query Specifies partition detail file System Information command:-H Displays the information in the Super block, not the details of the disk block group Mount-o remount.acl/temporarily effective "re-mount the root partition and mount the Add ACL permission vi/etc/ Fstab Join Aclmount-o remount/re-mount the file system or reboot the system for the changes to take effect getfacl file name view ACL permissions setfacl option file name-m set ACL permissions-x Delete the specified ACL permissions-b Remove all ACL permissions-D Set default ACL permissions-K ' remove default ACL permissions-r recursively set ACL permissions setfacl-m u:st:rx/project u on behalf of user St User name Rx Delegate permission Prpject represents any one file directory-M g:group1:rw/p Roject g for Group group1 group name ll-ddrwxrwx---+ 2 root lean 4096 January 13:47/project + has ACL permissions maximum effective permissions mask with ACL performed with Operation Setfacl-m m: RX/project Set the Mask permission to R-x, using "M: Permissions" format recursion is the parent directory when you set ACL permissions, all sub-files and subdirectories will also have the same ACL permissions-m u: User name: Permissions-R/ The purpose of project default ACL permissions is that if default ACL permissions are set for the parent directory, all new child files in the parent directory inherit ACL permissions from the parent directory. Setfacl-m d:u: User name: Permission file name file special permissions setuid binary file The owner of the command executes the program when it is executed and is only valid during the execution of the program. -rwsr-xr-x.  1 root root 30768 February 2012/usr/bin/passwd must have X (execute) permission for the cat command does not have setuid permissions chmod 47554 for SUID2 on behalf of GID1 representatives sticky BIT7 representatives have chmod u+s File name Dangerous setgid command when executing a program, the group identity is promoted to the genus Group of the program file. User groups executable and directory ll/usr/bin/locate lifetimes: Command end chmod u+g file name sticky bit sticky bit, ordinary users can only assign other people drwxrwxrwt for directory. 3 root root 4096 January 10:20/tmpchmod u+t filename 1755CHATRR permission to root also takes effect file System Properties + Add permissions-delete permission = equals a permission, I if the file is set I property, then the file is not allowed to be deleted, Renaming, can not add and modify data, if you set the directory I property, then can only modify the file in the directory data, not allow the creation and deletion of file a can only add data in the file, but can not delete and modify the data; If you set a property on the directory, only the file is allowed to be created and modified in the directory. However, deletion is not allowed. Lsattr file name-a displays all files and directories-D destination is a directory that lists only the properties of the directory itself, not the child files. sudo can only be performed by commands that are only super-user executed by a normal user. System command permissions. System commands when manipulating objects. Visudo actually modifies the/etc/sudoers file root all= (all) the address of the managed host (the identity that can be used) Authorization command (absolute path) #%wheel all= (All) all#% group name is Address of management host = (usable identity) Authorization command (absolute path) sudo-l View available Sudo command sudo/sbin/shutdown-r now normal user performs sudo-assigned command file system Primary partition: A total of up to 4 extended partitions: Only one can be counted as one of the primary partitions, that is, the primary partition plus the extended partition has a maximum of four However, the extended partition cannot store data and formatting and must be divided into logical partitions to be used. Logical partitioning: Logical partitions are partitioned in extended partitions, and if it is an IDE hard disk, Linux supports up to 59 logical partitions, and if SCSI hard disk Linux supports up to 11 logical partitions. Sda5 started; (1-4 can only be primary and extended) Ext2: is the extension version of Ext file Ext3 file system is an upgraded version of the Ext2 file system, the biggest difference is the log function. EXT4 is the CentOS6.3 default file system, 1EB=1024PB=1024*1024TBDF view file system-a displays all file system information, including special file systems such as/proc,/sysfs-h use custom units to display capacity, such as KB, MB or GB-T displays the file system type-m in MB units display capacity-K displays the capacity in kilobytes, the default is KB for the DU statistics directory-A to display per-Word file disk occupancy. By default, only the disk usage of subdirectories is counted. -H uses a custom unit to display capacity, such as KB,MB or gb-s total usage, without listing sub-directories and sub-file occupancy fsck file System repair command-a without displaying user prompts, automatic repair file system-y automatic repair, and-a function consistent, However, some file systems only support-YDUMPE2FS display disk status mount-L query system mounted devices,-l will display the volume label name-a according to the contents of the profile/etc/fstab, automatically mount Mount [-t file system] [-l volume label name] [-O Special Options] Device file name mount point-T file system: Adds a file system type to specify the type of mount, which can be a file system such as ext3,ext4,iso9660. -L Volume Label name: Mount the partition of the specified volume label instead of installing the device file name. -O Special option: You can specify additional options for mounting. Remount exec/noexec Execute/No mount Disc mkdir/mnt/cdrom/establish mount point mount-t iso9660/dev/cdrom (default to write soft connection)/mnt/cdrom Mount disc Put the CD into the optical drive mount/dev/sr0 (by default)/mnt/cdromumount device file name or mount point unmount disc fdisk-l does not support remote Mount view USB drive device file name Mount-t vfat/dev/sdb1/mnt/usb/Note: Linux defaults to NTFS file system files that do not support NTFS file system 1 Kernel compilation 2 3rd party software download ntfs-3g plugin http://www.tuxera.com/community/ NTFS-3G-DOWNLOAD/MOUNT-T ntfs-3g partition device file name mount point fdisk partition fdisk-l view recognized hard disk FDISK/DEV/SDB use FDISK command partition D remove partition m Help menu n New partition W save exit Q Exit p Show Partition list partprobe re-read partition table information extended partition cannot write data and format mkfs-t EXT4/DEV/SDB1 format partition SDB1 format to EXT4 file type set mount point and Mount Mkdir/disk1mount/dev /sdb1/disk1 Disadvantage restart mount information disappears auto mount modify VIM/ETC/FSTABSYSFS proc Memory mount point Tmpfs devpts Temporary mount point first field: Partition device file name or U UID second field: Mount point third field: File System name fourth field: Mount Parameter Fifth field: Specify whether the partition is backed by a dump, 0 for no backup, 1 for a daily backup, and 2 for an unscheduled backup Lost+found backup directory Sixth field: Specifies whether the partition is detected by fsck , 0 means no detection, other numbers represent the priority of the detection, then when let 1 priority than 2 high/etc/fstab file repair Mount-o remount,rw/is not the almighty command to allocate the swap partition free view memory and swap partition usage cached (cache) : The read data is kept in memory, and when read again, it is read directly from memory without reading the hard disk, speeding up the reading process of the data. Buffer (buffering) means that when writing data, the distributed write operation is saved to memory, and when the hard disk is written to a certain extent, it reduces the fragmentation and repeated seeking of the hard disk, speeding up the writing process of the data. n New partition change partition number t key change partition number to 82partprobe reread partition table information MKSWAP/DEV/SDB6 format SWAPSWAPON/DEV/SDB6 join swap partition SWAPOFF/DEV/SDB6 swap partition 2016 /2/17shell command line interpreter powerful programming language explanation execution scripting language can call Linux system commands directly two syntax type BOurne and C two syntaxes are incompatible with each other shell script execution mode echo output command-e support backslash control character conversion echo-e "ACD\BC" \b backspace delete \e[1; \e[0m supports color output #!/bin/bash gives execute permission, runs chmod 755 hello.sh./hello.sh execute script bash with bash call Hello.shdos2unix convert from DOS to UNIX format history-c empty history command-W to write history command in cache to history command save file ~/.bash_history History command save 1000 By default, can be in Environment variable config file/ Etc/profile Modify!n Repeat the first few lines! String repeats the last command alias alias = ' original command ' Alias query command alias make alias permanent Vi/root/.bashrcunalias alias Delete alias Ctrl + U           Delete the command before the cursor Ctrl + Y paste Ctrl + R command Search Ctrl + D exit current Terminal CTRL + C terminate current terminal standard input device filename file descriptor type Keyboard/dev/stdin 0                         Standard input display/dev/sdtout 1 standard output display/dev/sdterr 2 standard error output redirection type symbol               function standard output REDIRECT commands > files to overwrite the correct output of the command to the specified file or device.       Command >> file append the correct output of the command to the specified file or device standard error output redirect error command 2> file to overwrite the error output of the command to the specified file or device.                  Error command 2>> file to append the error output of the command to the specified file or device to the correct output and error output while saving the command > File 2>&1 in a way that overwrites the correct and error of the command to the same file.             Command >> file 2>&1 Save the correct and error commands to the same file in an additional way.                               Command &> file Save the correct and error of the command to the same file in the same way.                       Command &>> file Save the correct and error of the command to the same file in Append mode. Command >> file 1 2>> file 2 Append the correct output to file 1 and append the error output to file 2. Input redirect Wc-c statistics bytes-W statistic word number-l statistic number of rows WC < ANACONDA-KS.CFG output line number of Word characters WC << Hello touch Hello End multiple Command order execution; Multiple command order execution, no Any logical connection. && | | Or implementing a hard disk copy: DD if= input file of= output file bs= bytes count= number of pipe character Command 1 | Command 2 the correct output of command 1 as the operand of command 2 number of connections Netstat-an | grep "established" grep-i ignore case-N output line number-V Reverse lookup--color=auto search out keywords with color display grep "root"/etc/passwd? Match an arbitrary character * Match 0 or any number of any characters [] match any one of the characters in brackets [abc][-] matches any one of the characters in brackets-representing a range [A-z] matches a lowercase letter [^] match a character that is not within the brackets [^0-9] A symbol that matches a character that is not a number ' single quotation marks all special characters in single quotes, such as $ and • are not special meanings. "" double quotes, special symbols in double quotes have no special meaning, but $ and • \ is the exception, with the special meaning of "Call variable Value" "Reference command" and "escape character". The "anti-quote System command $ () and the anti-quote function, such as $ (date) # in the Sheel script, represents the value of the comment $ used to invoke the variable, and if the value of the variable name needs to be called, $name the value of the variable. The \ Escape character, followed by the special symbol after \ will lose special meaning, becomes ordinary character, such as \$ will output $, not as a variable reference. Variable: a unit of computer memory in which the stored value can be changed and must be composed of letters,Numeric and underscore the default type of a variable is a string, if you want to perform a numeric operation. You must specify the variable type as numeric. If the value of a variable has a space, you need to use single or double quotation marks in the value of the variable, you can use the "\" escape character if you need to increase the value of the variable, you can make the value of the variable overlay, but the variable needs to use double quotation marks containing "$ variable name" or with the ${variable name} including the 123 Overlay Assignment of variables view variables all variables set Delete unset the name environment variable takes effect in the current shell and all child shells of the shell, and if the environment variable is written to the response configuration file, the environment variable will take effect in all shells. Export variable name = variable Value # declaration variable env #查询变量unset variable name # delete variable path=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/  Usr/sbin:/usr/bin:/root/binpath= "$PATH":/root/sh defines the system environment variable ps1= ' [\[email protected]\h \w]\$ ' defines a system prompt variable Pstree       Query the process tree path system find a command location parameter variable $n n is a number, "$" represents the command itself $* all parameters in the command, the whole [email protected] command line all the parameters of a single $# command line all parameters of the number of predefined variable $? The return state of the last command executed, if the value of this variable is 0, proves that the previous command executed correctly, if the value of this variable is not 0, (which is the number, which is determined by the command itself), the last command is proved incorrect.  $$ the process number (PID) of the current process $! The process number (PID) of the last process running in the background receives the keyboard input read-p "prompt message": When the read input is waiting for the output prompt, the read command waits for user input, and this option allows you to specify the time to wait. -N Character number: The Read command accepts only the specified number of characters and executes. -s hides input data, applies to confidential information input,-t time numeric operation and operator method 1:declare declaring variable type-give variable type attribute + Cancel Variable Type property-I declare variable as Integer (integer)-x declare variable as environment variable-p Displays the declared type method of the specified variable 2:expr or let numeric Operation tool method 3:¥ () or $[] variable test and content substitution 


Linux Learning Notes (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.