Contos7 commonly used commands

`` Python `
CentOS commonly used commands:

View all operational units: systemctl list-units

View all cells: systemctl list-units --all

View all started service: systemctl list-units --type = service corresponding to the previous chkconfig --list

Check whether to enable, for example, a firewall: systemctl is-enabled firewalld.service

Check whether to run, such as a firewall: ystemctl is-active firewalld.service or systemctl status firewalld.service

Stop Firewall: systemctl stop firewalld.service

Start Firewall: systemctl start firewalld.service

Restart the firewall: systemctl restart firewalld.service

Heavy-duty firewall: systemctl reload firewalld.service

Note: When we use systemctl the start, restart, stop and reload commands, we do not get any output from the terminal to the content, only the status command can print output.

 

Service boot from the start: systemctl enable httpd

Service does not boot from the start: systemctl disable httpd

Use systemctl orders to kill service: systemctl kill firewalld.service

 

Obtain a current CPU allocation services, such as firewalls: systemctl show -p CPUShares firewalld.service

Obtain a service (httpd) the list of dependencies: systemctl list-dependencies httpd.service

 

22 open firewall ports: iptables -I INPUT -p tcp --dport 22 -j ACCEPT

View Host Name: hostnamectl status --static

 

Check the name of a service:

systemctl list-units |grep XXX

```

# CentOS7 set of common commands

These two days have been carried out first experience of CentOS 7.2, swollen with a variety of learning commands, but in fact most of the DOS and is the same, but the expression command may be a bit different, after all, these are not a thing out of ~

Ado, directly on the command and resolve!

## commonly used commands

### file and directory operations

| Command | parsing |
| ----------------------- | -------------------- ---------------------------------------- |
| cd / Home | enter '/ home 'directory |
| cd .. | go back one level |
| cd ../ .. | return to the two directories |
| cd - | return to the last directory |
| cp file1 file2 | copy file1 to file2 |
| cp -a dir1 dir2 | copy a directory |
| cp -a / tmp / dir1 |. copy a directory to the current working directory (on behalf of the current directory.) |
| LS | view the files in a directory |
| LS -a | show hidden file |
| -l LS | show details |
| LS -lrt | displayed in chronological files (a detailed list L, r represents the reverse ordering, t represents a time-ordered) |
| pwd | display operation path |
| mkdir dir1 | Creating 'dir1' directory |
| mkdir dir1 dir2 | create two directories simultaneously |
| mkdir -p / tmp / dir1 / dir2 | create a directory tree |
| mv dir1 dir2 | move / rename a directory |
| RM -f file1 | delete 'file1' |
| Rm -rf dir1 | delete directory 'dir1' and its subdirectories content |

### view file contents

| Command | parsing |
| ------------- | ------------------------------ ------ |
| CAT file1 | forward view the contents of a file from the first byte |
| head -2 file1 | the first two lines to view a file |
| More file1 | view the contents of a long file |
| tac file1 | view the contents of a file in reverse, starting from the last row |
| tail -3 file1 | view a file's last three lines |
| vi file | open and browse files |

### text processing

| Command | parsing |
| -------------------- | ----------------------- ------------------------------------- |
| grep str / tmp / the Test | in the file '/ tmp / test 'Find "str" |
| grep ^ str / tmp / the Test | in the file' Find the line "str" beginning / tmp / test 'in |
| grep [0-9] / tmp / the Test | Find '/ tmp / test' file all lines that contain numbers |
| grep str -r / tmp / * | in the directory '/ tmp' and its subdirectories to find "str" |
| diff file1 file2 | find two files the differences |
| the sdiff file1 file2 | to compare two files of different ways |
| VI file | i parsing operation to enter text edit mode to edit text mode Esc to exit: w preserve the current modification: q quit without saving vi: wq save The current changes and exit vi |

### query

| Command | parsing |
| -------------------------------------------- ---- | --------------------------------------------- --- |
| the Find / -name file1 | from '/' began to enter the root file system to find files and directories |
| the Find / -user user1 | find files and directories belonging to the user 'user1' of |
| the Find / Home / user1 - name * .bin | in the directory '/ home / user1' looks to '.bin' files ending in |
| the Find / usr / bin the -type f -atime +100 | Find has not been used in the past 100 days to perform file |
| the Find / usr / bin the -type f -mtime -10 | Find is created or modified within 10 days of file |
| the locate * .ps | seek to '.ps' end of the file, first run 'updatedb' command |
| find -name '* [ch] .' \ | xargs grep -E 'expr' | Find 'expr' in the current directory and its subdirectories all .c and .h files |
| -print0 the Find the -type f \ | xargs -r0 grep -F 'expr' | Find 'expr' in the regular files in the current directory and its subdirectories in |
| the Find -maxdepth 1 the -type f \ | xargs grep -F 'expr' | looks in the current directory ' expr '|

### compression, decompression

