linux笔记1-使用技巧1
windows访问ubuntu共享文件
- 确定是否已安装
sudo apt-get install samba
- 设置你的账户samba密码
sudo touch /etc/samba/smbpasswd
sudo smbpasswd -a usr #usr 表示你的用户名
- 将你的用户添加到sambashare用户组中
sudo adduser usr sambashare
logout后重新的登录,当前用户就可以共享文件夹了。
4. 当ubuntu中共享文件夹时显示"net usershare返回错误255"时
- vim /etc/samba/smb.conf
- 在 usershare allow guests = yes 下面添加 usershare owner only = false
- wq保存退出即可
- 具体共享文件方法
右击你想共享的文件夹,点击本地网络共享,然后点击共享文件夹就可以了。 - 怎么在Windows中访问这个共享文件夹
方法跟Windows访问Windows是一样的,按Windows+R,然后输入://服务器ip
Ubuntu使用 samba共享文件,出现拒绝访问:
解决:
重新给samba创建用户名和密码:
sudo smbpasswd -a username
输入共享密码:
确认密码:
打印显示log文件
tail -f xxx.log
修改用户密码
修改用户名密码命令,如果不是root用户需要把操作用户加入管理组。
sudo passwd 用户名
使用管道过虑
『Linux学习笔记』7. 管道和过滤器 -- pipe - HoD - 博客园 (cnblogs.com)
ls | grep xx
解决vi命令上下左右出现ABCD和BackSpace无法删除的问题
- 方法1:安装vim
Ubuntu预安装的是tiny版本(最小版),不好用。所以要安装vim的full版本(完整版)。
- 卸载tiny版本
sudo apt-get remove vim-tiny
有的Ubuntu版本对应的是vim-common,就要卸载vim-common:
sudo apt-get remove vim-common
- 安装full版本
sudo apt-get install vim
- 方法2:修改vi配置 编辑.,加入以下内容
sudo nano /etc/vim/vimrc.tiny
set nocompatible
set backspace=2
新安装的ubuntu打不开终端
打开“设置”->“语言&区域",将语言language设置为"汉语"
新装linu修改root密码
新安装linux系统没有设置密码的,需要设置root默认密码
user@domain:~$ su
密码:
su:认证失败
其原因是由于第一次使用,这时候还未设置root的密码,我们可以以user用户对其进行设置
user@domain:~$ sudo passwd
[sudo] password for user:
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
成功后我们输入
user@domain:~$ su root
密码:
root@domain:/home/user
即进入root用户
退出root用户
exit
将用户加入到管理组得到root权限
当用户使用sudo命令获取root权限时提示:
xxx is not in the sudoers file. This incident will be reported.
原来是新建的用户没在sudoers的管理文件中,那往里添加不就完了嘛,以下是方法:
- 切换到root用户
su root
- 添加sudoers文权写权限
chmod u+w /etc/sudoers
- 编辑sudoers文件
vi /etc/sudoers
- 找到
# User privilege specification
root ALL=(ALL:ALL) ALL
- 在下方仿写一句
username ALL=(ALL:ALL) ALL #username是新建的用户
也可以在
## Allow root to run any commands anywhere
- 撤销sudoers文件的权限。
chmod u-w /etc/sudoers
配置linux虚拟机远程ssh访问
- 安装openssh-server服务
sudo apt-get install openssh-server
sudo systemctl status ssh #安装ssh后查看是否运行
sudo systemctl enable ssh #关闭ssh
sudo systemctl start ssh #启动ssh
2.在虚拟机中使用桥接网卡模式
使用此模式后重启将为虚拟机linux分配局域网地址不再是10.0.2.15
些时就可以使用ssh工具连接到对应的Ip地址
3.如果使用<网络地址转换(NAT)>模式
- 使用此模式可以在不同网段影射连接。在虚拟机中选把网络为<网络地址转换NAT>模式。
- 在虚拟机网络设备的高级处,点击端口转发并添加主机地址为:127.0.0.1端口自定义2222
- 子系统ip为虚拟机ip,并设置端口22此端口为ssh端口。
详细说明地址https://www.cnblogs.com/haicheng92/p/6838206.html
以上可选其中一种网络连接的影射模式,但都必须要安装openssh-server
使用ssh在客户端连接linux提示错误
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:OvejiyaYn3jXNT091mK+ZH6+dNPtOaJuR0Gx0Fhb4Ak.
Please contact your system administrator.
Add correct host key in C:\\Users\\it8c/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\it8c/.ssh/known_hosts:3
Host key for ubuntu22 has changed and you have requested strict checking.
Host key verification failed.
出现这些信息是因为第一次使用ssh连接时,会生成一个认证,储存在客户端中的用户目录下面的.ssh/known_hosts文件。如果服务器端与客户端不同时会跳出此错误。
只要删除用户目录下面的.ssh/known_hosts文件中的内容就可以解决。重新生成ssh连接密钥。
- 如果以上设置后连接现在不信任,可以用以下命令重置
ssh-keygen -R ubuntu22
串口调试hexdump
hexdump /dev/ttyUSB1
以16进制显示当前指定串口的数据。
提示xxx is not in the sudoers file. this incident will be reported.解决
su - #切换到root用户
gedit /etc/sudoers #使用此命令打到以下行
# User privilege specification
root ALL=(ALL:ALL) ALL
在此添加XXX为你的用户名
XXX ALL=(ALL:ALL) ALL
#如果使用gedit提示(gedit:6244): Gtk-WARNING **:ip: cannot open display:
#可以使用nano命令
nano /etc/sudoers
#编辑如上保存后解决提示。
安装python3-pip
sudo apt install python3-pip
如果没有Python,只有python3可以创建一个连接
#备份原来的python软链接
mv /usr/bin/python /usr/bin/python.bak
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo ln -s /usr/bin/pip3 /usr/bin/pip
vscode的platformIO安装
- 首先安装好python和pip3等。
- 使用官网get-platformio.py安装platformio。
- 然后在vscode中安装platformio ide插件
- 配置liunx里的环境变量指向刚才使用py脚本安装的位置。
#编辑~/.profile文件添加以下环境变量
export PATH=$PATH:$HOME/.local/bin
- 第4步添加环境变量后还需要连接实际使用脚本安装platform的所在位置~/.platformio/penv/bin
ln -s ~/.platformio/penv/bin/platformio ~/.local/bin/platformio
ln -s ~/.platformio/penv/bin/pio ~/.local/bin/pio
ln -s ~/.platformio/penv/bin/piodebuggdb ~/.local/bin/piodebuggdb
sudo apt-get install python3-venv
- 配置远程ssh的platformio无法显示PIO Home问题
GitHub - luxk3/ubuntu_server_remote_dev_platformio: Ubuntu server VM configuration for remote (SSH) hardware development using PlatformIO.
vpn代理连接到虚拟机
- 打开clash for windows代理工具。并设置General/Allow LAN打开局域网通用。
- 在Allow LAN上的Port端口注意激活端口。
- 在虚拟机系统中ubuntu打开设置Network并设置代理network proxy
- 注意此时虚拟机中使用的NAT连接ip.比如192.168.11.1那么,上面的ip全部填写此ip。然后端口使用刚才clash工具上的激活端口比如7890
- 然后打开google或youtube测试是否成功。
虚拟机中ubuntu没有ttyUSB0问题
(1条消息) Ubuntu22.04 CH340系列串口驱动(没有ttyUSB)问题解决方案_dev里没有ttyusb0_鱼香ROS的博客-CSDN博客
vscode使用remote远程下载vscode server
- 下载vscode-server-linux-x64.tar.gz
- 注意#把:
{commit_id}/server-linux-x64/stable - 使用上面的地址会下载文件,下载地址比如下:
https://az764295.vo.msecnd.net/stable/8b617bd08fd9e3fc94d14adb8d358b56e3f72314/vscode-server-linux-x64.tar.gz - 此时的下载很慢,因为是外网。可以把https://az764295.vo.msecnd.net改成国内cdn如下:
https://vscode.cdn.azure.cn
完整如下:
https://vscode.cdn.azure.cn/stable/8b617bd08fd9e3fc94d14adb8d358b56e3f72314/vscode-server-linux-x64.tar.gz
- 在linux下建立文件夹
mkdir -p ~/.vscode-server/bin
rm ~/.vscode-server/bin/* -rf #把$HOME/.vscode-server/bin下的内容删干净,防止出错
- 然后将vscode-server-linux-x64.tar.gz上传在服务器上的$HOME/.vscode-server/bin文件夹中,解压。
cd ~/.vscode-server/bin
tar -zxf vscode-server-linux-x64.tar.gz
mv vscode-server-linux-x64 ${commit_id} # 注意把:${commit_id}替换成对应的Commit ID
- 创建一个文件名字0在该目录下
touch 0
更换ubuntu源
ubuntu换镜像源(ubuntu换源)_Fighting_1997的博客-CSDN博客
在windows共享vpn到虚拟机
- 在windows中查看ip
ipconfig
- 将看到地ip填到linux中的网络代理。
- 代理端口设置成clash for windows里的port端口。
使用自启动界面创建自启动
gnome-session-properties
配置tabby使用ssh连接时中文乱码问题
export LANG=zh_CN.utf-8
连接ssh后设置ssh终端LANG为zh_CN.utf-8格式.
如果以上方法还显示乱码,设置tabby的配置文件中
appearance:
- Character encoding: utf-8
vbox不能双向粘贴问题
- 提示没有找到kernel headers安装如下
apt install gcc make dkms
apt install build-essential linux-headers-`uname -r`
2.提示没有启动服务方法如下
(4条消息) virtualBox的拖放和共享粘贴板已经勾选为双向,还是不起作用的解决方法_行秋的博客-CSDN博客
version `GLIBC_2.34‘ not found简单有效解决方法
version `GLIBC_2.34‘ not found简单有效解决方法_huazhang_001的博客-CSDN博客
- 查询libc6版本
dpkg -l | grep libc6
#查看GLIBC版本
ldd --version
- 检查版本
strings /lib/x86_64-linux-gnu/libc.so.6 |grep GLIBC_
#以上命令需要安装binutils
sudo apt install binutils
- 安装libc6 2.35(不要升级)
sudo apt install libc6=2.35-0ubuntu3
- 降级到libc62.31(千万别搞危险)
sudo aptitude install libc6=2.31-0ubuntu9
禁止ubuntu弹出更新功能
怎么禁止/开启Ubuntu自动更新升级_ubuntu命令行如何设置 取消 " 不支持的更新 " 选项-CSDN博客
sudo vim /etc/apt/apt.conf.d/10periodic
将“APT::Periodic::Update-Package-Lists "1";”修改成为"APT::Periodic::Update-Package-Lists "0";"
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析