Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the classic commands in linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is about what are the classic commands in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. Delete 0-byte file

Find-type f-size 0-exec rm-rf {}\

two。 View the process

Sort by memory from large to small

Ps-e-o "% C:% p:% z:% a" | sort-K5-nr

3. Ranked by cpu utilization from large to small

Ps-e-o "% C:% p:% z:% a" | sort-nr

4. Print the URL in cache.

Grep-r-a jpg / data/cache/* | strings | grep "http:" | awk-Fairfax https'{print "http:" $2;}'

5. Check the number of concurrent requests for http and their TCP connection status:

Netstat-n | awk'/ ^ tcp/ {+ + S [$NF]} END {for (an in S) print a, S [a]}'

6. Sed-I'/ Root/s/no/yes/' / etc/ssh/sshd_config sed in this text, one line of Root matches the line of Root and replaces no with yes.

7.1. How to kill the mysql process:

Ps aux | grep mysql | grep-v grep | awk'{print $2}'| xargs kill-9 (learn the purpose of awk)

Pgrep mysql | xargs kill-9 [netizens: & FROST]

Killall-TERM mysqld

Kill-9 `cat / usr/local/apache2/logs/ httpd.pid` try the killing process PID

8. Displays running services enabled at level 3:

Ls / etc/rc3.d/S* | cut-c 15-(learn the purpose of cut and intercept data)

9. How to display multiple messages when writing SHELL, using EOF

Cat / root/pkts

thirty-nine。 Then check the repetition number of IP and sort it from smallest to largest. Notice that there are two spaces in the middle of "- t\ + 0".

# less pkts | awk {'printf $3 "\ n"'} | cut-d. -f 1-4 | sort | uniq-c | awk {'printf $1 "" $2 "\ n"'} | sort-n-t\ + 0

forty。 Check how many php-cgi processes are active

Netstat-anp | grep php-cgi | grep ^ tcp | wc-l

forty-one。 It is simple to use iptables to correspond.

Netstat-an | grep-v LISTEN | awk'{print $5}'| grep-v 127.0.0.1 | grep-v Native ip | sed "s/::ffff://g" | awk 'BEGIN {FS= ":"} {Num [$1] + +} END {for (i in Num) if (Num > 8) {print I}' | grep'[0-9]\ {1mer3\}\. [0-9]\ {1mer3\}\. [0-9]\ {1mer3\}\. [0-9] -9]\ {1DROP 3\}'| xargs-I [] iptables-I INPUT-s []-j DROP

The Num > 8 section sets the threshold, and this sentence automatically forbids more than a certain number of connections from the same IP found in netstat-an. Change the native ip to the ip address of your server

View the installation of software xxx

Dpkg-L xxx

Find softwar

Apt-cache search regular expression

Find out which package the file belongs to

Dpkg-S filename

Query which packages the software xxx depends on

Apt-cache depends xxx

Query which packages the software xxx is dependent on

Apt-cache rdepends xxx

Add a CD source

Sudo apt-cdrom add

System upgrade

Sudo apt-get updatesudo apt-get dist-upgrade

Clear the remaining configuration files for all deleted packages

Dpkg-l | grep ^ rc | awk'{print $2}'| tr ["\ n"] ["] | sudo xargs dpkg-P-

System

View the kernel

Uname-a

View Ubuntu version

Cat / etc/issue

View modules loaded by the kernel

Lsmod

View PCI Devic

Lspci

View USB Devic

Lsusb

Check the status of the network card

Sudo ethtool eth0

View CPU information

Cat / proc/cpuinfo

Display current hardware information

Lshw

Hard disk

View the partition of the hard drive

Sudo fdisk-l

Check the remaining space on the hard drive

Df-h df-H

View directory footprint

Du-hs directory name

The flash drive cannot be uninstalled.

Syncfuser-km / media/usbdisk

Memory

View current memory usage

Free-l

Process

Check what processes are currently in place

Ps-A

Kill a process

Kill process number (that is, the number of the first column in ps-A) or killall process name

Force to kill a process (used when the above kill process is unsuccessful)

Kill-9 process number or killall-9 process name

View the real-time status of the current process

Top

View files opened by the process

Lsof-p

ADSL

Configure ADSL

Sudo pppoeconf

ADSL manual dialing

Sudo pon dsl-provider

Activate ADSL

Sudo / etc/ppp/pppoe_on_boot

Disconnect ADSL

Sudo poff

View dial log

Sudo plog

The network

Check the address of the network card according to IP

Arping IP address

View the current IP address

Sudo ifconfig eth0 | awk'/ inet addr/ {split ($2m x, ":"); print x [2]}'

View the IP address of the current public network

W3m-no-cookie-dump ip.loveroot.com | grep-o'[0-9]\ {1Magne3\}\. [0-9]\ {1Magne3\}\. [0-9]\ {1Magne3\}\. [0-9]\ {1Magne3\}'

View the program currently listening to port 80

Lsof-I: 80

View the physical address of the current network card

Sudo arp-a | awk'{print $4} 'sudo ifconfig eth0 | head-1 | awk' {print $5}'

Let the network support nat now

Sudo echo 1 > / proc/sys/net/ipv4/ip_forwardsudo iptables-t nat-I POSTROUTING-j MASQUERADE

View routing information

Netstat-rnsudo route-n

Manually add and delete a route

Sudo route add-net 192.168.0.0 netmask 255.255.255.0 gw 172.16.0.1sudo route del-net 192.168.0.0 netmask 255.255.255.0 gw 172.16.0.1

The method of modifying the MAC address of Network Card

Sudo ifconfig eth0 down # close the network card sudo ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE # and then change the address to sudo ifconfig eth0 up # and start the network card

Service

Add a service

Sudo update-rc.d service name defaults 99

Delete a service

Sudo update-rc.d service name remove

Temporarily restart a service

/ etc/init.d/ service name restart

Temporarily shut down a service

/ etc/init.d/ service name stop

Start a service temporarily

/ etc/init.d/ service name start

Set up

Configure which default Java to use

Sudo update-alternatives-config java

Modify user profile

Sudo chfn userid

Set up a proxy for apt

Export http_proxy= http://xx.xx.xx.xx:xxx

Modify system login information

Sudo vim / etc/motd

Chinese

Convert the file name from GBK to UTF8

Sudo apt-get install convmv convmv-r-f cp936-t utf8-notest-nosmart *

Convert the contents of the file from GBK to UTF8

Iconv-f gbk-t utf8 $I > newfile

File

Quickly find a file

Whereis filenamefind directory-name file name

View file types

File filename

Displays the contents of the last 6 lines of the xxx file

Tail-n 6 xxx

Find the file that contains the xxx string

Grep-l-r xxx.

Find commands about xxx

Apropos xxxman-k xxx

Transfer files through ssh

Scp-rp / path/filename username@remoteIP:/path # copy local files to the server scp-rp username@remoteIP:/path/filename / path # download remote files from the server to the local

See which applications read and write a file

Lsof file name

Compress

Decompress xxx.tar.gz

Tar-zxvf xxx.tar.gz

Decompress xxx.tar.bz2

Tar-jxvf xxx.tar.bz2

Compress the aaa bbb directory to xxx.tar.gz

Tar-zcvf xxx.tar.gz aaa bbb

Compress the aaa bbb directory to xxx.tar.bz2

Tar-jcvf xxx.tar.bz2 aaa bbb

Nautilus

Show hidden files

Ctrl+h

Show address bar

Ctrl+l

Special URI address

* computer:///-all mounted devices and networks * network:///-browse available networks * burn:///-a virtual directory of data burning CDs/DVDs * smb:///-available windows/samba network resources * x-nautilus-desktop:///-desktop projects and icons * file:///-local files * trash:///-this Local recycling bin directory * ftp://-FTP folder * ssh://-SSH folder

View installed fonts

Type "fonts:///" in the address bar of nautilus, and you can view all the fonts of this machine.

program

Show the running information of the program in detail

Strace-f-F-o outfile

Date and time

Set date

# date-s mm/dd/yy

Set time

# date-s HH:MM

Write time to CMOS

Hwclock-systohc

Read CMOS time

Hwclock-hctosys

Console

Switch between different consoles

Ctrl + ALT + ← Ctrl + ALT + →

Specify console switch

Ctrl + ALT + Fn (nRU 1x 7)

Scroll under the console

SHIFT + pageUp/pageDown

Console screenshot

Setterm-dump n (NRV 1x 7)

Database

Mysql's database is stored in a place

/ var/lib/mysql

Export and import data from mysql

Mysqldump database name > file name # export database mysqladmin create database name # create database mysql database name < file name # import database

What if I forget mysql's root password?

Sudo / etc/init.d/mysql stopsudo mysqld_safe-- skip-grant-tables & sudo mysqladmin-u user password' newpassword''sudo mysqladmin flush-privileges

Modify mysql's root password

Sudo mysqladmin-uroot-p password 'your new password'

Other

Download website documentation

Wget-r-p-np-k http://www.21cn.com-r: set up a server-side directory structure locally;-p: download all pictures showing HTML files;-np: download only the contents of the specified directory and its subdirectories at the target site;-k: convert non-relative links to relative links.

Thank you for reading! This is the end of this article on "what are the classic commands in linux?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report