• 周四. 12月 1st, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Hard core! High frequency Linux command big summary, suggest collection~

[db:作者]

1月 6, 2022

front said

I remember sharing with you a wave of personal daily work not long ago 、 Study 、 Development 、 Write words 、 In the process of making videos, etc , Some useful and efficient online tools and websites , And put your own Browser favorites bookmarks offline files are exported to you .

A lot of little friends have good feedback from the background , After the bookmark is imported , A lot of tools really work , It mainly saves a lot of time to find resources and organize .

Continue to share today , Recently, I have spent a lot of time in the development process of some commonly used Linux The system command has made a big arrangement , Form a common high frequency Linux Quick check memo . With it , Still afraid Linux Can’t you remember the common operations and commands of the operating system ?

Let’s go straight to the dishes .

notes : this paper GitHub
https://github.com/rd2coding/Road2Coding Included , There’s something in it that I sort out
6 Big programming direction ( Position ) The self-study route of + The knowledge points are sorted out
The interview examination site
My resume
A few hardcore books pdf note , as well as
My life as a programmer .


To turn it off / restart / Cancellation

Common commands effect
shutdown -h now Shut down immediately
shutdown -h 10 10 Shut down in minutes
shutdown -h 11:00 11:00 To turn it off
shutdown -h +10 Scheduled time to shut down (10 Minutes later )
shutdown -c Cancel the specified time shutdown
shutdown -r now restart
shutdown -r 10 10 Restart in minutes
shutdown -r 11:00 Restart regularly
reboot restart
init 6 restart
init 0 Turn off immediately.
telinit 0 To turn it off
poweroff Turn off immediately.
halt To turn it off
sync buff Data synchronization to disk
logout Log out Shell

Be careful : For example, it’s also turned off ,shutdown、poweroff、halt、init 0 What’s the difference ? If you are interested, you can learn about it by yourself , They are different .


System information and performance view

In fact, the command here is usually used very much , Because once the system or back office service has problems , We often have to go up and check , Including a lot of system information , such as : System version 、 Kernel version 、 Processor architecture 、 Computer name 、 environment variable 、 User information 、 Load condition 、 Memory usage 、 Disk information 、 process 、 network connections …

Common commands effect
uname -a View kernel /OS/CPU Information
uname -r View kernel version
uname -m Look at the processor architecture
arch Look at the processor architecture
hostname View computer name
who Show users currently logged in to the system
who am i Displays the user name at the time of login
whoami Show current user name
cat /proc/version see linux Version information
cat /proc/cpuinfo see CPU Information
cat /proc/interrupts View interrupt
cat /proc/loadavg View system load
uptime View system running time 、 The number of users 、 load
env View the system’s environment variables
lsusb -tv Check the system USB Equipment information
lspci -tv Check the system PCI Equipment information
lsmod View the loaded system modules
grep MemTotal /proc/meminfo View total memory
grep MemFree /proc/meminfo View the amount of free memory
free -m Check memory usage and swap usage
date Display system date time
cal 2021 Show 2021 Calendar watch
top Dynamic display cpu/ Memory / Progress, etc
vmstat 1 20 Every time 1 The system status is collected every second , Mining 20 Time
iostat see io Reading and writing /cpu usage
sar -u 1 10 Inquire about cpu usage (1 Seconds at a time , common 10 Time )
sar -d 1 10 Query disk performance

Disks and partitions

These are some common commands closely related to daily use , stay Windows We click the mouse in the system , You can see it on the graphical interface , But in Linux We should be proficient in using command to view , such as : View all kinds of partition information 、 Disk usage 、 File and directory sizes 、 Various mount and unload …

Common commands effect
fdisk -l View all partitions
swapon -s View all swap partitions
df -h Check disk usage and mount point
df -hl Check the remaining disk space
du -sh /dir View the specified directory size
`du -sk * sort -rn` The file and directory sizes are displayed in descending order
mount /dev/hda2 /mnt/hda2 mount hda2 disc
mount -t ntfs /dev/sdc1 /mnt/usbhd1 Specifies the file system type mount ( Such as ntfs)
mount -o loop xxx.iso /mnt/cdrom mount iso file
mount /dev/sda1 /mnt/usbdisk mount usb disc / Flash devices
umount -v /dev/sda1 Uninstall by device name
umount -v /mnt/mymnt Unload through mount point
fuser -km /mnt/hda1 Force uninstall ( Use with caution )

Users and user groups

