Linux tips you don’t know

Time:2021-9-18

Linux tips you don't know

1. Quick jump command – Z

If you have to enter a folder with a deep directory every time, like the following:
Linux tips you don't know

> #cd /root/py/auto/fabric

Isn’t it annoying to enter multiple directory names every time? Here’s a very convenient operation to replace it with a Z command:

The source code of Z is here:https://github.com/rupa/z/blo…

You only need to copy the source code to the z.sh file in the user directory, then add “source / path / to / z.sh” at the end of the. Bashrc file, and finally use:

#source z.sh
perhaps

#. .bashrc
To jump to a directory, directly use the Z + directory name (this directory must be entered before).

Z this script will assign a weight to the directory you enter each time, and then adjust it to the directory you enter according to the weight.
Linux tips you don't know

2. Configure VIM

If you often write shell, python or C under the terminal, most of them should use vim. As a VIM party, how can you do without a cool interface for writing code? So, do you want the following interface? Including code completion, quick search for element files, directory tree, py and C header file completion and other functions.
Linux tips you don't know

Download the VIM configuration file and unzip it in the user’s root directory. Please search for the use method by yourself. Whether you can operate it very skillfully depends on your mastery of vim.

3. Set the prompt for MySQL

Sometimes it is necessary to connect to multiple servers at the same time and operate different mysql. Since the MySQL command line does not have a user or host prompt by default, it is easy to misoperate, so you can add the following configuration to the / etc / my.cnf file to display the MySQL prompt:

[mysql]prompt=”\[email protected]\h : \d \r:\m:\s>”

Re entering MySQL is like this:
Linux tips you don't know

4. View the current system version

You may often use the following methods to view the version of the system:

[[email protected] ~]# cat /etc/issueCentOS release 6.8(Final)Kernel \r on an
\m [[email protected] ~]# cat /etc/redhat-release CentOS release 6.8(Final)
[[email protected] ~]# cat /etc/issue.net CentOS release 6.8(Final)Kernel \r on
an \m

However, these files may expose the information of the system, generally empty the files, or such files may be tampered with. Then use the following command, which may be the most accurate command to view version information:
Linux tips you don't know
Linux tips you don't know
After CentOS installation, an RPM package with CentOS release + version number will be installed by default.

5. View system disk
What should I do if I want to check the disk usage of a system? The most frequently used commands are fdisk and DF, but look at the following commands:
Linux tips you don't know

Is it more intuitive than the results of fdisk and DF commands.

If you want to know more technical knowledge, scan the code and pay attention to me

Linux tips you don't know