Last active
March 14, 2018 05:37
-
-
Save imzyf/890e5aed3cdc54d240c5ee8679a4d769 to your computer and use it in GitHub Desktop.
Linux 常用命令
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
time=`date +"%Y%m%d"` | |
# 8011 要备份的数据表 列表 | |
# 同步数据库 表 | |
mysqldump -uroot -p site_db a_table > "key$time.sql" && cat "key$time.sql" | mysql -uroot -p coupon_local | |
### 文件移动 | |
``` | |
#/bin/bash | |
D_DIR='/home/moma/Backup' | |
for x in `ls ${D_DIR}` | |
do | |
echo $x | |
for y in `ls ${D_DIR}/${x}/*.pdf` | |
do | |
#echo $y | |
scp $y 192.168.1.10:/manual/source/guru_data | |
done | |
done | |
``` | |
``` | |
#/bin/bash | |
D_DIR='/home/moma/Backup/bk-source/offical_data' | |
for x in `ls ${D_DIR}` | |
do | |
echo $x | |
for y in `ls ${D_DIR}/${x}/*ang*ame/*.pdf` | |
do | |
echo $y | |
scp $y 192.168.1.10:/PHP-Manual-PDF/source/offical_pdfs | |
done | |
done | |
``` | |
``` | |
#!/bin/bash | |
D_DIR='/home/moma/Backup/bk-change/repeat_convert' | |
for x in `ls ${D_DIR}` | |
do | |
echo $x | |
for y in `ls ${D_DIR}/${x}/h*` | |
do | |
echo $y | |
tar zxvf $y -C ~/Backup/bk-s3 | |
done | |
done | |
``` | |
### 循环调用 | |
``` | |
for ((i=1;i<30;i++)) ; do echo 1;sleep 30 ; done | |
``` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 后台执行命令 | |
nohup somecommand & | |
# 修改文件夹权限(递归设置) | |
sudo chmod 765 filename -R | |
# 查找相关端口进程 | |
lsof -i:8080 | |
# 通过游览器共享文件 | |
python -m SimpleHTTPServer 9999 | |
# 打开pdf文件 | |
evince hdfs_design.pdf | |
# 传输文件 | |
scp java_manual.war 192.168.8.1:/opt/wildfly/standalone/deployments | |
# .gz.tar 解压/压缩 | |
# 解压 | |
tar zxvf FileName.tar.gz | |
# 压缩 | |
tar zcvf FileName.tar.gz DirName | |
# .zip 解压/压缩 | |
# 解压 | |
unzip 0728.zip -d ./aa/ | |
# 压缩 | |
zip -r /alidata/www/default/LH0913yifan.zip /alidata/www/default/love-home | |
# 查看内存情况 | |
free -m | |
# 查看系统信息 | |
uname -a | |
cat /proc/version | |
# SSH连接 | |
ssh -p 22 [email protected] | |
# 上一次SSH连接 | |
!ssh | |
# 修改root密码 | |
passwd | |
# 显示最后三行 | |
tail -d ttt.txt | |
# 不断刷新查看 | |
tail -f ttt.txt | |
# sodu 不需要密码 | |
visudo | |
www-data ALL=(ALL) NOPASSWD:ALL | |
$ sudo systemctl restart sshd | |
# 切换到 root 用户 | |
sudo -i | |
sudo su - | |
# df 显示文件系统空间信息 | |
df -h | |
# 用 M 和 G 做单位显示文件系统空间信息 -h 意思是 human-readable | |
# du 显示目录的空间使用信息 | |
du -sh /media/floppy | |
#-s 意思 summary | |
### 返回刚才的 directory | |
``` | |
cd - | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment