linux常用命令

Posted by Liao on 2019-09-12

SCP上传下载

1.从服务器拉取文件夹到本地

scp -r root@xx.xxx.x.xx:文件所在路径 /home/Document

2.从本地上传文件到服务器

scp -r /home/Document root@xx.xxx.x.xx:/home/default

3.rsync

文件压缩

tar -xvf file.tar

tar -xzvf file.tar.gz

tar -xjvf file.tar.bz2 //解压 tar.bz2

tar –xZvf file.tar.Z //解压tar.Z

unrar e file.rar //解压rar

unzip file.zip //解压zip

zip -r main.zip main

unzip main.zip

7z x file.7z

批量压缩文件夹,把每个文件夹单独压缩,一个文件夹对应一个压缩包:

1
for i in `find ./* -type d`;do zip $i.zip ./$i/*;done

mysql修改密码

mysql -uroot -p

Enter password: 【输入原来的密码】
mysql>use mysql;
mysql> update user set authentication_string=passworD(“test”) where user=’root’;

mysql> flush privileges;
mysql> exit;

Linux Mint

sudo apt-get install 软件包 #下载软件包

sudo apt-get update #更新软件包

dpkg -i:安装软件包; //软件更新时不能更新到
-r:删除软件包;
-P:删除软件包的同时删除其配置文件;
-L:显示于软件包关联的文件;
-l:显示已安装软件包列表;
–unpack:解开软件包;
-c:显示软件包内文件列表;
–confiugre:配置软件包。

命令行设置代理

由于命令行走http代理,则要把socks5转http。

1.首先安装privacy:sudo apt-get install privoxy

2.把转发的sorks5和监听的地址写入 sudo vim /etc/privoxy/config

forward-socks5 / 127.0.0.1:2333 .
listen-address localhost:8118

3.sudo systemctl restart privoxy.service

http_proxy=http://127.0.0.1:8118 https_proxy=http://127.0.0.1:8118 curl ip.gs

命令行使用代理

http_proxy=http://127.0.0.1:8118 https_proxy=http://127.0.0.1:8118 git clone https://github.com/GreenHatHG/ACMRecentContests_UI

查看系统占用

1
2
3
4
5
top 
free
htop
vmstat
iostat

选择地查看历史记录

history | grep htop #能过滤出所查询的命令在第几行

!260 #能把那一行的代码直接写在命令行

环境变量

我终端使用的是zsh,因此把变量写在~/.zshrc

export MY_PATH = “ “

export PATH=$PATH:$MY_PATH

查看文件类型

file xx