Common centos commands

Source: Internet
Author: User
CentOS commands are often used in our use. As a result, we have compiled a comprehensive list of some of CentOS 'most commonly used and important commands. These CentOS commands are described below.

One: view the CPU using CentOS common commands
More /proc/cpuinfo | grep "model name" grep "model name" /proc/cpuinfo [root@localhost /] Intel (R) Pentium (R) Dual CPU e2180@2.00 GHz

Two: use CentOS common command to view memory
Grep MemTotal /proc/meminfo grep MemTotal /proc/meminfo | cut-f2-d: free-m |grep "Mem" | awk '{print $2}'

Three: use CentOS common command to see whether the CPU is 32-bit or 64-bit to see the CPU number (32 or 64) getconf LONG_BIT
Four: use CentOS common command to view the current version of Linux more /etc/redhat-release cat /etc/redhat-release

Five: use CentOS common command to view the kernel version uname-r uname-a

Six: use CentOS common command to check the current time date the above has introduced how to synchronize the time

Seven: use CentOS common command to view hard disk and partition df-h fdisk-l you can also view partition du-sh you can see the total occupied space du/etct-sh you can see the size of this directory

Eight: use CentOS common command to view the installed software package to view the installed software package cat-n /root/install.log more /root/install.log | wc-l check which packages rpm-qa rpm-qa | wc-l yum list installed | wc-l No reason was found.

Nine: use CentOS common command to view the keyboard layout cat /etc/sysconfig/keyboard cat /etc/sysconfig/keyboard | grep KEYTABLE | cut-f2-d =

X: use CentOS common command to view selinux status sestatus sestatus | cut-f2-d: cat /etc/sysconfig/selinux

Eleven: use CentOS common command to view IP, MAC address in the ifcfg-eth0 file you can see the MAC, gateway and other information. Ifconfig cat /etc/sysconfig/network-scripts/ifcfg-eth0 |grep IPADDR cat /etc/sysconfig/network-scripts/ ifcfsconfig/eth0 |grep IPADDR | cut-f2-d = ifconfig eth0 b| grep "inet addr:" |awk '{print $2}' | cut-c 6-ifconfig | grep 'inet addr:' | grep -v '' | cut-d: -f2 | awk '{print $1}' look at the gateway cat /etc/sysconfig/network look at DNS cat /etc/resolv.conf

Twelve: echo $LANG $LANGUAGE cat /etc/sysconfig/i18n using CentOS common command

Thirteen: use the CentOS common command to check the time zone and UTC time cat /etc/sysconfig/clock

14: use CentOS common command to check hostname hostname cat /etc/sysconfig/network to modify hostname is to modify this file, and it is better to modify the host file as well.

Fifteen: use CentOS common command to view uptime 09:44:45 up 67 days, 23:32... It seems that it was really a problem with the network segment. My machine was turned on 67 days ago. # system resource usage vmstat 1 - S m procs -- -- -- -- -- -- -- -- -- -- - the memory -- -- -- -- -- -- -- -- -- -- -- -- -- swap -- -- -- -- -- -- the IO -- -- system -- -- -- -- -- -- CPU -- -- -- -- -- -- r. b. SWPD free buff cache si sobibo in cs us sy id wa st 0 0023319977800 42511 3 0 96 00 00 1029 856 13 1 86 0 dmidecode |

Unzip hostname or cat /etc/sysconfig/network how does pkill mysqld kill the mysql process find/type f-size + 100000k-ls query size over 100M

17: NO1. Create file system type [root@rehat root]# umount /dev/sdb1 [root@rehat root]# mkfs-t ext3 /dev/db1 [root@rehat root]# mount /dev/sdb1 /practice NO1. Set your notes to be visible only to yourself [root@rehat root]# chmod go-rwx test.txt or [root@rehat root]# chmod 700 test.txt NO2. CentOS common command for changing the owner of a file or folder is chown. Only root can use NO1. Change the owner of a file [root@rehat root]# chown Jim :usergroup test.txt NO2 Chown Jim: usergroup-r test cat NO1 common CentOS command for viewing the contents of text files Add the line number [root@rehat root] # cat-b test.txt NO3. Merge the contents of the two files [root@rehat root] # cat test1.txt test2.txt > test_new.txt NO4. TXT test1.txt test2.txt test_total.txt NO5. Empty the contents of a file [root@rehat root]# cat /dev/null > test.txt NO6. Create a new file [root@rehat root]# cat > new Newfile [root]# vi newfile.txt NO2. Modify file [root]# vi test.txt test.txt Command mode, edit mode NO4. Enter vi in command mode, press Insrt key to enter edit mode, press ESC to enter command mode, can not be edited in command mode, can only enter the command NO5.

