这两天经常用到一些linux命令,记了忘,忘了又去搜,实在麻烦,于是在这里整理一下
- 文件颜色
蓝色:目录,
绿色:可执行文件,
天蓝色:符号文件,
白色:普通文件,
黄色:设备文件,
红色:失效文件的链接,
浅红:压缩文件或tarball文件,
粉色:图片文件
- ps(process status)命令
ps命令用于显示当前进程 (process) 的状态,类似于windows的任务管理器。
查看一个程序是否运行:
ps –ef|grep tomcat 查看所有有关tomcat的进程。
-e 显示所有进程
-f 全格式
- top命令
top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器
- su命令
su root
-
touch命令
-
ubuntu阿里云源
vim /etc/apt/sources.list
直接放在默认云源之前
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt-get update
- 安装eclipse
#本方法并未证实
1. 从官网下载tar.gz包,解压到相应的路径,此时执行 ./eclipse 就会启动eclipse,但十分的不方便,所以选择建立快捷方式
2. 在Desktop 下 vim eclipse.desktop (其中“Exec=”后面为eclipse安装目录下的eclipse程序的位置路径,
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse
Exec=/apps/eclipse/eclipse “Exec=”后面为eclipse安装目录下的eclipse程序的位置路径
Icon=/apps/eclipse/icon.xpm “Icon=”后面为eclipse安装目录下的图标图片的路径
Terminal=false
StartupNotify=true
Type=Application
Categories=Application;Development;“Icon=”后面为eclipse安装目录下的图标图片的路径)
3. chmod u+x eclipse.desktop
- 使用root账户登录
- apt-get
apt-cache search package 搜索软件包
apt-cache show package 获取包的相关信息,如说明、大小、版本等
sudo apt-get install package 安装包
sudo apt-get install package --reinstall 重新安装包
sudo apt-get -f install 修复安装
sudo apt-get remove package 删除包
sudo apt-get remove package --purge 删除包,包括配置文件等
sudo apt-get update 更新源
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
apt-cache depends package 了解使用该包依赖那些包
apt-cache rdepends package 查看该包被哪些包依赖
sudo apt-get build-dep package 安装相关的编译环境
apt-get source package 下载该包的源代码
sudo apt-get clean && sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖
- ubuntu首次登录设置密码
sudo passwd root
- ls命令
- 安装mysql-server
#基于ubuntu18.04LTS,当遇到莫名奇妙的问题时记得去试试重启mysql,看能不能解决
#安装
sudo apt-get install mysql-server
sudo apt-get install mysql-client
#首先要先登录进去数据库,mysql默认安装时会有一个随机的密码,其初始化在 mysql/debian.cnf 中,用以下命令打开文件
sudo vim /etc/mysql/debian.cnf
#user和password为初始用户和随机的初始密码
mysql -u debian-sys-maint -p
#登录
mysql -u root -p
#更新密码
update mysql.user set authentication_string=password('password') where user='root'and Host = 'localhost';
#重启MySQL,用 sudo mysql -uroot -p 即可登录成功(这里出现了一个问题,若不加sudo,只用 mysql -uroot -p 的话会登录失败,查询资料得,原因是mysql使用了auth_socket plugin进行认证)
#于是我们首先查看用户的权限
use mysql;
select user,host,plugin from user;
#root用户为auth_sock,所以要将其改为mysql_native_password,即使用mysql自带密码认证功能,用以下命令
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
flush privileges;
#删除mysql
sudo apt-get autoremove --purge mysql-server-5.7
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P //删除多余数据
#查看mysql版本
mysql -V
#启动、停止、重启mysql数据库
service mysql start
service mysql stop
service mysql restart
- 设置mysql远程登录
#修改root账号密码
update user set authentication_string = password('password'), password_expired = 'N', password_last_changed = now() where user = 'root';
#设置host
update user set host='%' where user='root';
#修改配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
加前缀#注释掉bind-address = 127.0.0.1
#防火墙放行3306端口
sudo ufw allow 3306