Linux User groups and users themselves are also very important concepts in the system , This part of the order is mainly about : User CRUD、 User groups CURD、 And then it includes checking users 、 Switching users 、 Change password 、 Check the user login log …

Common commands effect
useradd codesheep Create user
userdel -r codesheep Delete user
usermod -g group_name user_name Modify user’s group
usermod -aG group_name user_name Add users to groups
usermod -s /bin/ksh -d /home/codepig –g dev codesheep Modify the user codesheep The login Shell、 Home directory and user groups
groups test see test User’s group
groupadd group_name Create user group
groupdel group_name Delete user group
groupmod -n new_name old_name Rename user groups
su – user_name Switch completely to a user environment
passwd Modify password
passwd codesheep Change a user’s password
w view active user
id codesheep View specified user information
last View user login log
crontab -l View scheduled tasks for the current user
cut -d: -f1 /etc/passwd View all users of the system
cut -d: -f1 /etc/group View all groups in the system

Network and process management

We develop as a back end , These commands are usually used with great probability , such as : Check out the Internet 、 View connections 、 View port services 、 Configure network card / A firewall / Routing table /DNS, View and filter processes , Acquisition system status , There are also some system performance monitoring and troubleshooting commands … wait . These orders , It’s very useful when the back-end development is connected to the company’s server for troubleshooting , It’s also used very often .

Common commands effect
ifconfig View network interface properties
ifconfig eth0 View the configuration of a network card
route -n View routing table
netstat -lntp View all listening ports
netstat -antp View all established connections
netstat -lutp see TCP/UDP Status information
ifup eth0 Enable eth0 Network devices
ifdown eth0 Ban eth0 Network devices
iptables -L View firewall settings
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 To configure ip Address
dhclient eth0 With dhcp Mode enable eth0
route add -net 0/0 gw Gateway_IP Configure the default gateway
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 Configure static routing to reach the network ‘192.168.0.0/16’
route del 0/0 gw Gateway_IP Delete static route
hostname View host name
host www.codesheep.cn Resolve host name
nslookup www.codesheep.cn Inquire about DNS Record , Check whether domain name resolution is normal
ps -ef View all processes
`ps -ef grep codesheep` Filter out the processes you need
kill -s name kill Process with specified name
kill -s pid kill Appoint pid The process of
top Real time display of process status
vmstat 1 20 Every time 1 The system status is collected every second , Mining 20 Time
iostat see io Reading and writing /cpu usage
sar -u 1 10 Inquire about cpu usage (1 Seconds at a time , common 10 Time )
sar -d 1 10 Query disk performance

Common system service commands

This kind of command is often used , For example, we often use it when we install and deploy various basic programming environments and services , For example, pretend to be JDK、MySQL database 、redis cache 、nginx The server …

Common commands effect
chkconfig --list List system services
service < service name > status Check out a service
service < service name > start Start a service
service < service name > stop Terminate a service
service < service name > restart Restart a service
systemctl status < service name > Check out a service
systemctl start < service name > Start a service
systemctl stop < service name > Terminate a service
systemctl restart < service name > Restart a service
systemctl enable < service name > Turn on self starting
systemctl disable < service name > Turn off auto start

File and directory operations

All these orders are Linux The basic operation of the system , It’s also the most frequently used commands , About file operation 、 About directory operations 、 About the path . such as : High frequency operations on files and directories , establish 、 see 、 lookup 、 Delete 、 rename 、 Copy 、 Soft connection 、 Quickly locate and find … wait . They’re all high-frequency practical commands .

