"Du and DF"
when the size of the disk exceeds the standard, there will be alarm prompts, if you know the DF and du command is a very wise choice.
du:disc usage show each file and Du is a file-oriented command that calculates only the space occupied by the file. Does not calculate the space occupied by the file system metadata.
DF is calculated based on the overall file system, which determines the size of the allocated space in the system through unallocated space in the file system. The DF command can get how much space the hard disk occupies and how much space is left, and it can also show the usage of all file systems on the I node and disk blocks.
it works well with both. For example, use DF to see which level of directory is too large, and then use Du to view the folder or file size, so you can quickly determine the crux of the problem.
The DF command displays the available space and usage scenarios for all current file systems :
[Email protected] ~]$ df-hfilesystem Size used Avail use% mounted on/dev/sda1 3.9G 300M 3.4G 8%//dev/sda7 100G 188M 95G 1%/data0/dev/sdb1 133G 80G 47G 64%/ Data1/dev/sda6 7.8G 218M 7.2G 3%/var/dev/sda5 7.8G 166M 7.2G 3%/tmp/ Dev/sda3 9.7G 2.5G 6.8G 27%/usrtmpfs 2.0G 0 2.0G 0%/DEV/SHM
The parameter-H indicates the use of the "human-readable" output, that is, in the file system size using GB, MB and other easy-to-read format.
The first field (Filesystem) and the last field (mounted on) are the file system and its hang-in points respectively. We can see that this partition of/DEV/SDA1 is hung in the root directory. The next four fields size, used, Avail, and use% are the partition's capacity, the size used, the remaining size, and the percentage used.
du: Querying disk usage space for a file or folder
If you have a lot of files and folders under the current directory, you can cycle through the space used by all files and folders using the command without the parameter Du. This is not good to see if it is too large, so you have to specify the number of layers in the depth directory, parameter:--max-depth=, this is a very useful parameter! As follows, note that using "*", you can get the space size of the file.
If a process opens a large file, the large file is dropped directly by RM or MV, then du updates the statistics, DF does not update the statistics, or the space is not released. Until the process of opening the large file was killed.
View the size of the Linux file directory and the number of files that the folder contains
du [options] [File]-a or-all displays the size of individual files in the directory. -B or-bytes displays the directory or file size, in bytes. -C or--total displays the sum of all directories or files in addition to the size of individual directories or files. -K or--kilobytes output in kilobytes (1024bytes). -M or--megabytes is output in megabytes. -S or--summarize displays only the totals, listing only the last added total value. -H or--human-readable in k,m,g to improve the readability of the information. -X or--one-file-xystem the file system at the beginning of the processing, if any other different file system directories are skipped. -l< the source file size of the symbolic link specified in the Symbolic link > or--dereference< symbolic link > Display option. -S or--separate-dirs displays the size of individual directories without the size of their subdirectories. -x< file > or--exclude-from=< file > in < file > specify directory or file. --exclude=< directory or File > skip the specified directory or file. -D or--dereference-args displays the source file size for the specified symbolic link. -H or--si is the same as the-h parameter, but the k,m,g is converted to 1000 units. -L or--count-links duplicates the hardware-linked files.
Du-sh xmldb/ //Total statistics size DU-SM * | sort-n //Statistics The current directory size and an Ann size sort Du-sk * | Sort-ndu-sk * | grep guojf //Look at a man's size du -M | Cut-d "/"-F 2//Look at the text in front of the second/character du xmldb/ //View this folder how many files du xmldb/*/*/* |wc-l //view this folder/*/*/* how many files are explained: WC [-LMW]-L: how much Line-M: How many characters-W: how many words
"Grep"
The default grep searches all files, including files under Hidden folders.
grep's "--exclude-dir= parameter" is to exclude a directory, so you can use this parameter to remove the hidden directory of the. Repo/git.
If you enter the--exclude-dir= parameter every time, is it slow and error prone, reducing efficiency? the--exclude-dir= parameter can be added to the configuration file ~/.BASHRC (This is the current user profile for bash) to simplify operations and improve efficiency. Add the following command at the end of the ~/.BASHRC file:
Export grep_options= "--EXCLUDE-DIR=\.SVN"
then save, execute the source ~/.BASHRC or. ~/.BASHRC to make the modification work.
Then, when searching, execute the following command:
GREP-NR Mediabutton *
This will load the Grep_options option by default, without searching for the. SVN directory.
Note that the Grep_options keyword can not be modified to other, otherwise the system will not be considered to be GREP an option parameter.
"View System Version"
$cat/proc/versionlinux version 3.11.0-15-generic ([email protected]) (GCC version 4.6.3 (Ubuntu/linaro 4.6.3-1ubuntu5)) #25 ~precise1-ubuntu SMP Thu Jan 17:39:31 UTC 2014$uname-alinux mtkswgap17 3.11.0-15-generic #25 ~precise1-ubuntu SMP T Hu Jan 17:39:31 UTC x86_64 x86_64 x86_64 gnu/linux$cat /etc/issueubuntu 12.04.4 LTS \ \l$cat/etc/lsb-release distrib_id=ubuntudistrib_release=12.04distrib_codename=precisedistrib_description= "Ubuntu 12.04.4 LTS" $sudo lsb_ Release-ano LSB modules is available. Distributor id:ubuntudescription: Ubuntu 12.04.4 ltsrelease: 12.04Codename: precise just view kernel version $uname- R3.11.0-15-generic
# uname-a # View kernel/Os/cpu info # head-n 1/etc/issue # view OS version # Cat/proc/cpuinfo # view CPU Info # hostname # view computer name # LSPCI- TV # List all PCI devices # LSUSB-TV # list all USB devices # lsmod # list loaded kernel modules # env # View environment variable resource # free-m # View memory usage and swap usage # df-h # View the usage of each partition # du-sh < directory name > # View the size of the specified directory # grep memtotal/proc/meminfo # View Total Memory # grep Memfree/proc/meminfo # View Idle amount # uptime # View system uptime, number of users, load # cat/proc/loadavg # View system load disk and partition # Mount | Column-t # View attached partition status # fdisk-l # View all partitions # swapon-s # view all swap partitions # hdparm-i/DEV/HDA # View disk parameters (IDE devices only) # DMESG | grep IDE # View IDE Device detection status on Startup network # ifconfig # View all network Interface Properties # iptables-l # View firewall settings # route-n # View Routing table # NETSTAT-LNTP # View all listening ports # NETSTAT-ANTP # View all established connections # netstat-s # View Network Statistics Progress # PS-EF # View All Processes # top # Real-time display process Status User # W # view active user # ID < username ; # View specified user information # Last # View user log in log # cut-d:-F1/ETC/PASSWD # View system All users # cut-d:-f1/etc/group # View system All groups # Crontab-l # view Current user The Scheduled Tasks Service # chkconfig–list # Lists all system Services # Chkconfig–list | grep on # Lists all boot system service programs # RPM-QA # view all installed Packages
"Man"
Linux provides a rich help manual that you do not have to look for when you need to see the parameters of a command, as long as you have a man. The Linux Man Handbook has several chapters:
Generation No. |
Representative contents |
1 |
Instructions or executables that the consumer can manipulate in the shell |
2 |
The system core can call functions and tools, etc. |
3 |
Some common functions and function libraries (library), most of which are C's function libraries (LIBC) |
4 |
Description of the device file, usually in/dev file |
5 |
The format of a profile or some file |
6 |
Game (games) |
7 |
Conventions and agreements, such as Linux file systems, network protocols, ASCII code, and so forth |
8 |
Management instructions available to the system administrator |
9 |
Documents related to Kernel |
"Linux. Bash_profile"
If some programs are not installed in the system default path (ie/bin/,/usr/bin,/usr/local/bin/), this time ordinary users want to invoke these commands, must set the path. The method is simple: Log in as a normal user, and then edit the . Bash_profile in the terminal, as long as you add your own path in front of the export path, for example:
[Email protected] bin]$ VI ~/.bash_profile# bash_profile# Get the aliases and Functionsif [-f ~/.BASHRC]; Then . ~/.bashrcfi# User specific environment and startup Programspath= $PATH:/usr/local/programs/crosstool/ Gcc-4.0.2-glibc-2.3.6/arm-linux-gnu/bin/export PATH
"Rsync"
Rsync,remote Synchronize
The specific explanations for the rsync parameters are as follows
-V,--verbose verbose mode output-Q,--quiet thin output mode-C,--checksum turn on the checksum switch, force the file transfer to verify-A,--archive archive mode, which means to transfer the file recursively and keep all file attributes, is equal to-rlptgod-r,--recursive the subdirectory in recursive mode to the-R,--relative uses the relative path information-B,--backup to create the backup, that is, for the purpose already exists with the same file name, the old file is renamed to ~ FileName You can use the--suffix option to specify a different backup file prefix. --backup-dir store backup files (such as ~filename) in the directory. -suffix=suffix defines the backup file prefix-u,--update only updates, which is to skip all the files that already exist in DST, and the file time is later than the file to be backed up. (Does not overwrite the updated file)-L,--links preserves the soft link-L,--copy-links treats the soft link as if it were a regular file--copy-unsafe-links only copies links to the SRC Path directory tree--safe-links Ignore links to src path directory tree-H,--hard-links reserved hard link-p,--perms keep file Permissions-O,--owner keep file belongs to main information-G,--group keep file group information-D,--devices Keep device file information-T,--times hold file time information-S,--sparse Special processing of sparse files to save DST space-N,--dry-run reality which files will be transmitted-W,--whole-file copy files, not incremental detection-X,- -one-file-system do not cross file system boundaries-B,--block-size=size the block size used by the test algorithm, the default is 700 bytes-E,--rsh=command specifies the use of rsh, SSH mode for data synchronization--rsync-path=path Specifies the path information for the rsync command on the remote server-C,--cvs-exclude uses the same method as CVs to automatically ignore files to exclude files that you do not want to transfer--existing Just update those files that already exist in the DST without backing up those newly created files--delete delete those DST in src not the files--delete-excluded also delete the receive side those are the optionSpecify excluded files--delete-after the transfer ends and then delete--ignore-errors timely IO errors are also deleted--max-delete=num up to delete NUM files--partial keep files that are not fully transferred for any reason, In order to expedite the subsequent retransmission--force forcibly delete the directory, even if it is not empty--numeric-ids does not match the user and group ID of the number to the user name and group name--timeout=time IP timeout, in seconds-I,--ignore-times Do not skip those files that have the same time and length--size-only when deciding whether to back up a file, just look at the file size regardless of the file time--modify-window=num determine whether the file is the same time using the timestamp window, the default is 0-t-- Temp-dir=dir Create a temporary file in dir--compare-dest=dir also compare the files in dir to determine if you need to backup-P equals--partial--progress display backup process-Z,--compress Compress the backed-up files on transfer--exclude=pattern specify to exclude file patterns that do not need to be transferred--include=pattern specify file patterns that need to be transferred without exclusion--exclude-from=file Exclude files in the specified mode in file--include-from=file do not exclude files that specify pattern matching--version print version information--address bind to a specific address--config=file specify a different configuration file. Do not use the default rsyncd.conf file--port=port Specify a different rsync service port--blocking-io use blocking on the remote shell io-stats give the transfer status of some files--progress During transmission, the actual transfer process--log-format=format specify the log file format--password-file=file get the password from file--bwlimit=kbps limit I/O bandwidth, Kbytes per second-h,-- Help Display assistance information
Rsync-a-l-t-R--delete--force src dest
rsync-vazu-progress [Email protected]:/terry//Home
"Awk"
The file is read line by row, with a blank space as the default delimiter will be sliced each row, cut part of a variety of analysis processing.
"Linux" Summary linux commands