1. view the process ps-a and killPID2. add the scheduled task crontab-e. for example: 3021 *** servicehttpdrestart restart apache at every day to view cr
1. View process ps-
Kill PID
2. add a scheduled task crontab-e
Example: 30 21 *** service httpd restart
Restart apache at every day
View crontab status
Service crond status
3. find/-name jiangkong.zip
4. centos host name Modification Command
You need to modify either of them:/etc/sysconfig/network and/etc/hosts. modifying only one of them will cause system startup exceptions. Switch to the root user first. Vi/etc/sysconfig/network open the file with any of your favorite editors, which contains a line of HOSTNAME = localhost. modify localhost. localdomain is your host name. Vi/etc/hosts www.2cto.com open the file, there will be a line 127.0.0.1 localhost. localdomain localhost. Here, 127.0.0.1 is the local loop address, and localhost. localdomain is the host name (hostname), that is, what you want to modify. Localhost is the alias of the host name (alias). It appears at the Konsole prompt. Modify the second item to your host name. The third item is optional. After the above two files are modified, they cannot take effect immediately. If it takes effect immediately, you can use hostname your-hostname for temporary modification. it only modifies the host name temporarily and will be restored after the system is restarted. However, the modification of the above two files is permanent, and the new host name will be obtained after the system is restarted. Finally, check the host name uname-n after restart.
5. View and uninstall software in centos
Rpm-qa | grep VirtualBox
Rpm e VirtualBox-4.2-4.2.10_84104_el6-1.i686
I. View cpu using common CentOS commands
More/proc/cpuinfo | grep "model name"
Grep "model name"/proc/cpuinfo
[Root @ localhost/] # grep "CPU"/proc/cpuinfo
Model name: Intel (R) Pentium (R) Dual CPU E2180 @ 2.00 GHz
Model name: Intel (R) Pentium (R) Dual CPU E2180 @ 2.00 GHz
If you feel more comfortable to watch
Grep "model name"/proc/cpuinfo | cut-f2-d:
II. View memory using common CentOS commands
Grep MemTotal/proc/meminfo | cut-f2-d: free-m | grep "Mem" | awk '{print $2 }'
III. use common CentOS commands to check whether the cpu is 32-bit or 64-bit
View CPU bits (32 or 64)
Getconf LONG_BIT
4. use common CentOS commands to view the current linux version
More/etc/redhat-release
Cat/etc/redhat-release
5. view the kernel version using common CentOS commands
Uname-r
Uname-
6. use common CentOS commands to view the current time
Date. the preceding section describes how to synchronize the time.
7. View hard disks and partitions using common CentOS commands
Df-h
Fdisk-l
You can also view partitions.
Du-sh
The occupied space is displayed.
Du/etc-sh
The directory size is displayed.
8. use common CentOS commands to view installed software packages
View the software packages installed during system installation
Cat-n/root/install. log
More/root/install. log | wc-l
Check the software packages that have been installed.
Rpm-qa
Rpm-qa | wc-l
Yum list installed | wc-l
But it is strange that the number of installation packages I query through rpm and yum is not the same. No reason is found.
9. view the keyboard layout using common CentOS commands
Cat/etc/sysconfig/keyboard
Cat/etc/sysconfig/keyboard | grep KEYTABLE | cut-f2-d =
10. use common CentOS commands to view selinux information
Sestatus
Sestatus | cut-f2-d:
Cat/etc/sysconfig/selinux
11: Use common CentOS commands to view ip addresses and mac addresses
In the ifcfg-eth0 file you can see mac, Gateway and other information. Ifconfig cat/etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR cat/etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut-f2-d = ifconfig eth0 | grep "inet addr: "| awk '{print $2}' | cut-c 6-ifconfig | grep 'inet addr: '| grep-v' 127. 0.0.1 '| cut-d:-f2 | awk' {print $1} 'view gateway cat/etc/sysconfig/network view dns cat/etc/resolv. conf 12: Use common CentOS commands to view the default language
Echo $ LANG $ LANGUAGE
Cat/etc/sysconfig/i18n
12: Use common CentOS commands to check the time zone and whether UTC time is used
Cat/etc/sysconfig/clock
Thirteen: Use common CentOS commands to view the host name
Hostname
Cat/etc/sysconfig/network
Modifying the host name is to modify this file, and it is recommended that you also modify the host file.
14. run common CentOS commands to view the startup time
Uptime
09:44:45 up 67 days, 23:32 ,...
It seems that this is indeed a problem with the network segment. I started the machine 67 days ago.
# System resource usage
Vmstat 1-S m procs ----------- memory ---------- --- swap -- ----- io ---- system -- ----- cpu ------ r B swpd free buff cache si so bi bo in cs us sy id wa st 0 0 233 199 778 0 0 0 25 1 1 3 0 0 0 0 0 0 233 199 778 0 0 0 1029 856 13 1 86 0
Among the many Linux Terminal commands, we should introduce them by category. here we will first talk about the file directory class, driver mounting class, program installation class, compression and decompression class, and process control class, all Linux Terminal commands are frequently used here. it should be much easier to get familiar with these commands.
I. file directory
1. create a directory: mkdir directory name
2. delete the empty directory: rmdir directory name
3. delete the subdirectory unconditionally: rm-rf directory name
4. change the current directory: cd directory name (go to the user's home directory: cd ~; Go to the upper-level Directory: cd -)
5. view your own directory: pwd
6. view the current directory size: du
7. display the directory file list: ls-l (-a: add an implicit directory)
Blue: Directory; Green: executable file; red: compressed file; light blue: linked file; gray: other files; red: Wrong link file
8. browse File: more file name. txt; less file name. txt
9. copy the file: The target file of the cp Source File (-r: contains directory)
10. find the file: (1) find (2) locate command name
11. link: (1) create a hard link: ln to link the source file (-d: create a directory link); (2) create a symbolic link: ln-s to link the source file
II. driver mounting
1. check hard disk usage: df-T-h
2. check the disk partition: fdisk-l
3. mount the hardware and software areas: mount-t/dev/fdx | hdax/mnt/directory name
Among them: modos -- FAT16; vfat -- FAT32; ntfs -- NTFS; optical drive -- iso9660
Supported Chinese names: mount-o iocharset = x/dev/hdax/mnt/directory name (where: x = cp936 or
Mount the optical drive: mount-t auto/dev/cdrom/mnt/cdrom
Mount the ISO File: mount-t iso9660-o loop xxx. iso/path
4. unmount: umount/mnt/directory name
Unmount all: umount-
5. create a file system: mkfs-t/dev/hdxx. Ftype: ext2, ext3, and swap
III. program installation
1. RPM Package installation: (1) install rpm-ivh somesoft. rpm
(2) reverse install rpm-e somefost. rpm
(3) query rpm-q somefost or rpm-qpi somefost. rpm (Where: p is not installed; information contained in I)
(4) query the location after installation: rpm-ql somefost. rpm
(5) upgrade and install: rpm-Uvh somesoft. rpm
(6) force installation: rpm-ivh -- nodeps somesoft. rpm or rpm-ivh -- nodeps -- force somesoft. rpm
2. install the source code package:
Read README
Basic usage (1) configuration: extract the directory./configure
(2) compile: extract the make
(3) installation: make install in the decompressed Directory
3. install src. rpm
IV. compression and decompression
1.tar.gz class: (1) extract: tar-xvzf file .tar.gz((2)tar.gz to tar: gzip-d file .tar.gz (2) compression: gzip file to be compressed
2.tar uncompressed class: (1) unpack: tar-xvf file .tar; (2) package: tar-cvf file .tar file list
3.zip: (1) decompress: unzip file. zip-d dir; (2) compressed: zip zipfile list of files to be compressed
4.bz2: (1) decompress: bunzip2 file. bz2 or bzip2-d File. bz2; (2) compress: bzip2 file to be compressed
5. z class: (1) decompress: uncompress file. z; (2) compress: compress file
5. Process control
1. list the current process ID: ps-auxw
2. terminate processes: (1) terminate a single process: kill process ID
(2) terminate all processes of the program: Killall program name
(3) terminate the X-Window Program: xkill
3. View resource usage: (1) top (2) free (3) dmesg
4. view the environment variable value: env
5. restart: (1) reboot (2) Ctrl Alt Del (3) init 6
6. shutdown: (1) shutdown-h now (2) halt (3) init 0
7. switch the desktop: switchdesk gnome | KDE |...
Next we will introduce program running, user account, vi editing, network services, and other Linux Terminal commands.
In order to allow other new users like me to get started faster and not afraid of "commands", we will sort out the following frequently used commands for reference:
(The following experiences mainly come from Ubuntu, Red Hat, and CentOS. if there is any inconsistency in other Linux versions, please leave a message to correct them)
--------------- Directory -----------------
1. ifconfig-IP view management command
2. run the man command and the -- help parameter to view the command help document.
3. cd directory switch command
4. ls and ll (ls-l) browse directories and file commands
5. find resource search command
6. sudo and su use the root account permission command
7. passwd password Modification Command
8. apt-get and yum software installation and uninstallation commands
9. service management and ps process viewing commands
10. chkconfig service management commands (not included in the system, need to be installed separately)
11. vi text editing tool
12. chmod file and directory permission management commands
13. copy, move (rename), and delete commands for cp, mv, rm files and directories
14. scp Remote Copy Command
15. wget remote resource access and download commands
16. ssh remote logon command
------------------ Details of this article --------------------
1. ifconfig-IP view management command
Put the IP view management command in the first introduction,
It is because you know the IP address of the installed linux system that you can log on to the system through remote ssh for learning and management.
You can enter "ifconfig" or "ifconfig-a" to view the system IP address and press enter.
Note that it is not ipconfig in windows, but ifconfig!
For more information, see "how to view the local IP address in Linux" and "how to modify the configuration file in Ubuntu to set the static IP address".
Note: If CentOs is used, the/sbin PATH is not added to the environment variable $ PATH by default. to view the value of this environment variable, run echo $ PATH ),
You can enter the absolute path of the command to execute it, that is, "/sbin/ifconfig ".
Other commands are as follows.
2. run the man command and the -- help parameter to view the command help document.
Before proceeding, I would like to introduce a very useful command and parameter, which is used to view the help documentation of the command.
If you want to see the detailed parameters of the ls command and how to use them,
Enter "ls -- help" or "man ls" and press enter,
The system will print out all the use instructions related to ls.
Almost all commands can use the -- help parameter, or use the man command to view their usage methods.
Note: When the man command is used to view the help document of a command, exit the help document and enter the letter "q.
3. cd directory switch command
Like cd in windows's doscommand, cd is used to switch the current directory.
Usage example:
After logging on to linux, it will be in the user directory of the current user by default. if the user name is user, the absolute path of the directory will be "/home/user /";
If you want to switch to the/etc directory, enter the command "cd/etc" and press enter.
4. ls and ll (ls-l) browse directories and file commands
Compared with the dir command in windows, it is not difficult to understand its usage.
It must be noted that there are no ll (two lower-case L) commands in Ubuntu, but they can be replaced by the ls-l command.
5. find resource search command
Find is equivalent to the file search function opened by the Ctrl + F shortcut in windows.
If you want to find a file test.html in the entire folder,
Input: "find/-name test.html"
Wildcards can be used in the searched file name, for example, "find/-name *. html".
6. sudo and su use the root account permission command
Generally, the root account is not used,
Because it is the highest privilege user in linux, a slight carelessness may cause serious consequences.
Occasionally, some operations require temporary use of the root account permission. what should I do?
You can add sudo to the command. for example, use the root account to open an apache configuration file: sudo vi/etc/httpd/conf/httpd. conf.
The first time you use sudo, you will be prompted to enter the current user's password. if you use sudo for a while, you do not need to enter the password again.
In addition to using sudo, you can also use the user switching command: su to switch to the root account,
Enter the command: "su" or "su root". press enter and enter the password of the root account as prompted.
7. passwd password Modification Command
In Ubuntu, after the system is installed, the password of the root account is usually not set,
To use the root account for the first time, you must set a password for the root account.
Run "sudo passwd root" and press enter,
The system will prompt you to enter the new password of the root account twice. repeat the password twice.
You can use the new password to log on to the root account.
Related articles: Setting the root account password after Ubuntu installation
8. apt-get and yum software installation and uninstallation commands
New software is required when you are new to linux or a newly installed linux system.
A great charm of linux is that most of the open-source software you want to use,
Both Ubuntu and CentOs collect these open source software together,
It also provides a software management tool to help users easily download, install and configure the software.
Ubuntu provides apt-get, while CentOs (Red Hat) provides yum.
This section only describes how to use them to install a software,
For example, to install apache2, run the following command: "sudo apt-get install apache2" or "sudo yum install apache2".
Related articles: install the php Extension Library mcrypt, curl, and gd in Ubuntu
9. service startup stop management and ps process view commands
Linux also has the same concept of "service" as windows:
A software automatically runs on the background after the system is started. this software can be called a "service".
In linux, the command used to manage services is "service". generally, services support three parameters (start, stop, and restart): "start", "stop", and "restart".
If you restart the apache2 service, enter "sudo service apache2 restart".
Generally, "ps-ef" is used to view all processes currently;
To filter out the process name, add the grep command: "ps-ef | grep http"
10. chkconfig service management commands (not included in the system, need to be installed separately)
The service management here is different from the above service start, stop, and restart management,
The preceding service commands can be regarded as the startup, stop, and restart management of a software,
While chkconfig manages the service itself, such as setting a service to run automatically upon startup, or setting a service to run without startup, or even delete it from the service.
This tool can be installed through "sudo apt-get install chkconfig" or "yum install chkconfig.
For example, in CentOs, set apache2 to boot automatically: "chkconfig -- level 2345 httpd>
Note: the service name of apache2 may not be apache2, but httpd.
Command: chkconfig -- list to view all services
Related articles: CentOS: Building an apache + mysql + php environment and configuring a virtual directory for apache
11. vim text editing tool
Vi (vim) can be seen as a notepad software similar to windows. it is a plain text editor, but its function is far more powerful than notepad.
Vim is too powerful. here we will only introduce its basic usage:
Open a file named test.html with "vi test.html",
The following parameters can be the absolute or relative paths of one or more files (for details, refer to this article: VI commands for opening and editing multiple files ).
In vim, enter the letter "I" to enter the editing mode. I indicates insert;
Press Esc in edit mode to exit edit mode;
The letters "H", "J", "K", and "L" respectively indicate that the cursor is "left", "up", "down", and "right;
Enter the colon character ":", that is, press "shift + semicolon;" to enter the command mode;
In command mode, enter "w" and press enter to save the file;
In command mode, enter "x" and press enter to save the file and exit vim;
In command mode, enter "q" and press enter, or press Shift + Z + Q to save the file and exit vim;
For other common operations, see vim related documents.
Related articles: vim simple settings in linux and vim color scheme colorscheme settings
Vim common folding operations and settings automatic saving and folding view, vi save and edit session and Operation record information
12. chmod file and directory permission management commands
In linux, file permissions include read, write, and execution, which correspond to "r", "w", and "x" respectively ";
For example, to add execution permissions to a script file test. sh, enter "chmod + x test. sh"
The plus sign "+" indicates that this permission is added, and the minus sign "-" indicates that this permission is removed.
If you want to set the directory test and all the files in it to read/write and execute by anyone,
Enter the command: "chmod-R 777 test"
Here, the Read r value is 4, the write w value is 2, and the execution x value is 1.
13. copy, move (rename), and delete commands for cp, mv, rm files and directories
Copy a file or directory command: cp. for example, if test.htmlis copied to test2.html, enter "cp test.html test2.html ";
Command for moving files or directories: mvcommand, for example, to move test.html to the upper-level Directory, enter "mv test.html ../";
Command for deleting a file or directory: rm. for example, delete the file test.html and enter "rm test.html ";
If the preceding three operations are for directories, add the-R parameter.
14. scp Remote Copy Command
It is often used to copy a file from one linux server to another,
Using the scp Remote Copy command is very convenient and convenient.
For example, copy the test.html file of the local machine to the/usr/test Directory of the machine whose IP address is 192.168.1.102,
You can enter: "scp test.html root@192.168.1.102:/usr/test/", and then press Enter,
Enter the password of the root account on the machine 102 as prompted.
15. wget remote resource access and download commands
If you download a file from the web to your local machine,
Enter "wget http://www.qq.com/qq.exe”". then, go back to the bus to confirm,
Upload the qq.exefile to the current directory named qq.exe.
16. ssh remote logon command
If you remotely log on to another server through ssh from a linux server,
This situation is usually used when multiple servers are used.
Because a firewall is often set up for the server and cannot directly access a server on the Internet,
To be accessible, you must first connect to a machine outside the firewall and then connect to the server in the firewall.
If you use the root account to connect to a machine with the IP address 192.168.1.102, enter "ssh 192.168.1.102-l root ",
Enter the password of the root account and then press Enter to confirm.
If the ssh port of the server is not the default port 22 and is a custom port 1234, you can add the parameter-p after the command,
For example, "ssh 192.168.1.102-l root-p 1234"