18: batch replacement files were migrated by SVN today, and I found that the original path was written wrong, which resulted in the failure to access the source server. Please check. SVN /entries to roughly understand the contents. For fin $(find./ type f-name 'entries') do sed-i "s/202\.68\.134\.18/202\.68\.134\.34/g" $f done sed: Sed "s/sourcestring/newstring/g" $$f the sourcestring file f convert into newstring, output to the terminal. S for search and replace, and /g for global. Sed - I $f means to modify directly in $f. Sed-iback $f means that the modified file is saved as $fback sed. All regular expressions in sed must be qualified with a strict escape character \ : "\ /! Please use \ "\/ \\! Escaped. \n means newline

19. When the shell variable string manipulation mono runs under Linux, apache+mod_mono sometimes needs to load the Assembly must be configured in GAC, The following is a script to complete this function CD bin for fin $(find./ -name "*.dll") do gacutil-i $f done if you want to unload these assemblies in bulk from the GAC, you can do the following: for fin $(ls *.dll) do gacutil-u ${f%% %. ${f%%. DLL} ${f%%

Twenty, view the current connection to netstat -an

Restart the shutdown -r now reboot the system so that the Settings take effect shutdown -h now shutdown reboot poweroff shutdown

Edit rc.local file #vim /etc/rc.d/rc.local # du-sh # view size of specified directory # uptime # view system running time, number of users, load # cat /proc/loadavg # view system load # iptables -L # view firewall # route-n # view routing table # netstat - LNTP # view all listening ports # Netstat -antp # view all established connections # netstat -s # view network statistics # w # view active user # id # view specified user information # last # view user log-in log # cut-d: -f1 /etc/passwd # view all users of the system # cut-d: -f1 /etc/group # view all groups of the system # crontab -l # view the scheduled tasks of the current user # chkconfig - list # list all system services # chkconfig - list | grep on # list all system services started under centOS common SSH command directory operations: rm-rf mydir CD mydir CD - CD.. CD ~ mv tools tool ln-s tool bac cp-a tool /home.vpser/WWW Tar XVF wordpress.tar tar-tvf myfile.tar tar cf tool.tar tool tar CFZ vpser.tar. Wget wget - c process management: the meaning of ps - aux ps command output fields: [list] [*] USER, the process owner USER name. [*]PID, process number, can uniquely identify the process. [*]%CPU, the percentage of CPU time and total time consumed by the process since the last refresh. [*]%MEM, the percentage of memory used by the process. [*]VSZ, virtual memory size used by process, in K. [*]RSS, the total amount of physical memory consumed by a process, in K. [*]TTY, the terminal name associated with the process. [*]STAT, the state of the process, with (R - run or ready to run; S - sleep state; I - free; Z - freeze. D - uninterrupted sleep; W- process has no resident page; T stop or track. These are the letters. [*]START, process START time. [*]TIME, the total CPU TIME used by the process. [*]COMMAND, the COMMAND line to be executed. [/list] ps-aux | grep nginx kill 1234 killall nginx Vim action: H/j/k/l: left/right/on/under moved a w: move back word (how many words adding digital mobile) b: word moving forward (front how many words) digital mobile e: back to the end of the term ge: move forward to the end of the term $: 0: at the end of the row row first tx: x and moved to find the bank to the right there (upper left) 33 G: move to the files line 33 gg: file first line G: file with 33% : 33% of the files in h/M/l: The first/middle/last line of the screen zt/zz/zb: the current line moves to the first/middle/bottom of the screen : find up (after add keywords) n: a conform to the record of editors: I: transition to the insert mode x: delete the current characters. : repeat the last modification operations (with PS CTRL + f filter) u: undo CTRL - R: redo p: will delete character is inserted into the current position (put) to exit the save: : q: exit: q! : exit without saving ZZ: exit after saving :e! : abandon the modification and edit the following command again. When installing centos, check the HTTP server, and install apache by default.

Mysql, PHP services.

I. apache start stop service HTTPD start start; Service HTTPD stop closed; Service HTTPD restart. Note that under centos, apche is not started by default.

Method 1: directly connect the apache version in the system with the command to view, the premise of the current system installed apache, when the RPM package installation, check whether RPM installed RPM -qa |grep HTTPD can see whether the system installed apache, directly enter the command, apache ectl-v can display the version; Method 2: the tar packages to install apache, the system is the tar package compiled installation check method is/usr/local/apache2 / bin/apachectl -v (pay attention to the path for the custom installation), shows the content as follows: Server built: Aug 26 2009 15:29:07 /usr/local/apache2/bin/ is the full path to the Apache source installation, which is based on your installation location. 3. Mysql start and stop service mysqld start; Service mysqld stop. 5. Check whether mysql is started: netstat - NAT, if there is 3306 for mysql port, it is started. Centos default installation of apache in /etc/httpd site root directory is /var/ww/html /, if the internal establishment of files, you need to give apache access to the file permissions, otherwise it can not be accessed. 8, to view the data storage address of mysql: first enter mysql, and then enter show variables like '%dir%' to see the relevant data. Whereis mysql? Whereis mysql? Whereis mysql? Whereis mysql? You can switch to other services later, such as HTTPD (apache) and PHP. Shutdown -h now shutdown -r now restart immediately. Create a level directory in the current path [root@rehat root]# mkdir test NO2. Create a level directory in the current path [root@rehat root]# mkdir-p mytest/test1/test1_1 NO3 The CentOS command cp NO1. Copy the files from the specified directory to the current directory and rename them [root@rehat root]# cp ~/. Bashrc bashrc_bak NO2. Regardless of whether the current directory contains the file [root@rehat root]# cp-f ~/. Bashrc bashrc NO2. Copy the specified directory to the current directory [root@rehat root]# cp-r /root/test. NO3. Copy the files of the specified directory to the specified directory [root@rehat root]# cp ~/.bashrc /bak/.bashrc NO4. If no parameters are specified, the target file and source file properties may not be consistent. If you want to keep two folders in sync, if one file changes, the other file changes, but make sure that both files are up to date. Cp-u/SRC /. Bashrc /. Bashrc /. Bak_src /. In this way, even if the original file is deleted, as long as the link file is not deleted, it is still not deleted in the storage space. TXT test.txt_hlnk path operation CentOS common command CD PWD NO1. Display the current path [root@rehat root]# PWD NO2. Return to the user's home directory [root@rehat root]# CD NO3 [root @ rehat root] # CD.. Find NO1. Find all the files in the current user's home directory. [root@rehat root]# find.-perm 644-exec ls-l {} \; NO3. In order to find all ordinary files with the length of 0 in the system, and list their complete paths; Find/size 0-type f-exec ls-l {} \; NO4. Look for normal files in the /var/logs directory that changed 7 days ago and ask them before deleting them; Find /var/log-mtime + 7-type f-ok rm-i {}; NO5. Find all files belonging to the root group on the system for /; Find / -group root-exec ls-l {} \; No6.find will delete the admin.log file [root@rehat root]# find.-name "admin.log[0-9][0-9][0-9]" - atime-7-ok rm {} \; NO7. To find all the directories in the current file system and sort them. -type d | sort NO8.This includes the hidden file [root@rehat root]# ls-a NO2. Show the details of the file [root@rehat root]# ls-l NO3. Show the current directory and all subdirectory information [root@rehat root]# ls-rl NO4 The common CentOS command mv for moving or changing the name of a file/folder is similar to the cp command. In this way, under test2, there will be two files test.txt and text.txt~. Test.txt ~ is the backup file, and test.txt is the new file NO2. Directly overwrite [root@rehat root]# mv-f test.txt test2/ NO3. When the source and the target both have the same file, if the source file is newer than the target, it will be moved. Otherwise, do not move [root@rehat root]# mv-u test.txt test2/ NO4. Change the file name [root@rehat root]# mv test.txt test2.txt NO5. Displays the usage of all storage system Spaces, as well as the file system type of the storage system. Displays the space usage of the specified file system. If you only want to see the file system on the machine, use the following command [root@rehat root]# df-ahlt NO5. Check the disk usage of a file system Du-ch NO3. View the size of the file [root]# du-h test1.txt NO4. View the size of multiple files at the same time [root]# du-h test1.txt test2.txt temporarily tidy, then large area, large range, large density, large scraping collection.
Some commonly used Centos commands

Tag: HTTP IO OS USES ar for file data art

The original address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.