| Command | parsing |
| ------------------------------- | ------------ ------------------------------------------------ |
| bzip2 file1 | compress file1 |
| bunzip2 file1.bz2 | decompression file1.bz2 |
| gzip file1 | compress file1 |
| gzip -9 file1 | maximize compression file1 |
| gunzip file1.gz | decompression file1.gz |
| tar -cvf archive.tar file1 | file1 packed into the archive.tar (-c: establish compressed file; -v: displays all process; -f: use file name, is a must, is the last parameter) |
| tar -cvf archive. tar file1 dir1 | put file1, dir1 packaged into archive.tar |
| the tar -tf archive.tar | display the contents of a package |
| the tar -xvf archive.tar | release a package |
| the tar -xvf archive.tar -C / tmp | compressed package release to the / tmp directory |
| zip file1.zip file1 | create a zip format archive |
| zip -r file1.zip file1 dir1 | files and directories compressed into a zip archive format |
| Unzip file1.zip | decompressing a zip format archive to the current directory |
| test.zip the unzip -d / tmp / | decompressing a zip format archive to the / tmp directory |

### yum installer

| Command | parsing |
| ------------------------------ | ------------- -------------------------------------- |
| yum -y install [Package Penalty for] | download and install a rpm package |
| yum localinstall [package.rpm] | install an rpm package, use your own repositories to resolve all the dependencies |
| yum -y update | update all rpm packages that are currently installed on the system |
| yum update [ package] | upgrade a rpm package |
| yum the Remove [package] | remove a rpm package |
| yum List | List all packages currently installed on the system |
| yum Search [package] | Search package rpm warehouse |
| yum clean [package] | package Clear the cache directory (/ var / cache / yum) under the |
| Clean yum headers | delete all the header files |
| yum Clean All | delete all cache packages and headers |

### network-related

| Command | parsing |
| -------------------------------------------- --- | ---------------------- |
| ifconfig eth0 | display an Ethernet card configuration |
| ifconfig eth0 192.168.1.1 Netmask 255.255.255.0 | configuration IP address of the NIC |
| ifdown eth0 | disable 'eth0' network equipment |
| ifup eth0 | enable 'eth0' network equipment |
| iwconfig eth1 | displaying a wireless network card configuration |
| iwlist Scan | display wireless |
| ip addr show | display card IP address |

### system-related

| Command | parsing |
| -------------------------------------------- - | -------------------------------------------- |
| su - | switch to root permissions (su with distinction) |
| the shutdown -h now | off |
| the shutdown -r now | restart |
| Top | list using the most CPU resources linux tasks (enter q to quit) |
| pstree | to tree diagram display program |
| man ping | View reference Manual (such as ping command) |
| passwd | Change password |
| df -h | show disk usage |
| CAL -3 | display the previous month, the current month and the next calendar month |
| CAL 10 1988 | specified month display, year calendar |
| -date DATE '1970-01-01 UTC seconds the 1,427,888,888' | seconds respect to a phase transition into 1970-01-01 00:00 time |

## XSheel 5 related operations

### Forms shortcuts

| Command | parsing |
| -------------- | ----------------------------- ------------------------------- |
| Ctrl + U | before deleting the cursor to the beginning of character |
| Ctrl + k | delete before cursor to end of line characters |
| Ctrl + c | cancel the current command line input, the equivalent Break + Ctrl |
| Ctrl + a | move the cursor to the beginning of the line (ahead of line), equivalent to the usual Home button |
| the Ctrl + E | cursor to the end of the line (End of line) |
| move the cursor forward (forward) a character position | | the Ctrl + F
| the Ctrl + B | cursor back (Backward) moves one character |
| Ctrl + l | clear the screen, equivalent to execute the clear command |
| Ctrl + r | display: No. prompt, find relevant history command (reverse-i-search) based on user input |
| Ctrl + w | deleted from the current cursor position to the front which begins with the word (word) of |
| Ctrl + t | before the cursor position two characters exchange |
| Ctrl + the y-| paste the last deleted word |
| Ctrl + Alt + d | show Desktop |
| Alt + b | cursor back (Backward) moves to the previous word |
| the Alt + D | cursor position is deleted from the Currently located at the end of the word |
| Alt + F2 | Run |
| Alt + F4 | close the current window |
| Alt + F9 | minimize the current window |
| Alt + F10 | maximize the current window |
| Alt + the Tab | Switch windows |
| Alt + Left | moving window (or the mouse wheel to scroll at the bottom of the taskbar) |

### Operation Tips

Middle mouse button: paste the highlighted text. (Using the left mouse button to select the text. Point the cursor to where want to paste the text. Click the middle mouse button to paste.)

Tab: command line completion. This approach can be used when using a shell prompt. Type the first few characters of a command or file name, and then press the [Tab] key, it will automatically fill all orders or show match all the commands typed characters.

In the space of the scroll bar click the mouse button: Scroll to the screen that is that place.

Press / to enter the location on the desktop or the file manager, open the file manager.

In vi or Firefox, press / to enter the fast search mode.

Web site links, and images can be dropped directly onto the desktop or catalog can be downloaded immediately.

Directly to the File Manager and drag the file path name of the terminal you can get full in the terminal.

## Conclusion

In fact, to learn Linux operating is not very difficult thing, in the ordinary course, having problems, learn to go online to find the answer would be a very good tool! thank you all!

Guess you like

Origin www.cnblogs.com/Zhchan/p/11099087.html