Common commands effect
cd < Directory name > Enter a directory
cd .. Go back to the superior directory
cd ../.. Go back to the upper two levels
cd Enter personal home directory
cd – Go back to the previous Directory
pwd Show current path
ls Look at the list of file directories
ls -F Look at the contents of the catalog ( Shows whether it’s a file or a directory )
ls -l View a detailed list of files and directories
ls -a View hidden files
ls -lh Display permission
ls -lSr more View files by size / Catalog
tree Look at the tree structure of files and directories
mkdir < Directory name > Create directory
mkdir dir1 dir2 Create two directories at the same time
mkdir -p /tmp/dir1/dir2 Create a tree
rm -f file1 Delete ‘file1’ file
rmdir dir1 Delete ‘dir1’ Catalog
rm -rf dir1 Delete ‘dir1’ The catalog and its contents
rm -rf dir1 dir2 Delete both directories and their contents at the same time
mv old_dir new_dir rename / Mobile directory
cp file1 file2 Copy file
cp dir/* . Copy all files in a directory to the current directory
cp -a dir1 dir2 duplicate catalog
cp -a /tmp/dir1 . Copy a directory to the current directory
ln -s file1 link1 Create a pointing file / Soft links to directories
ln file1 lnk1 Create a pointing file / Physical links to directories
find / -name file1 Start with the directory and search for files / Catalog
find / -user user1 Search users user1 The file of / Catalog
find /dir -name *.bin In the catalog /dir China search has .bin Postfix file
locate key word Quick location of files
locate *.mp4 seek .mp4 Final document
whereis halt Display a binary file / Path to executable file
which halt Look for binary files in the system directory
chmod ugo+rwx dir1 Set directory owner (u)、 group (g) And others (o) The reading of (r) Write (w) perform (x) jurisdiction
chmod go-rwx dir1 Remove group (g) And others (o) Read and write permission to the directory
chown user1 file1 Change the owner property of the file
chown -R user1 dir1 Change the owner property of the directory
chgrp group1 file1 Change file group
chown user1:group1 file1 Change the owner and group of files

File viewing and processing

This part of the command is mainly about file processing or text processing , For example, we as a programmer , That operation most is the code source file , All kinds of fancy view 、 Compare 、 increase 、 Delete 、 Replace 、 Merge … And so on, a series of quick operations .

Common commands effect
cat file1 View file contents
cat -n file1 Look at the content and mark the number of lines
cat xxx.txt awk ‘NR%2==1’ Look at all the odd lines in the file
tac file1 Look back at the contents of the file from the last line
more file1 View the contents of a long file
less file1 similar more command , But reverse operation is allowed
head -2 file1 Look at the first two lines of the file
tail -2 file1 Look at the last two lines of the file
tail -f /log/msg See what’s added to the file in real time
grep codesheep hello.txt In the file hello.txt Search for keywords in codesheep
grep ^sheep hello.txt In the file hello.txt Find in sheep Content at the beginning
grep [0-9] hello.txt choice hello.txt All lines in the file that contain numbers
sed ‘s/s1/s2/g’ hello.txt take hello.txt In the document s1 Replace with s2
sed ‘/^$/d’ hello.txt from hello.txt Delete all blank lines in file
sed ‘/ *#/d; /^$/d’ hello.txt from hello.txt Delete all comments and blank lines in the file
sed -e ‘1d’ hello.txt From file hello.txt Exclude first line in
sed -n ‘/s1/p’ hello.txt View contains only keywords “s1” The line of
sed -e ‘s/ *$//’ hello.txt Delete the last blank character in each line
sed -e ‘s/s1//g’ hello.txt Remove only words from document s1 And keep the rest
sed -n ‘1,5p;5q’ hello.txt View from first line to 5 Row content
sed -n ‘5p;5q’ hello.txt Look at the first 5 That’s ok
paste file1 file2 Merge the contents of two files or two columns
paste -d ‘+’ file1 file2 Merge the contents of two files or two columns , Intermediate use “+” distinguish
sort file1 file2 Sort the contents of two files
sort file1 file2 uniq Take out the Union ( Keep only one duplicate line )
sort file1 file2 uniq -u Delete intersection , Leave the rest of the line
sort file1 file2 uniq -d intersect
comm -1 file1 file2 Compare the contents of the two files ( Remove ‘file1’ What it contains )
comm -2 file1 file2 Compare the contents of the two files ( Remove ‘file2’ What it contains )
comm -3 file1 file2 Compare the contents of the two files ( Remove the common parts of the two files )

Packaging and decompression

This part is mainly about the packing, compression and decompression of files or directories , Several kinds of compressed package formats and files are involved , This part of the command is also used very frequently in ordinary times .

Common commands effect
zip xxx.zip file Compression – zip package
zip -r xxx.zip file1 file2 dir1 Multiple files + The catalogue is pressed into zip package
unzip xxx.zip decompression zip package
tar -cvf xxx.tar file Create uncompressed tar package
tar -cvf xxx.tar file1 file2 dir1 Multiple files + Catalogue type tar package
tar -tf xxx.tar see tar The contents of the package
tar -xvf xxx.tar decompression tar package
tar -xvf xxx.tar -C /dir take tar Extract the package to the specified directory
tar -cvfj xxx.tar.bz2 dir establish bz2 Compressed package
tar -jxvf xxx.tar.bz2 decompression bz2 Compressed package
tar -cvfz xxx.tar.gz dir establish gzip Compressed package
tar -zxvf xxx.tar.gz decompression gzip Compressed package
bunzip2 xxx.bz2 decompression bz2 Compressed package
bzip2 filename Compressed files
gunzip xxx.gz decompression gzip Compressed package
gzip filename Compressed files
gzip -9 filename Maximum compression

Then there are some common package manager commands . First, what is a package manager , Everyone should know .

Let me put it this way , If there is no package manager , That’s probably just Linux Software installation on the system , I’m afraid many users will be dissuaded , Because a lot of software dependent processing can drive people crazy . So simply put , We can think of package manager as , Used for Linux Software installation on the system 、 uninstall 、 upgrade 、 Query supported components , So for users , It’s a set of tools and commands .

We usually use the most widely, such as , The bag structure of the red hat RPM Package manager , image RedHat、CentOS When the system is in use , The typical command is rpm command 、yum command ; Then is DPKG Package manager , image Debain、Ubuntu And so on , Typical commands like dpkg command 、apt Software tools .


rpm Package management command

Common commands effect
rpm -qa View installed rpm package
rpm -q pkg_name Query a rpm package
rpm -q –whatprovides xxx Show xxx Which package provides the functionality
rpm -q –whatrequires xxx Show xxx Which package does the function depend on
rpm -q –changelog xxx Show xxx Record of package changes
rpm -qi pkg_name See the details of a package
rpm -qd pkg_name Query the documents provided by a package
rpm -qc pkg_name View installed rpm The configuration file provided by the package
rpm -ql pkg_name Check which files are installed in a package
rpm -qf filename Check which package a file belongs to
rpm -qR pkg_name Query package dependencies
rpm -ivh xxx.rpm install rpm package
rpm -ivh –test xxx.rpm Test installation rpm package
rpm -ivh –nodeps xxx.rpm install rpm Ignore dependencies when packaging
rpm -e xxx Uninstall package
rpm -Fvh pkg_name Upgrade to determine the installed rpm package
rpm -Uvh pkg_name upgrade rpm package ( If not, it will be installed )
rpm -V pkg_name RPM Package details check

yum Package management command

Common commands effect
yum repolist enabled Show available source repositories
yum search pkg_name Search package
yum install pkg_name Download and install the package
yum install –downloadonly pkg_name Download only and do not install
yum list Show all packages
yum list installed Check the packages installed on the current system
yum list updates See the list of packages that can be updated
yum check-update Check out the upgradeable packages
yum update Update all packages
yum update pkg_name Upgrade the specified package
yum deplist pkg_name List package dependencies
yum remove pkg_name Remove package
yum clean all Clear cache
yum clean packages Clear cached packages
yum clean headers Clear cached header

dpkg Package management command

Common commands effect
dpkg -c xxx.deb List deb The contents of the package
dpkg -i xxx.deb install / to update deb package
dpkg -r pkg_name remove deb package
dpkg -P pkg_name remove deb package ( Do not keep configuration )
dpkg -l Check that… Is installed in the system deb package
dpkg -l pkg_name Show general information about the package
dpkg -L pkg_name see deb Package installation files
dpkg -s pkg_name View package details
dpkg –unpack xxx.deb Untie deb The contents of the package

apt Software tools

Common commands effect
apt-cache search pkg_name Search for packages
apt-cache show pkg_name Get an overview of the package
apt-get install pkg_name install / Upgrade package
apt-get purge pkg_name Uninstall software ( Including configuration )
apt-get remove pkg_name Uninstall software ( Not including configuration )
apt-get update Update package index information
apt-get upgrade Update installed packages
apt-get clean Clean cache

Offline documents

In addition to the above , This time, those high-frequency practical Linux The order was given , And made two forms of offline documents , Respectively PDF Format and high definition image format ,PDF It’s easy for the computer to see , High definition pictures are easy to view on your mobile phone , If you have nothing to do, you can take it out and have a look on your mobile phone 、 Have a look .

PDF The document looks like this :

High definition pictures look like this , There are more than a dozen , It contains hundreds of commands :

The document GitHub
https://github.com/rd2coding/Road2Coding Included .


after remember

Besides, a lot of efforts have been made recently , The programming learning resources for self use are sorted out .

It’s all pure liver , Directory as follows .

This content GitHub
https://github.com/rd2coding/Road2Coding Included , There’s something else in it that I sort out
6 Self study route of big programming direction + The knowledge points are sorted out
My resume
The interview examination site
A few hardcore books pdf note , as well as
My life as a programmer , welcome star.

Sorting is not easy to , Welcome to support , See you next time !

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注