常用命令记录
在ssh中使用scp命令上传/下载文件
// 下载文件
scp username@servername:/path/filename /var/www/local_dir
//上传文件
scp /path/filename username@servername:/path
查看文件夹大小
du -sh /var //只输出/var的总大小
du -h --max-depth=1 /var 输出/var下一级目录的大小和/var的总大小
列出目录下大文件夹排行
du -hm --max-depth=4 | sort -nr | head -20
导出所有数据库
#备份数据库
mysqldump -u用户名 -p密码 --lock-all-tables --all-databases > all.sql
#导入数据库
mysql -u用户名 -p密码 < all.sql
mysql查看列数
select count(*) from wp_posts where post_type=”post” and post_status=”publish”;
mysql新建用户并给予全部权限
CREATE USER 'name'@'localhost' IDENTIFIED BY 'passwd';
GRANT ALL PRIVILEGES ON *.* TO 'name'@'localhost';
FLUSH PRIVILEGES;
tar打包解包
tar czvf pkgname.tar.gz /path
tar xzvf pkgname.tar.gz
删除参数 v 就不会输出内容
tar czf pkgname.tar.gz /path
tar xzf pkgname.tar.gz
nohup
nohup command >/dev/null 2>&1 &
列出当前文件夹内文件数量:
ls -l | grep "^-" | wc -l
ls -lR | grep "^-"| wc -l ## 包括子文件夹
curl上传ftp文件:
curl --user username:passwd -T file.tar.gz ftp://ip/
mysql连接远程数据库:
mysql -h ip -P 3306 -u username -ppasswd
查找大文件
find . -type f -size +100M
在 top / htop 命令中根据内存和CPU占有率排序
大写 M P
ubuntu快速安装lamp
apt-get -y install mariadb-server mariadb-client apache2 php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-curl php7.2-gd php7.2-intl php-pear php-imagick php7.2-imap php-memcache php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-mbstring php-gettext php7.2-opcache php-apcu php-zip php-mbstring php-xml php-xml-rpc2
mysql_secure_installation
apache虚拟主机配置文件
<VirtualHost *:80>
ServerAdmin zuoridangnian@outlook.com
DocumentRoot /var/www/zrdn/
ServerName zuoridangnian.com
<Directory /var/www/zrdn/>
Options -Indexes
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
certbot ssl证书
## certbot 证书
apt-get install software-properties-common
add-apt-repository universe
add-apt-repository ppa:certbot/certbot
apt-get install certbot python3-certbot-apache
certbot --apache
oh my zsh
apt install zsh -y
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
centos查看版本
cat /etc/redhat-release
测试硬盘速度
dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync && rm -f test
wget递归下载ftp文件夹
wget -nH -m --ftp-user=user --ftp-password=passwd ftp://address
查看服务器外网ip
curl cip.cc
wget 下载整站
wget -c -r -np -k -L -p
tar gz 分卷压缩和解压
tar zcf - /www/wwwroot/zuoridangnian.com |split -d -b 100m - www.tar.gz.
解压:
cat www.tar.gz* | tar zx