查找
find ./ -name aaa #(模糊查询用*号,即:find ./ -name *aaa 或 find ./ -name aaa*)
编辑文件
vim aaa
/abc #先输入“/”在输入要查找的字符abc
N #按“N”查找下一处
:set nu
查看文件
tail -f aaa
tail -n aaa
cat aaa
安全相关
tail -f /var/log/secure
定时任务相关
service crond status
tail -f /var/log/cron
#或者看全部
cat /var/log/cron
crontab -l
crontab -e
service crond reload
service crond restart
防火墙相关
firewall-cmd --state
systemctl start firewalld
systemctl stop firewalld
firewall-cmd --list-ports
firewall-cmd --add-port=3690/tcp --permanent #--permanent表示永久开启
firewall-cmd --zone=public --remove-port=3306/tcp --permanent
systemctl restart firewalld
SVN相关
yum -y install subversion
rpm -ql subversion
svnserve -d -r /data/svn #(/data/svn为版本库的根目录)
ps aux | grep svn
#如果打印如下信息,证明已开启svn,否则未开启
root 1078 0.0 0.0 166316 676 ? Ss 10:29 0:00 svnserve -d -r /data/svn
root 1080 0.0 0.0 112648 948 pts/0 R+ 10:29 0:00 grep --color=auto svn
kill -s 9 1078
Mysql相关
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
systemctl start mysqld.service
systemctl status mysqld.service
mysql -u root -p
#或者指定host登录
mysql -u root -h 127.0.0.1 -p
#再输入密码,回车
#注:用如下命令获取MySQL的临时密码
grep 'temporary password' /var/log/mysqld.log
- 首次登录如果提示“You must reset your password using ALTER USER statement before executing this statement.”,执行如下命令
ALTER USER USER() IDENTIFIED BY '12345678';
- 如果修改密码提示“Your password does not satisfy the current policy requirements”,执行如下命令再修改
set global validate_password_policy=0;
show global variables like 'port';
vi /etc/my.cnf
#添加下面这行后,保存退出
port=6608
show databases;
use mysql;
UPDATE user SET Password = PASSWORD('newpassword') WHERE user = 'root';
FLUSH PRIVILEGES;
UPDATE user SET host='%' WHERE user='root' and host='localhost';
- mysql命令下,给远程访问的root用户设置所有权限
GRANT ALL PRIVILEGES ON *.* TO "root"@"%" IDENTIFIED BY "root";
FLUSH PRIVILEGES;
create user 'abc'@'%' identified by 'newpassword';
grant select,insert,update,delete,create on *.* to abc;
flush privileges;
service mysql restart
如果报“ailed to restart mysql.service: Unit not found.”错误提示,则执行下面一条命令
service mysqld restart
source /home/sqlfiles/aaa.sql #前提一定要先选好数据库
查找进程和端口
ps -ef | grep tomcat
#如果打印如下信息,表示查找到tomcat进程号为25855
root 25855 1 6 14:38 pts/0 00:00:29 /usr/java/jdk1.8.0_171/jre/bin/java -Djava.util.logging.config.file=/apache-tomcat-7.0.88/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dignore.endorsed.dirs= -classpath /apache-tomcat-7.0.88/bin/bootstrap.jar:/apache-tomcat-7.0.88/bin/tomcat-juli.jar -Dcatalina.base=/apache-tomcat-7.0.88 -Dcatalina.home=/apache-tomcat-7.0.88 -Djava.io.tmpdir=/apache-tomcat-7.0.88/temp org.apache.catalina.startup.Bootstrap start
root 26616 23678 0 14:46 pts/0 00:00:00 grep --color=auto tomcat
netstat -anop | grep 25855
#如果打印如下信息,表示tomcat进程占用了8005、8009、8080等端口
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 25855/java off (0.00/0/0)
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 25855/java off (0.00/0/0)
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 25855/java off (0.00/0/0)
unix 2 [ ] STREAM CONNECTED 11510487 25855/java
查看机器配置
ifconfig
文件及目录操作
cp /AAA/aaa /BBB
- 复制 AAA目录下所有子文件和子文件 到 BBB目录
cp -rf /AAA/* /BBB
rm -f /AAA/aaa
rm -rf /AAA
mv AAA BBB
mv aaa bbb