linux 常用命令小记

[code="sql"]1、ssh远程登录:ssh:[email protected]
2、下载:wget -c http://xxxxx.xx 支持断点下载
3、环境变量修改: vi /etc/profile
4、ar –xvf file.tar //解压 tar包
tar -xzvf file.tar.gz //解压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

jdk1.6 下载地址:http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u21-oth-JPR

export JAVA_HOME=/home/java/jdk1.6.0_45
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar



   11  apt-get update
   12  apt-cache search mysql
   13  apt-cache search mysql-server
   14  apt-get install mysql-server




create database db;
CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
insert into mysql.user(Host,User,Password) values('localhost','blog',password('pwd'));
flush privileges;
grant all privileges on blog.* to 'blog'@'%' identified by 'pwd';
flush privileges;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;

查询重复纪录
select user_name,count(*) as count from user_table group by user_name having count>1;



防火墙设置

sudo iptables -I INPUT -s 127.0.0.1 -j DROP 限制单条ip
sudo iptables -A INPUT -s 127.0.0.1 -p tcp -m tcp --dport 8080 -j ACCEPT 允许本机访问8080端口
sudo iptables -A INPUT -p tcp -m tcp --dport 8080 -j DROP 禁止远程访问8080端口
sudo iptables -L -n 查看配置

sudo iptables -F 清空所有规则

删除
sudo iptables -A INPUT -s 127.0.0.1 -p tcp -m tcp --dport 8080 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 8080 -j DROP



文件夹下的文件个数 包括子文件夹:ls -lR|grep "^-"|wc -l

相关推荐