局域网下使用samba服务在Linux系统与Windows系统直接共享文件是一项很方便的操作。以Ubuntu为例配置samba服务,Linux服务器的版本是Ubuntu 18.04.1 LTS。
在终端中执行下列指令:cat /etc/issue查看当前正在运行的 Ubuntu 的版本号。
以下是我的安装配置步骤:
(1)更新当前软件。
sudo apt-get upgrade
sudo apt-get update
sudo apt-get dist-upgrade
(2)安装samba服务器。
sudo apt-get install samba samba-common
(3)创建一个用于分享的samba目录。
sudo mkdir /home/linuxidc/linuxidc.com/share
(4)给创建的这个目录设置权限
sudo chmod 777 /home/linuxidc/linuxidc.com/share
(5)添加用户(下面的linuxidc是我的用户名,之后会需要设置samba的密码)。
sudo smbpasswd -a linuxidc
(6)配置samba的配置文件。
sudo nano /etc/samba/smb.conf
在配置文件smb.conf的最后添加下面的内容:
[share]
comment = share folder
browseable = yes
path = /home/linuxidc/linuxidc.com/share
create mask = 0700
directory mask = 0700
valid users = linuxidc
force user = linuxidc
force group = linuxidc
public = yes
available = yes
writable = yes
在上面valid users = linuxidc中的linuxidc为我的用户名。
(7)重启samba服务器。
sudo service smbd restart
(8)Windows徽标+R 在弹出的运行窗口中输入 \ip即可访问。如\192.168.182.188,输入samba用户名及密码访问即可看到共享,然后就可以在Linux系统与Windows系统直接进行文件共享了
Win+R:在弹出的运行窗口中输入\ip(在ubuntu中用ifconfig查看ip)即可访问。
如果提示:提示你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问。这些策略可帮助保护你的电脑免受网络上不安全设备或恶意设备的威胁。
解决方法见:https://www.linuxidc.com/Linux/2018-11/155467.htm
(9)输入samba用户名及密码访问即可看到共享文件夹share。
上传创建文件
(10)选中share,点击右键,选择映射网络驱动器。
(11)最终结果如下图。
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx
本文永久更新链接地址:https://www.linuxidc.com/Linux/2018-11/155466.htm
安装samba服务器
#forCentOS
yum install samba
#forDebian
apt-get installsamba
配置samba服务器
vi /etc/samba/smb.conf
在配置文件最后加入下面配置可以把整个linux文件系统共享出来:
[root]
comment=this is Linux share directory
path=/
public=yes
writable=yes
guest ok=no
create mask=0775
directory mask=0775
启动samba服务器,别忘了关闭SELinux,否则可能导致权限问题
#for CentOS
service smb restart
service nmb restart
#for Debian
service smbd restart
service nmbd restart
设置root帐户密码
smbpasswd -a root
开放防火墙
#for CentOS
iptables -I INPUT -p tcp --dport 139 -j ACCEPT
iptables -I INPUT -p tcp --dport 445 -j ACCEPT
iptables -I INPUT -p udp --dport 137 -j ACCEPT
iptables -I INPUT -p udp --dport 138 -j ACCEPT
service iptables save
windos下面使用samba服务器
打开”我的电脑”,”工具”菜单下面的”映射网络驱动器”
选择其它用户
输入 \xx.xx.xx.xx\root
输入 root
输入 “密码”
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接https://blog.csdn.net/tianxionj/article/details/71170150?utm_source=blogxgwz1
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/jiejiemcu/article/details/90814387
收起
前言
首先Windows下是没有linux的依赖的,因此在Windows向下编写linux的代码是无法实现自动补全的,那么解决的办法就是将linux的依赖拿到Windows上,编写程序轻松一点,然后在linux上编译即可。
①
要知道linux的依赖在 /usr/include 目录下,只需要把它拷贝到Windows上即可,我是通过share与Windows进行交互的,不用依赖啥网络。
cp -r /usr/include/ /mnt/hgfs/share/
1
②
在linux中随便建立一个文件夹,保存拷贝出来的依赖,我是放在D:\Program Files\linux_include目录下,拷贝过来即可
③
重点来了,需要设置vscode的全局includePath配置
默认的情况下includePath 在 c_cpp_properties.json 中设置,也就是工程目录下的一些头文件设置,如果你是只需要在工程目录下找到这些依赖的话,只需配置c_cpp_properties.json文件即可。(这个文件可以自己在.vscode中创建)
添加以下代码:
"includePath": [
"${workspaceFolder}/**",
"D:/Program Files/linux_include/include/**"
],
但是我们需要将这项依赖全局化,让所有使用linux打开的工程都能找到这些依赖,我们就要设置vscode的全局includePath。
首先选中 “管理” -> “设置” -> 输入Settings -> “在Settings.json中编辑”。
在这里插入图片描述
打开Settings.json文件,添加以下代码:
"[cpp]": {
"editor.quickSuggestions": true
},
"[c]": {
"editor.quickSuggestions": true
},
"C_Cpp.default.includePath": [
"D:/Program Files/linux_include/include/x86_64-linux-gnu/**",
"${workspaceFolder}/**",
"D:/Program Files/linux_include/include/**",
"D:/Program Files/linux_include/include/"
],
上面的这些代码是对应的依赖路径(可以适当调整的)
"D:/Program Files/linux_include/include/x86_64-linux-gnu/**",
"D:/Program Files/linux_include/include/**",
"D:/Program Files/linux_include/include/"
至此,我们看到linux编写的代码就不会找不到依赖:
在这里插入图片描述
并且还能自动补全:
在这里插入图片描述
在这里插入图片描述
附配置文件:
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"includePath": [
"${workspaceFolder}/**",
"D:/Program Files/linux_include/include/**"
],
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
Settings.json
{
"files.autoGuessEncoding": true,
"workbench.statusBar.feedback.visible": true,
// 控制工作台底部状态栏的可见性。
"workbench.statusBar.visible": false,
"terminal.integrated.env.windows": {
"PATH": "C:\\Users\\jiejie\\.aos\\python-venv\\Scripts;${env:PATH}"
},
"window.zoomLevel": 0,
"workbench.startupEditor": "welcomePage",
"editor.renderWhitespace": "none",
"editor.renderControlCharacters": false,
"breadcrumbs.enabled": false,
"C_Cpp.updateChannel": "Insiders",
"aliosStudio.showWelcome": false,
"cmake-tools-helper.cmake_download_path": "c:\\Users\\jiejie\\.vscode\\extensions\\maddouri.cmake-tools-helper-0.2.1\\cmake_download",
"[cpp]": {
"editor.quickSuggestions": true
},
"[c]": {
"editor.quickSuggestions": true
},
"C_Cpp.default.includePath": [
"D:/Program Files/linux_include/include/x86_64-linux-gnu/**",
"${workspaceFolder}/**",
"D:/Program Files/linux_include/include/**",
"D:/Program Files/linux_include/include/"
],
}
SSH 为 Secure Shell 的缩写,为建立在应用层基础上的安全通信协议。
一、检查SSH服务是否已启动
Ubuntu系统默认是没有SSH服务的,故要检查SSH服务是否已安装。
打开终端输入以下指令:
1 $ ps -e | grep ssh
2
3 7529 ? 00:00:00 sshd
4 7852 pts/1 00:00:00 ssh
若输入指令后显示类似于上图所示,则说明SSH服务已启动
其中sshd表示ssh-server已启动,ssh表示ssh-client已启动
二、安装SSH服务
安装SSH的客户端和服务端:
1 $ sudo apt-get install openssh-client
2
3 $ sudo apt-get install openssh-server
三、启动SSH服务
安装完成后通过以下指令启动:
1 $ sudo /etc/init.d/ssh start
启动后通过以下指令判断SSH服务是否正确启动:
$ ps -e | grep ssh
若启动成功,则终端内会出现类似于第一步出现的结果
四、修改SSH端口号
SSH默认端口号为22,若有修改SSH端口号的需求,则运行以下指令打开SSH配置文件:
1 $ sudo gedit /etc/ssh/sshd_config
可以看到如下图所示:
修改端口号(Port)后,重启SSH服务即可生效,命令如下:
1 $ sudo /etc/init.d/ssh restart
五、SSH远程登录
SSH服务启动后,即可远程登陆,登陆命令格式为:ssh 帐号@IP地址,例如:
1 $ ssh [email protected]
其中帐号指的是Ubuntu的登录帐号
若不知道IP地址可以通过以下指令查看:
1 $ ifconfig -a
输入该指令后找到如下图所示处:
其中inet即为本机IP地址
登录指令输入后根据提示输入Ubuntu下该帐号的密码即可以远程登录
远程登录后若想退出,输入以下指令即可:
1 $ exit
六、数据传输
完成SSH服务配置之后即可实现基于SSH的数据传输,最常用方便的指令便是scp,以下是常用scp指令:
$ scp -r [email protected]:/home/lk /root //将远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的所有文件拷贝到本地 /root 文件夹中
$ scp [email protected]:/home/lk/test.jar /root //将远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的test.jar文件拷贝到本地 /root 文件夹中
$ scp -r /root [email protected]:/home/lk //将本地 /root 中的所有文件拷贝到远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的文件夹中
$ scp /root/test.jar [email protected]:/home/lk //将本地 /root 中的test.jar文件拷贝到远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的文件夹中
scp的通用指令格式为:scp [参数] [原路径] [目标路径]
其中-r参数意为:递归复制整个目录
转载自 :https://www.cnblogs.com/asyang1/p/9467646.html
本地win10, cmd输入
ssh-keygen -t rsa -b 4096
记事本打开
.ssh\id_rsa.pub
复制内容到远程linux的
~/.ssh/authorized_keys
保存。应该就可以了
注意config要在.ssh\id_rsa.pub相同目录
转账链接 : https://zhuanlan.zhihu.com/p/117292835
关闭用户图形界面,使用tty登录。
sudo systemctl set-default multi-user.target
sudo reboot
开启用户图形界面。
sudo systemctl set-default graphical.target
sudo reboot