In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use the linux command, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The stat command looks at the attributes of a file: access time (Access), modification time (modify), state change time (Change) stat filename finds and deletes / data the file created 7 days ago in this directory # find / data-ctime + 7-exec rm-rf {}\; # find / data-ctime + 7 | xargs rm-rffind command looks for the file and copies it to / opt directory method 1: find / etc-name httpd.conf-exec cp-rf {} / opt/\ : #-exec executes the following command, {} represents the result of the previous output,\ End command method 2xargs # find / etc-name httpd.conf | xargs-I cp {} / opt #-I means the output result is {} instead of viewing files larger than 1G in the root directory. The default unit is b. You can use other units, such as C, K, M # find /-size + 1024Mtar command to compress and exclude a directory # tar zcvf data.tar.gz / data-- exclude=tmp #-- exclude parameter does not contain a directory or file. Later, you can also view tar package archive files with more than one. Do not extract # tar tf data.tar.gz # t to list the archive file directory, f is to specify the memory used by the real-time viewing system for archive files # free-b-s 55 seconds cycle. Check which process the port is occupied by # lsof-I: Port number # netstat-tunlp | grep port number view server IP connections # netstat-tun | awk'{print $5}'| cut-d:-f1 | sort | uniq-c | sort-n-tun:-tu displays tcp and udp connections, n shows tcp and udp connections as IP address, cut-d:-f1:cut is a command that selectively displays one line,-d specifies: separator -F1 displays the first field after the delimiter. Uniq-c: report or delete duplicate lines in the text,-c add the number of occurrences before the output line sort-n: sort according to different types, the default sort is ascending, and the-r parameter is changed to descending -n is sorted by numerical value. Iptables forwards native port 80 to local port 8080 # iptables-t nat-A PREROUTING-p tcp-- dport 80-j REDIRECT-- to-ports 8080iptables website jump enables routing forwarding: # echo "1" > / proc/sys/net/ipv4/ip_forward # temporarily effective internal network access to public network (SNAT): # iptables-t nat-A POSTROUTING-s [internal network IP or network segment]-j SNAT-to [public network IP] the private network server should point to the firewall private network IP to access the internal network (DNAT) for the gateway public network (public network port maps the private network port): # iptables-t nat-A PREROUTING-d [external IP]-p tcp-- dport [external port]-j DNAT-- to [private network IP: private network port] the private network server should configure the firewall private network IP as the gateway Otherwise, the packet will not come back. In addition, there is no need to configure SNAT here, because the system service will return to modify the MAC address of the network card based on the source of the packet: # ifconfig eth0 down#ifconfig eth0 hw ether 00:AA:BB:CCD:EE#ifconfig eth0 up lists the 10 IP methods most accessed by nginx logs 1 IP # awk'{print $1} 'access.log | sort | uniq-c | sort-nr | head-n 10sort: sort uniq-c: merge duplicate lines And record the number of repetitions sort-nr: sort the monitoring directory in descending order by number, and append the newly created file name to the log to install the inotify-tools package #! / bin/bashMON_DIR=/optinotifywait-mq-- format% f-e create $MON_DIR |\ while read files Do? Echo $files > > test.logdone releases all arp:#arp-d-an on Linux corresponding to the / proc/sys/ directory for sysctl: / etc/sysctl.conf. For example, to modify / proc/sys/net/ipv4/ip_default_ttl, modify the / etc/sysctl.conf file as follows. Add a behavior: net.ipv4.ip_default_ttl=255, that is, turn the folder into a decimal point and then execute # sysctl-p once to take effect. Use date to modify the system time: $date-s "20190301 14:31:00" # hwclock writes bios to keep the program running after exiting SSH: # disown or nohup command & set environment variable # export variable name = variable value automation task cron,at Batch system administrators use cron.deny and cron.allow to prohibit and allow users to have their own crontab files. Crontab format: time-sharing, day, month and week command to run (note that the command must be an absolute path) crontab-e edit crontab-r delete crontab-u user use a user to execute crontab-l list the current crontab content at also through / etc/at.allow and at.deny files Which users can use the at command after the vacancy If you can't create a file, specify the date # touch-t 11091531file / / 11.09 15:31 divide the string to judge that the two strings str1 = str2 have the same content, True str1! = str2 str1 and str2 unequal true-n str1 string length greater than 0 (string non-empty)-z str1 string length 0 true (empty string) str1 str1 non-empty true df command used to display disk usage statistics of file systems currently on Linux systems-block-size= {SIZE} using {SIZE} The size of Blocks-k is equivalent to-- block-size=1024-m is equivalent to-- block-size=1048576-T shows the form of the file system xargs is a filter for passing parameters to commands. You can convert pipe or standard input (stdin) data to command-line parameters, you can read data from the output of a file, or you can convert single-line or multi-line text input to other formats, such as multiple lines to multiple lines. You can capture the output of one command and pass it to another command. Since many commands do not support | pipe to pass parameters, which is necessary in daily work, there is a xargs command, such as: somecommand | xargs-item command-a file is read from the file as sdtin-e flag, note that sometimes it may be-E xargs flag must be a space-separated flag, analysis contains the flag will be stopped when the flag. -p ask the user once when one argument is executed at a time. -n num is followed by a number of times to indicate the number of argument used at a time when the command is executed. By default, all are used. -t means to print the command before executing it. -I or-I assigns each name of xargs, usually line by line, to {}, which can be replaced by {}. -r no-run-if-empty stops xargs when the input to xargs is empty, and you don't have to execute it anymore. The maximum number of characters on the-s num command line, which refers to the maximum number of command line characters for the command that follows xargs. -L num reads the num line once from the standard input to the command command-d delim delimiter, the default xargs delimiter is carriage return, and the argument delimiter is a space. What is modified here is the meaning of the xargs delimiter-x exit, mainly with-s to use-P to modify the maximum number of processes. The default is 1 and 0 is as many as it can. I didn't expect this example. These are all the contents of the article "how to use linux commands". Thank you for your reading. I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.