Ubuntu小配置
Ubuntu
拍摄快照
在虚拟机安装好、配置号后各拍摄一次快照,并存储。
可在虚拟机出错后回滚
Root用户
Ubuntu默认不能以 Root用户身份直接登录
因此,正常操作时在需要调用 root权限时,必须使用 sudo命令来获取部分权限
Root直接登录
在现有用户下为 root帐户设置密码
sudo passwd root
# 现在的用户的密码
# root用户密码
# 确认密码
修改文件: /etc/pam.d/gdm-autologin ,用 # 注释掉
auto retuired pam_succeed_if.so user != root quiet_success
修改文件 /etc/pam.d/gdm-password
auto retuired pam_succeed_if.so user != root quiet_success
临时转为 Root
在配置好 Root密码后,使用如下命令:
su root
# 密码
这之后的所有操作都不需要再加 sudo了
退出命令:
exit
脚本文件
权限
如果文件没有可运行权限,则不能使用 ./xxx的方式
此时可以选择 加权限或者使用其他命令运行的方式,如:
chmod o+x hello.sh
chmod u+x hello.sh
chmod 777 hello.sh
- o:表示 other
- u:表示 属主,user
- g:表示 属组,group
- 777:可读权限为4 可写为2 可执行为1;针对某文件,一种角色的权限可以表示为 4/2/1的和
bash
如果 xxx.sh没有 x权限,则可以使用
bash xxx.sh
sudo bash xxx.sh
此时,在文件内部的第一行必须标记为:
#!/bin/sh
来帮助找到 sh命令
python
如果 xxx.py没有 x权限,则可以使用
python xxx.py
此时,文件内部的第一行必须标记为:
#!bin/python3
网络相关
关于 apt换源
1)先将 /etc/apt/sources.list备份
cp sources.list sources.list.bak
2)然后修改sources.list中的源
gedit sources.list
修改为
# 清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 网易源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
3)更新 apt
sudo apt-get update
4)然后就可以正常使用了
关于虚拟机网络
可选的为 NAT模式,桥接模式和自定义模式
NAT
使用 VMnet8的网卡
桥接
类似和电脑并联
一般选用桥接,便于连接 xshell
关于SSH
使用 apt下载以下内容
sudo apt-get install net-tools
sudo apt-get install openssh-server
然后使用 ifconfig查看虚拟机 IP
使用 xshell进行连接
关于FTP
宿主机和虚拟机可以通过 FTP协议互相传文件
XFTP
使用 xshell的 xftp
下载免费版 xftp后,在 xshell连接的情况下,使用 xftp进行宿主机和虚拟机的数据交互
lrzsz
可以使用 rz命令和 sz命令
先用 apt安装
sudo apt install lrzsz
然后就可以使用 rz命令将宿主机的东西传到虚拟机中
使用 sz命令将虚拟机中的东西传到宿主机中
但是貌似还是只能在 xshell中使用
关于防火墙和端口
先用 apt安装
sudo apt install ufw
开放单个端口
sudo ufw allow 80
sudo ufw allow 22
关闭单个端口
sudo ufw delete allow 80
查看防火墙的状态
sudo ufw status
重启防火墙
sudo ufw reload
关闭防火墙
sudo ufw disable
设置外来访问的默认权限(拒绝)
sudo ufw default deny
Java相关
配置 Java
直接安装Java
直接安装可以不用配置路径(好像)
主要,我也不知道直接 apt安装到了哪里,科学的讲估计是在 /usr/local下
# 直接在控制台输入 java或者 javac
# 会提示 没有该命令,然后会提示推荐安装的内容
# 可以装 jre也可以装 jdk
# 直接使用 apt即可安装
直接安装,虽然没有配置路径,但是貌似是存在 JAVA_HOME的,因为 tomcat可以识别到。
wget 下载安装
使用 wget命令安装
sudo wget 某个版本的java的tar.gz文件
下载后正常解压,可以解压到 /usr/local下,也可以解压到 /opt下
tar -zxvf 压缩文件名 -C 解压后存储的路径
手动配置路径
用户环境变量
针对每个用户的环境变量,只有本用户才能有效
每个用户的家目录下有个隐藏文件 .profile
ls -a /home/zhao/.profile
在 CentOS下,叫做 .bash_profile好像
可以使用 gedit或者vim修改其内容,建议先备份
可在其内部添加如下:
export JAVA_HOME=/opt/jdk-1.8.0
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
系统环境变量配置
在 /etc/profile.d 目录下新建一个脚本,命名任意,但要以 .sh为后缀
内部配置类似 上面
注意:如果,是手动解压安装 Java的,必须手动配置路径,建议配置为系统路径
配置 Tomcat
使用 wget 从官网上下载,注意版本号和 JDK版本的联系
也可以使用 XFTP 或者 rz命令从宿主机中上传
下载后解压
tar -zxvf apache-tomcat-版本号 -C 解压后的路径
然后,可以进入到该目录下查看,会发现只有 root才有访问权限
于是需要切换 root用户
su root
# 密码
在 bin目录下启动:./startup.sh
在 bin目录下关闭:./shutdown.sh
开启tomcat后,在宿主机与虚拟机上都能访问到发布的项目
# 宿主机
虚拟机ip:8080
# 虚拟机
localhost:8080
备份之后 修改配置文件
gedit conf/server.xml
配置 Redis
直接 apt安装 redis-server
sudo apt install redis-server
查看 redis状况
service redis-server status
在 /etc/redis/redis.conf 下修改redis配置
gedit redis.conf
注释掉 bind 127.0.0.1
添加密码 requirepass
重启 redis-server
登录 redis-cli尝试
在宿主机上登录 Redis Desktop Manager尝试连接虚拟机上的 redis
配置 MySQL
安装MySQL
1)通过 apt安装 MySQL
sudo apt-get install mysql-server
2)初始化配置
sudo mysql_secure_installation
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (选择N ,不会进行密码的强校验)
#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)
#3
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (选择N,不删除匿名用户)
#4
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N (选择N,允许root远程连接)
#5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (选择N,不删除test数据库)
#6
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (选择Y,修改权限立即生效)
3)检查 MySQL状态
systemctl status mysql.service
4)配置远程访问
修改 /etc/mysql/mysql.conf.d/mysqld.cnf
# bind 127.0.0.1
5)登录 mysql进行修改
sudo mysql -uroot -p
use mysql;
select host,user,plugin from user; -- 此时 root的 plugin和其他的不一样,表示只能用权限登录
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;
UPDATE user SET host = '%' WHERE user = 'root';
flush privileges;
quit;
之后,切换为普通用户登录 mysql
尝试使用 宿主机的 navicat登录 虚拟机上的 mysql
MySQL卸载
1)查看依赖项
dpkg --list|grep mysql
2)卸载
sudo apt-get remove mysql-common
sudo apt-get autoremove --purge mysql-server-5.7
3)清除残留数据
dpkg -l|grep ^rc|awk '{print$2}'|sudo xargs dpkg -P
4)查看依赖项
dpkg --list|grep mysql
5)删除依赖项
sudo apt-get autoremove --purge mysql-apt-config
Ubuntu小配置的更多相关文章
- Ubuntu下配置python完成爬虫任务(笔记一)
Ubuntu下配置python完成爬虫任务(笔记一) 目标: 作为一个.NET汪,是时候去学习一下Linux下的操作了.为此选择了python来边学习Linux,边学python,熟能生巧嘛. 前期目 ...
- 转[开发环境配置]在Ubuntu下配置舒服的Python开发环境
在Ubuntu下配置舒服的Python开发环境 Ubuntu 提供了一个良好的 Python 开发环境,但如果想使我们的开发效率最大化,还需要进行很多定制化的安装和配置.下面的是我们团队开发人员推荐的 ...
- Ubuntu下配置L2TP
发现PPTP已经不可用了,不知是不是又被墙了.只能尝试L2TP了. Ubuntu可视化配置界面network-manager默认是没有L2TP配置选项的,需要安装第三方插件软件: sudo apt-a ...
- ubuntu环境配置之vi 配置【转载】
ubuntu环境配置之vi 配置 [日期:2014-02-10] 来源:Linux社区 作者:zhonghe1114 [字体:大 中 小] Android的源码开发,几乎离不开Linux,Lin ...
- [C#]使用 C# 代码实现拓扑排序 dotNet Core WEB程序使用 Nginx反向代理 C#里面获得应用程序的当前路径 关于Nginx设置端口号,在Asp.net 获取不到的,解决办法 .Net程序员 初学Ubuntu ,配置Nignix 夜深了,写了个JQuery的省市区三级级联效果
[C#]使用 C# 代码实现拓扑排序 目录 0.参考资料 1.介绍 2.原理 3.实现 4.深度优先搜索实现 回到顶部 0.参考资料 尊重他人的劳动成果,贴上参考的资料地址,本文仅作学习记录之用. ...
- 《一个操作系统的实现》 ubuntu系统环境配置
<一个操作系统的实现> ubuntu系统环境配置 电脑之前已经安装了gcc. 一.nasm安装:sudo apt-get install nasm或官网下载http://sourcefor ...
- Ubuntu中配置Java环境变量时,出现command not found问题解决记录
百度出Ubuntu中配置Java环境变量时,在利用sudo gedit /etc/profile 对profile编辑后, 在terminal中输入 sudo source /etc/profile, ...
- SecureCRT连接虚拟机(ubuntu)配置
使用SecureCRT连接虚拟机(ubuntu)配置记录 这种配置方法,可以非常方便的操作虚拟机里的Linux系统,且让VMware在后台运行,因为有时候我直接在虚拟机里操作会稍微卡顿,或者切换速 ...
- Ubuntu下配置C/C++开发环境
在 Ubuntu 下配置 C/C++ 开发环境 转自:白巴的临时空间 Submitted by 白巴 on 2009-04-27 19:52:12. 学习笔记 虽然 Ubuntu 的版本已经是9.04 ...
随机推荐
- Codeforces Round #613 (Div. 2) B. Just Eat It! (DP)
题意:有一个长度为\(n\)的序列,找出最大的长度不为\(n\)的子段和,问最大子段和是否小于所有元素和. 题解:最大子段和我们可以直接用dp来找,每次状态转移为:\(dp[i]=max(dp[i-1 ...
- 牛客编程巅峰赛S1第11场 - 黄金&钻石 C.牛牛找子集 (二分)
题意:有一\(n\)个数,从中找数构成相同的子集,要求子集元素个数为\(k\),求构成子集个数最多的情况,输出子集(字典序最小). 题解:我们可以对子集的个数二分答案,首先用桶记录每个元素的个数,然后 ...
- 远程连接 出现身份验证错误,要求的函数不受支持(这可能是由于CredSSP加密Oracle修正)
修改本地组策略: 计算机配置>管理模板>系统>凭据分配>加密Oracle修正 选择启用并选择"易受攻击". 原文:https://blog.csdn.net ...
- Dubbo从入门到实践
1 Dubbo出现的背景 随着互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,亟需一个治理系统确保架构有条不紊的演进. 我们传统的网站结构为 ...
- GO - go mod使用原理
Go Module 依赖管理 go mod使用 原理及使用ref: https://xuanwo.io/2019/05/27/go-modules/ go module的稳定路径: https://l ...
- 4.安装etcdkeeper查看etcd数据库中的数据
作者 微信:tangy8080 电子邮箱:914661180@qq.com 更新时间:2019-06-24 12:47:59 星期一 欢迎您订阅和分享我的订阅号,订阅号内会不定期分享一些我自己学习过程 ...
- WSL (Windows Subsystem for Linux) 的 VSLAM (Visual Simultaneous Localization and Mapping) 道路
WSL 的 VSLAM 道路 以 Windows Subsystem for Linux 闯入 Visual Simultaneous Localization and Mapping 世界的艰难道路 ...
- LeetCode 856. Score of Parentheses 括号的分数
其实是这道题的变式(某港带同学的C/C++作业) 增加一点难度,输入的S不一定为平衡的,需要自己判断是否平衡,若不平衡输出为0. 题目描述 Given a parentheses string s, ...
- Leetcode(868)-二进制间距
给定一个正整数 N,找到并返回 N 的二进制表示中两个连续的 1 之间的最长距离. 如果没有两个连续的 1,返回 0 . 示例 1: 输入:22 输出:2 解释: 22 的二进制是 0b10110 . ...
- C++ STL (基础)
STL是什么(STL简介) 本节主要讲述 STL 历史.STL 组件.STL 基本结构以及 STL 编程概述.STL 历史可以追溯到 1972 年 C 语言在 UNIX 计算机上的首次使用.直到 19 ...