
说明:日常高频使用,100%适用于CentOS7
ctrl + a ;ctrl + e #鼠标焦点到最前or最后
ctrl a ctrl k # 清除当前行
ctrl c # 结束命令,另起一行
ctrl + z #结束其他终端的输入输出
sudo chmod -R 777 /var/www # 快速赋予文件权限
cp -r # 递归复制
mkdir -p # 递归创建
创建软连l接 ln -s {实际文件} {软连接文件} # 软连接指向位置地址。
删除软链接 rm -rf ./test_chk_ln #注意不要多带/
find . -name "*.c" #将当前目录及其子目录下所有文件后缀为 .c 的文件列出来
find . -name share #将当前目录及其子目录下所有文件名为share的文件列出来
rm -rf !(file1|file2) #删除除了file1和file2的其他文件
free -h #以合适的单位显示内存使用情况
du -sh #查看目录文件大小
df -sh #查看磁盘使用情况
ps -ef | grep nginx#查看正运行的nginx进程
netstat -anp | grep ranger # netstat -anp:显示系统端口使用情况
lsof -i:80 #使用-i:port来显示与指定端口相关的网络信息
hostname -i #查看本机ip地址
systemctl stop mysqld #停止服务
systemctl restart mysqld #重启服务
systemctl status mysqld #服务状态查看
登录 mysql :mysql -u root -p
show databases;
use database_name; #使用数据库
show tables;
select user from mysql.user; #查看所有用户
desc table_name; #查看表结构
drop user user_name #删除用户
drop database database_name; #删除数据库
编辑 ~/.vimrc,添加set number #默认打开就显示行号
:set nu #显示行号 :setnonumer #关闭行号,方便复制
:n #跳转到文件第n行,需要回车
跳转到当前行的第一个字符按“0”,当前行行尾按“A” ;
跳到文本的最后一行,即“G”;跳到第一行的第一个字符:先按两次“g”。
:e!放弃所有修改,从上次保存文件开始在编辑
:u 撤销更改
/pattern 向下搜索 #继续搜索下一个
?pattern 向上搜索 #继续搜索上一个
全部删除:按esc键后,先按gg(到达顶部),然后dG
git branch -c
git branch -d local_branch_name
git push remote_name -d remote_branch_name
我想删除远程origin/test分支,所以我使用命令:git push origin -d test
git reset # git reset命令用于将当前HEAD复位到指定状态。一般用于撤消之前的一些操作(如:git add,git commit等)。
Git图解 https://mp.weixin.qq.com/s/FSBEM2GqhpVJ6yw9FkxnGA
快捷键 参考文章
tar #归档文件,方便传输。归档方式有 tar,gzip,bzip 归档为 tar,tar.gz,tar.bz等格式文件
# 普通归档
tar -cvf tecmint-14-09-12.tar /home/tecmint/
# use gzip
tar zcvf MyImages-14-09-12.tar.gz /home/MyImages
tar zcvf MyImages-14-09-12.tgz /home/MyImage
# use bz2
tar jcvf Phpfiles-org.tar.bz2 /home/php
tar jcvf Phpfiles-org.tar.tbz /home/php
tar jcvf Phpfiles-org.tar.tb2 /home/php
# untar 只有这一个命令
tar -xvf videos-14-09-12.tar.bz2
tar -xvf public_html-14-09-12.tar -C /home/public_html/videos/
# To list , 仅仅查看
tar -tvf uploadprogress.tar unzip
-x 文件列表 解压缩文件,但不包括指定的file文件。
-v 查看压缩文件目录,但不解压。
-t 测试文件有无损坏,但不解压。
-d 目录 把压缩文件解到指定目录下。
例如:unzip -x ./1.zip -d ../ #将当前目录下的1.zip解压到上级目录
// sz从远程传到本地 ,rz从本地传到远程
用法:rz -be
用法:scp -r local_file remote_username@remote_ip:remote_folder
Several file transfer commands under Linux sz rz sftp scp
Recently, I came into contact with some file transfer commands when deploying the system, and make a simple record:
1.sftp
Secure Ftp is a file transfer management tool based on the SSH security protocol. Because it is based on SSH, it will encrypt the user's password, data and other sensitive information during the transmission process, so it can effectively prevent the user information from being stolen during the transmission process, and has higher security than FTP. It is very similar to FTP in terms of function. It can not only transfer file data, but also remote file management (such as creating, deleting, viewing file lists, etc.). Although there is only one word difference between Sftp and ftp, the transmission protocols based on them are different. Therefore, neither sftp client can be used to connect to ftp server nor ftp client can be used to connect to sftp server.
Establish connection: sftp user@host
Upload files from local: put localpath
Download file: get remotepath
For local operations corresponding to remote, you only need to add "l" before the command, which is easy to remember.
For example: lcd lpwd lmkdir
2.scp
SCP: secure copy (remote file copy program) is also a file transfer command based on the SSH security protocol. Different from sftp, it only provides file transfer function between hosts, without file management function.
Copy local_file to remote_folder
scp local_file remote_user@host:remote_folder
Copy local_folder to remote remote_folder (need to add parameter -r recursion)
scp –r local_folder remote_user@host:remote_folder
The above command is written in reverse to remotely copy to the local
3.sz/rz
sz/rz are commands based on the ZModem transmission protocol. The transmitted data will be checked, and there is good transmission performance. It is very convenient to use, but the premise is that the window side needs to have a telnet or SSH client that can support ZModem, such as secureCRT.
you need to configure the relevant local download and upload directories in secureCRT, and then use the rz and sz commands to easily transfer file data.
Download the data to the local download directory: sz filename1 filename2…
Upload data to remote: execute the rz -be command, the client will pop up the upload window, and the user can choose (multiple choice) the file to upload.So in both Postgres and the SQL Standard we have this containment hierarchy:
Linux repositories are one of the most useful features of a Linux distribution. They contain a database of packages and software for the specific distribution or its children.
Yum is one of those repositories. It is the base repository for RPM packages used in RedHat and RedHat-based distributions. RPM is easy to configure and use, allowing users to install software packages in their systems easily and quickly.
Yum packages can be hosted on a server and served remotely via HTTP, HTTPS, and FTP or local installation of the repository. Local installation involves downloading the packages and store them on the local disk.
The purpose of this tutorial is to teach you how to set up a locally hosted Yum repository on CentOS.
https://linuxhint.com/create-yum-local-repository/
yum install tree
If you are using Debian / Mint / Ubuntu Linux, type the following apt-get command to install the tree command :
sudo apt install tree
If you are using Apple OS X, type:
brew install tree
终端:命令的输入输出环境,终端设备和终端模拟器
shell:调用内核程序,返回结果
shell是个解释器:如Windows:cmd.exe powshell Mac: bash zsh
终端是个输入输出界面:如conhost.exe westerm
在配置ssh免密登陆时,为啥把公钥复制给目标主机,就能免密登陆目标主机了?不应该目标主机能免密登陆自己吗? 数据+私钥 ++公钥 = 数据
ssh-keygen -t rsa #生成公私钥
cd ~/.ssh
cat id_rsa.pub>> authorized_keys #追加公钥
ssh-copy-id -i hostname #拷贝到其他主机
master->node01 master->node02 #配置master到node01和node02的免密登录,ssh之后别忘了退出配置ip地址到主机的映射:vi /etc/hosts 格式:ip_add host_name
查看ip地址:
ip addr centos
修改centos ip
配置静态和动态iP:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。