Common instructions for CentOS actual combat development (long-term update)

Create, delete, move, copy

1. Create a new folder

mkdir filename

Create a new folder named test under home

view source1 mkdir /home/test

2. New text

Create a new test.sh script under home

 vi /home/test.sh

3. Delete files or folders

-r is to recursively delete the directory and its subdirectories in the parameter table, the directory will be emptied and deleted.

The user is usually prompted when deleting a directory containing a write-protected file.

-f is to delete all files in the directory without prompting the user.

rm -rf /home/test

4. Move files or folders

mv [options] 源文件或目录 目标文件或目录

Example:

1. Move all files, directories and subdirectories under the hscripts folder/directory to the tmp directory

mv hscripts tmp


Analysis: In the above command, if the tmp directory already exists, the mv command will move all files, directories and subdirectories under the hscripts folder/directory to the tmp directory. If there is no tmp directory, it will rename the hscripts directory to the tmp directory.

2. Move multiple files/more requests to another directory

mv file1.txt tmp/file2.txt newdir

This command moves the file1.txt of the current directory and the file2.txt of the tmp folder/directory to the newdir directory.

parameter:

-i: Operate interactively. If the mv operation will result in overwriting the existing target file, the system asks whether to overwrite, and the user is required to answer "y" or "n", which can avoid overwriting the file by mistake.

-f: Suppress interactive operations. The mv operation does not give any instructions when overwriting an existing target file. After specifying this parameter, the i parameter will no longer work.

5. Copy files or folders

cp [options] 来源档(source) 目的檔(destination)

Parameters:
-a : equivalent to -pdr;
-d : if the source file is the attribute of the link file (link file), copy the attribute of the link file instead of the file itself;
-f : the meaning of force, if When there is duplication or other doubts, the user will not be asked, and the copy will be forced;
-i: If the destination file (destination) already exists, it will first ask whether it is a real action when overwriting!
-l : create a hard link link file instead of copying the file itself;
-p : copy along with the attributes of the file instead of using the default attributes;
-r : recursively continue copying, for directory Copy behavior;
-s : Copy as a symbolic link file (symbolic link), that is, a "shortcut" file;
-u : Only update the destination if the destination is older than the source!
Finally, it should be noted that if there are more than two source files, the last destination file must be a "directory"!

Example:

1. Copy two files:

cp file1 file2

The above cp command copies the contents of the file file1.php to the file file2.php.

2. Backup the copied files:

cp -b file1.php file2.php

Create a backup file file2.php~ of the file file1.php with the symbol '~'.
3. Copy folders and subfolders:

cp -R scripts scripts1

The cp command above copies the folder and subfolders from scripts to scripts1.

6. Create a directory

mkdir 文件名
mkdir /var/www/test

 

Modify view text content

edit file

vi 文件名

exit without saving

Esc
:q

Force quit without saving

Esc
:q!

exit and save

Esc
:wq

Force quit and save

Esc
:wq!

 

mount hard disk

Mount the hard disk under Windows with dual systems. After installing ntfs-3g, execute the following command, where /dev/sdc1 is the hard disk name /root/desktop/windowsC is the mount location:

mount -t ntfs-3g /dev/sdc1 /root/桌面/windowsC

 

install uninstall 

yum

when installing a software

yum -y install httpd

When installing multiple similar software

yum -y install httpd*

When installing multiple non-similar software

yum -y install httpd php php-gd mysql

When uninstalling a software

yum -y remove httpd

When uninstalling multiple similar software

yum -y remove httpd*

When uninstalling multiple non-similar software

yum -y remove httpd php php-gd mysql

RPM 

RPM install operation
command:

rpm -i 需要安装的包文件名

An example is as follows:

rpm -i example.rpm 安装 example.rpm 包;
rpm -iv example.rpm 安装 example.rpm 包并在安装过程中显示正在安装的文件信息;
rpm -ivh example.rpm 安装 example.rpm 包并在安装过程中显示正在安装的文件信息及安装进度;

RPM query operation
command:

rpm -q …

Additional query commands:
a query all installed packages The following two additional commands are used to query the information of the installation package;
i display the information of the installation package;
l display the directories in which all files in the installation package are installed;
s display the installation version The status of all files in and which directories are installed; the following two additional commands are used to specify whether the installation package or the installed files need to be queried;
p is the information of the installation package;
f is the installed package Information about a file;
for example:

rpm -qa | grep tomcat4 查看 tomcat4 是否被安装;
rpm -qip example.rpm 查看 example.rpm 安装包的信息;
rpm -qif /bin/df 查看/bin/df 文件所在安装包的信息;
rpm -qlf /bin/df 查看/bin/df 文件所在安装包中的各个文件分别被安装到哪个目录下;

RPM uninstall operation
Command:

rpm -e 需要卸载的安装包

Before uninstalling, you usually need to use the rpm -q ... command to find out the name of the installation package that needs to be uninstalled.
An example is as follows:

rpm -e tomcat4 卸载 tomcat4 软件包

RPM upgrade operation
command:

rpm -U 需要升级的包

An example is as follows:

rpm -Uvh example.rpm 升级 example.rpm 软件包

RPM verify operation
command:

rpm -V 需要验证的包

An example is as follows:

rpm -Vf /etc/tomcat4/tomcat4.conf

The output information is similar to the following:

S.5….T c /etc/tomcat4/tomcat4.conf

Among them, S indicates that the file size has been modified, and T indicates that the file date has been modified. Due to space limitations, please refer to the rpm help file for more verification information: man rpm
RPM other additional commands
–force to force operations such as forced installation and deletion;
–requires to display the dependencies of the package;
–nodeps to ignore the dependencies and continue the operation

 

The firewall is turned on by default and cannot be accessed. CentOS7 turns off the firewall:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

 

After installing Anaconda, open Anaconda Navigator:

anaconda-navigator

 

After installing and configuring jupyter notebook, open jupyter notebook:

jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

 

Open the MySQL service:

service mysqld start

 

The root user cannot open the Chromium browser and needs to fill in the shortcut command of Chromium as follows, where the location of /root/my_chromium needs to be created manually:

chromium-browser --no-sandbox --user-data-dir=/root/my_chromium

 

When running the Java website, it prompts that the port is occupied. Most of the reason is that the JVM has not been shut down normally, so the port cannot be opened when Tomcat is started again. At this time, run the following two commands:

ps -ef|grep java|grep -v grep(查看java进程,记下JVM的进程号)

kill -9 JVM的进程号(杀死占用端口的JVM进程)

 

The desktop is stuck, kill the desktop process, and she will pull it up again:

killall -9 gnome-shell

 

View current location

pwd

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324996671&siteId=291194637