In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the Linux system commands commonly used in the development process, which have a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Shutdown / restart / logout common commands function shutdown-h now shutdown immediately shutdown-h shutdown shutdown-h + 10 scheduled time shutdown shutdown-h + 10 scheduled time shutdown shutdown-c cancel shutdown shutdown-r now restart shutdown-r 1010 minutes after restart shutdown-r regularly restart reboot restart init 6 restart init 0 shut down telinit 0 shut down poweroff shut down halt shutdown immediately Data synchronization to disk logout exit login Shell
Note: for example, if the computer is also turned off, what's the difference between shutdown, poweroff, halt and init 0? If you are interested, you can find out for yourself. There is a difference between them.
System information and performance view
In fact, a lot of commands are used here, because once the system or background service has a problem, we often log on to check it, including a lot of system information, such as: system version, kernel version, processor architecture, computer name, environment variables, user situation, load, memory usage, disk information, process, network connection …
Commonly used commands use uname-a to view kernel / OS/CPU information uname-r view kernel version uname-m view processor architecture view processor architecture view hostname view computer name who display current login system user name whoami display user name at login whoami display current user name cat / proc/version view linux version information cat / proc/cpuinfo view CPU information cat / proc/interrupts view break cat / proc/ Loadavg View system load uptime View system uptime, Number of users, Load env view system environment variables lsusb-tv view system USB device information lspci-tv view system PCI device information lsmod view loaded system modules grep MemTotal / proc/meminfo view total memory grep MemFree / proc/meminfo view amount of free memory free-m view memory usage and swap usage date display system date time cal 2021 display 2021 calendar top dynamic display cpu/ memory / process vmstat 1 20 system status is taken every 1 second Iostat 20 times to check io read / write / cpu usage sar-u 1 10 query cpu usage (once per second, total 10 times) sar-d 1 10 query disk performance disks and partitions
These are some common commands that are closely related to daily use. In the Windows system, we can click the mouse and view it on the graphical interface, but in Linux we should be proficient in using commands to view, such as: various partition information view, disk usage, file and directory size, various mount and uninstall.
Commonly used commands use fdisk-l to view all disk partitions swapon-s to view all swap partitions df-h to view disk usage and mount point df-hl to view disk remaining space du-sh / dir to view specified directory size du-sk * | sort-rn to display files and directory sizes mount / dev/hda2 / mnt/hda2 mount hda2 disk mount-t ntfs / dev/sdc1 / mnt/usbhd1 specify file system Unified mount (e.g. ntfs) mount-o loop xxx.iso / mnt/cdrom mount iso file mount / dev/sda1 / mnt/usbdisk mount USB disk / flash device umount-v / dev/sda1 unmount umount-v / dev/sda1 by device name unmount fuser-km / mnt/hda1 by mount point force unmount (with caution) users and user groups
User groups and users themselves are also a very important concept in the Linux system, this part of the command is mainly about: user's CRUD, user group's CURD, and then it also includes checking users, switching users, changing passwords, checking user login logs.
Common commands function useradd codesheep to create user userdel-r codesheep delete user usermod-g group_name user_name modify user group usermod-aG group_name user_name add user to group usermod-s / bin/ksh-d / home/codepig-g dev codesheep modify user codesheep login Shell, Home directory and user group groups test view test user group groupadd group_name create user group groupdel group_name delete user group groupmod-n new_name old_name rename user group su-user_name fully switch to a user environment passwd modify password passwd codesheep modify a user's password w view active user id codesheep view specified user information last view user login log crontab-l view current user account Set the task cut-d:-F1 / etc/passwd to view all users of the system cut-d:-F1 / etc/group view all group networks and process management of the system
As a back-end developer, we usually use these commands with a high probability, such as: viewing the network, viewing connections, viewing port services, configuring network cards / firewalls / routing tables / DNS, viewing and filtering processes, collecting system status, and some system performance monitoring and troubleshooting commands. Wait. These commands are useful and frequently used when the back-end developer connects to the company server to troubleshoot problems.
Common commands use ifconfig to view network interface properties ifconfig eth0 to 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 view status information of TCP/UDP ifup eth0 enable eth0 network devices ifdown eth0 disable eth0 network devices iptables-L view iptables rules ifconfig eth0 192.168.1.1 netmask 255.255.255.0 configure ip address dhclient Eth0 enables eth0route add-net 0 gw Gateway_IP in dhcp mode to configure the default gateway route add-net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 configure a static route to the network '192.168.0.0/16'route del 0ta 0 gw Gateway_IP delete static route hostname view hostname host www.codesheep.cn resolution hostname nslookup www.codesheep.cn query DNS record Check whether domain name resolution is normal ps-ef View all processes ps-ef | grep codesheep filters out the processes you need kill-s namekill specified name process kill-s pidkill specified pid process top real-time display process status vmstat 1 20 take system status every second, take iostat 20 times to check io read and write / cpu usage sar-u 1 10 query cpu usage (once per second) Total 10 times) sar-d 1 10 query disk performance common system service commands
Such commands are often exposed to, for example, we often install and deploy a variety of basic programming environments and services, such as JDK, MySQL database, redis cache, nginx server.
Common command functions chkconfig-- list lists system services service status view a service service start starts a service service stop terminates a service service restart restarts a service systemctl status views a service systemctl start starts a service systemctl stop terminates a service systemctl restart restarts a service systemctl enable starts self-startup systemctl disable shuts down self-startup file and directory operations
This kind of commands are all the basic operations used by the Linux system, and they are also the most frequently used commands, about file operations, directory operations, and paths. For example: a variety of high-frequency operations on files and directories, create, view, find, delete, rename, copy, soft connection, quick positioning and search. Wait. They are all high-frequency practical orders.
Common commands use cd to enter a directory cd. Go back to the superior directory cd... /... Cd back to the previous two-level directory into the personal home directory cd-back to the previous step where the directory pwd displays the current path ls view file directory list ls-F view directory contents (display file or directory) ls-l view file and directory details list ls-a view hidden file ls-lh display permissions ls-lSrmoretree view file and directory tree structure mkdir create directory mkdir dir1 dir2 simultaneously create two Directory mkdir-p / tmp/dir1/dir2 create directory tree rm-f file1 delete 'file1' file rmdir dir1 delete' dir1' directory rm-rf dir1 delete 'dir1' directory and its contents rm-rf dir1 dir2 delete both directories and their contents mv old_dir new_dir rename / move directory cp file1 file2 replication file cp dir/*. Copy all the files in a directory to the current directory cp-a dir1 dir2 copy directory cp-a / tmp/dir1. Copy a directory to the current directory ln-s file1 link1 create a soft link to a file / directory ln file1 lnk1 create a physical link to a file / directory find /-name file1 start with the directory search file / directory find /-user user1 search user user1 file / directory find / dir-name * .bin search the directory / dir for files with the .bin suffix locate keywords quickly locate the file locate *. Mp4 Look for the file at the end of .mp4 whereis halt displays the path of a binary / executable file which halt looks up the binary file under the system directory chmod ugo+rwx dir1 settings directory owner (u), Group (g) and others (o) read (r) write (w) execute (x) permissions chmod go-rwx dir1 remove group (g) and others (o) read and write permissions to directory chown user1 file1 change file owner attribute chown-R user1 dir1 change directory owner attribute chgrp group1 file1 change file group chown user1:group1 file1 change file owner and group file viewing and processing
This part of the command is mainly about file processing or text processing, for example, as a programmer, the most operations are code source files, various fancy viewing, comparing, adding, deleting, replacing, merging. Wait, a series of quick operations.
Commonly used commands use cat file1 to view the contents of the file cat-n file1 to view the contents and mark the number of lines cat xxx.txtawk 'NR%2==1'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 is similar to the more command But allow reverse operation head-2 file1 to view the first two lines of the file tail-2 file1 view the file after two lines tail-f / log/msg real-time view the content added to the file grep codesheep hello.txt look for the keyword codesheepgrep ^ sheep hello.txt in the file hello.txt find the content that begins with sheep in the file grep [0-9] hello.txt Select all lines containing numbers in the hello.txt file sed 's/s1/s2/ G 'hello.txt replaces S1 in the hello.txt file with s2sed'/ ^ $/ d 'hello.txt to delete all blank lines sed' / * # / d from the hello.txt file / ^ $/ d 'hello.txt removes all comments and blank lines from the hello.txt file sed-e '1d' hello.txt excludes the first line sed-n' / S1 hello.txt from the file hello.txt view the line containing only the keyword "S1" sed-e's / * $/ / 'hello.txt deletes the white space character at the end of each line sed-e'sUniverse hello.txt only from the document Vocabulary S1 and keep all remaining sed-n '1pint 5p 5q' hello.txt to view the content from line 1 to line 5 sed-n'5p 5Q 'hello.txt view the contents of line 5 paste file1 file2 merge two files or columns paste-d' + 'file1 file2 merge the contents of two files or columns Sort the contents of two files with "+" distinguishing sort file1 file2-usort file1 file2uniq-dcomm-1 file1 file2 compare the contents of two files (remove the contents of 'file1') comm-2 file1 file2 compare the contents of two files (remove the contents of' file2') comm-3 compare the contents of two files (remove the common parts of the two files) package and decompress the contents of two files
This part is mainly about the packaging, compression and decompression of files or directories, involving several compressed package formats and files, and this part of the command is also used very frequently.
Common commands use zip xxx.zip file to compress into zip package zip-r xxx.zip file1 file2 dir1 compress multiple files + directories into zip package unzip xxx.zip extract zip package tar-cvf xxx.tar file create uncompressed tar package tar-cvf xxx.tar file1 file2 dir1 multiple files + directories pack tar tar-tf xxx.tar view contents of tar package tar-xvf xxx.tar extract tar package tar-xvf xxx.tar-C / dir extract tar package to the specified Directory tar-cvfj xxx.tar.bz2 dir create bz2 package tar-jxvf xxx.tar.bz2 extract bz2 package tar-cvfz xxx.tar.gz dir create gzip package tar-zxvf xxx.tar.gz extract gzip package bunzip2 xxx.bz2 extract bz2 package bzip2 filename file gunzip xxx.gz extract gzip package gzip filename file gzip-9 filename maximum compression
Then there are some common package manager commands. First of all, everyone should know what a package manager is.
To put it this way, if there is no such thing as a package manager, it is probably just the software installation on the Linux system, which will probably dissuade a lot of users, because a lot of software dependency processing will drive people crazy. So to put it simply, we can understand the package manager as a component that is used to support the installation, uninstallation, upgrade and query of software on the Linux system, so it is generally a set of tool commands for users.
We usually use the most widely used, for example, the red hat packet structure RPM package manager, such as RedHat, CentOS and other systems are used, the typical command is the rpm command, yum command; then is the DPKG package manager, such as Debain, Ubuntu and other systems are used, typical commands such as dpkg commands, apt software tools.
Rpm package management commands commonly used commands use rpm-qa to view installed rpm packages rpm-Q pkg_name query a rpm package rpm-Q-- whatprovides xxx shows which package provides the xxx function rpm-Q-- whatrequires xxx shows which package depends on rpm-Q-- changelog xxx display xxx package change records rpm-qi pkg_name view the details of a package rpm-qd pkg_name query a package location Provided documentation rpm-qc pkg_name View the configuration file provided by the installed rpm package rpm-ql pkg_name View which files are installed in a package rpm-qf filename check which package a file belongs to which package rpm-qR pkg_name query package rpm-ivh xxx.rpm install rpm package rpm-ivh-- test xxx.rpm test install rpm package rpm-ivh-nodeps xxx.rpm ignore dependencies rpm-e when installing RPM package Xxx uninstall package rpm-Fvh pkg_name upgrade determine installed rpm package rpm-Uvh pkg_name upgrade rpm package (if not installed) rpm-V pkg_nameRPM package details Verification yum package Management commands Common commands function yum repolist enabled display available source warehouse yum search pkg_name search package yum install pkg_name download and install package yum install-downloadonly pkg_name only download and do not install yum list display There are packages yum list installed view current system installed packages yum list updates view list of packages that can be updated yum check-update view upgradeable packages yum update update all packages yum update pkg_name upgrade specified packages yum deplist pkg_name lists package dependencies yum remove pkg_name delete packages yum clean all remove caches yum clean packages clear cached packages yum clean headers clear cached headerdpkg package management commands Commonly used commands use dpkg-c xxx.deb to list the contents of the deb package dpkg-I xxx.deb install / update deb package dpkg-r pkg_name remove deb package dpkg-P pkg_name remove deb package (do not retain configuration) dpkg-l View deb package installed in the system dpkg-l pkg_name display package general information dpkg-L pkg_name view deb package installation file dpkg-s pkg_name view package details dpkg-unpack xxx. Deb unlock the contents of the deb package apt software tools commonly used commands apt-cache search pkg_name search package apt-cache show pkg_name get package overview information apt-get install pkg_name installation / upgrade package apt-get purge pkg_name uninstall software (including configuration) apt-get remove pkg_name uninstall software (excluding configuration) apt-get update update package index information apt-get upgrade update installed package apt -get clean Clean the cache Thank you for reading this article carefully I hope the article "what are the Linux system commands commonly used in the development process" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.