Linux常用基本操作

#本地拷贝文件到远程服务器

scp output.txt root@192.168.1.1:/home/user/
scp 文件名  服务器名@服务器IP:远程存放路径

#链接远程服务器

ssh -p 端口 用户名@服务器IP

ssh -p 22 root@192.168.1.1

#输入密码

#成功

yum 切换镜像源 阿里

cd /etc/yum.repos.d/

#源地址

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

#重新生成缓存—查看执行结果,如果有aliyum字样就算成功

yum maskecache

查看当前Centos操作系统的发行版信息

cat /etc/redhat-release

Linux 安装mysql 后启动把报错

1、下载mysql的Yum仓库
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
2、安装 mysql服务
yum -y install mysql-community-server
3、启动报错:
Failed to start mysqld.service: Unit not found
解决办法:
解决方法如下:
首先需要安装mariadb-server
yum install -y mariadb-server
4、在⽇日志⽂文件中查看初始密码
grep "password" /var/log/mysqld.log
5、进⼊入修改Mysql密码
mysql -uroot -p
6、新密码设置必须由⼤大⼩小写字⺟母、数字和特殊符号组成

xxxx密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxx';
7、开启mysql的远程访问, %是指全部

xxxx密码

grant all privileges on *.* to 'root'@'%' identified by 'xxxx' with grant option;
8、刷新权限
flush privileges;

Linux 常用命令

1、cd 切换目录
cd /usr/local/    cd ..   cd -
2、ls命令 列出目录内容
ls -ltr
ls -lrt /home/
3、pwd 命令 查询所在目录路径
pwd
4、cat 查看小文件内容
cat -n 123.txt
5、more 查看大文件内容
more System.map-3.10.x86_64
6、head查看文件的前面N行
head -20 System.map-3.10.x86_64
7、tail查看文件后面的N行
tail -f access.log;
tail -20 access.log;
8、touch创建一个空文件
touch 123.txt
9、mkdir 创建目录
mkdir -p /temp/xd/xd
10、rmdir 删除目录
rmdir /temp/xd/xd
rm 987.php;
rm -rf 345.txt
11、cp 拷贝文件
cp 123.txt class ;	
cp -a 123.txt class/789.txt
12、mv 移动或更名现有文件或目录
mv 123.txt 345.txt	
mv 789.txt /home/987.txt
13、rm 删除文件或目录
rm 987.php	
rm -rf 456.txt
14、检查端口被那个进程占用
netstat -lnp|grep 88 
#88查看被占用的端口  换成自己的被占用的端口  如:  80

#执行netstat -lnp |grep 88 之后会打印出被占用的进程以及编号
kill -9 进程号
15、diff命令 对比文件差异
diff 123.txt 456.txt
16、id 查看用户
id root
17、ping 查看网络是否畅通
ping 192.168.56.104
18、echo 标准输出命令
echo "this is echo 命令"
19、man 查看帮助文档(ls --help)
man ls
20、help 查看内部命令帮助
help if

Linux工作中常用的命令

1、clear 清屏
clear;
ctrl+1
2、who 当前在本地系统上的所有用户信息
whoami;
who;
3、uptime 查看系统信息
load average : 0.00,	 0.01 , 	0.05 
			一分钟负载	5分钟负载	15分钟负载
4、w 查看系统信息
5、free 查看系统内存
free -h;
free -w;
6、wc 统计行
wc -l 123.txt
7、grep 查找文件里符合条件的字符串
grep '192.168.245.33' 123.txt | wc -l
-n:输出行数  grep -n '182.292.22.33' 13.txt;
-w:精准匹配 grep -w '113.22.44.777' 213.txt;
-i:忽略大小写 grep -i 'ip:113.11.445.753' 123.txt;
-v:反向选择  grep -v '241.23.111.545' 123.txt;
8、find 查询文件
find / -name -type f 123.txt
9、uniq 对排序号的内容进行统计
uniq -c 123.txt | sort -n
10、sort 对内容进行排序
uniq -c 123.txt | sort -n
11、df 文件系统的磁盘使用情况统计
df -h  查看磁盘使用情况
12、netstat 查看网络端口的使用情况
netstat -tunlp | grep nginx
-t 显示tcp端口
-u 显示UDP端口
-n 指明拒绝显示别名
-l 指令listen
-p 指明显示建立相关连接的程序名
安装netstat 命令
yum -y install net-tools
13、hostname 查看主机名
hostname 
16、ps 显示所有进程信息,ps 与gerp常组合使用,查看特定的进行
ps -ef| grep nginx
ps -aux |grep nginx
17、top 监控Linux系统状况,比如cpu\内存的使用
退出:按住键盘q退出
18、du 统计大小
du -sh;
du -sm*
19、firewall-cmd 查看防火墙的状态
firewall-cmd --state
centos 7关闭防火墙:
	systemctl stop firewall.service
20、cal 查看日历
cal 2008
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值