foreword
Linux programming is a very important part of Linux learning. We can improve programming efficiency through some tools. When facing some large source codes, using source insight can help us edit codes very well, but some codes must be in the virtual Compile in the machine environment, so at this time, you can use samba to share the directory of the virtual machine to windows, so that you can use source insight to open the source code in the windows environment for editing.
preliminary work
The virtual machine environment I use is ubuntu16.04 64-bit desktop system
Download address: Ubuntu Releases
The virtual machine version is not as high as possible. If the computer configuration is low, try to choose a low version of ubuntu
1. Use the root user to log in to ubuntu16.04
First open the terminal and type
sudo gedit /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf
Then add two lines of code at the end of the text
user-session=ubuntu
greeter-show-manual-login=true
all-guest=false
as the picture shows:
Then open another terminal and type
sudo gedit /root/.profile
Add the code at this point in the text
tty -s &&
Finally, restart the virtual machine and enter the root user to log in
Reference article link: ubuntu16.04 uses root user login_ubuntu16root login_mr__bai's blog-CSDN blog
Second, install the samba service
Open the terminal and enter the command to install the samba service
apt-get install samba samba-common
Note that you are using the root user to log in to ubuntu at this time, and you don’t need to enter a password for any operation. This is the benefit of the root user, which is faster and more efficient.
After installation, create a new folder in the root directory as a shared folder
Enter the code in the terminal to add a user
smbpasswd -a 用户名
Then edit the /etc/samba/smb.conf file with
gedit /etc/samba/smb.conf
Add the following at the end
[share]
path = /share
available = yes
valid users = lhh
read only = no
browsable = yes
public = yes
writable = yes
create mask = 777
directory mask = 777
force user = lhh
force group = lhh
available = yes
browseable = yes
Finally, enter the command in the terminal to restart the samba service
service smbd restart
3. Windows connects to samba service
Enter ifconfig in the virtual machine terminal to get the ip of ubuntu
Open windows explorer, right click on this computer, select add a network location
Keep clicking Next, enter the ip address of the virtual machine on this page
Note that the share here corresponds to this name
Finally, enter your newly created username and password to connect to the shared folder.
At this time, if your shared folder does not have permission, you need to give permission
chmod 777 /share -R
# share 你的共享文件夹根目录
4. Practical application
Create several folders, put the source code in the src directory, build the source insight project in the soc directory, put the libraries to be linked in the lib directory, put the headers that need to be added in the include directory, and add the new After the file, don't forget to re-assign permissions
chmod 777 /share -R
# share 你的共享文件夹根目录
After that, you can directly change the code in source insight
When compiling, connect to the virtual machine through ssh, and then execute the make command, so that you can modify and compile the code without switching to the virtual machine
If you don’t know how to connect to virtual machine ssh, you can refer to my article
Use ssh to connect to the virtual machine nanny level tutorial - Yuansec's Blog - CSDN Blog
If the development board is connected to the computer, you can directly write a script, compile it first, and download it to the development board directly with the scp command after compiling, so that it can be solved directly with one click, which greatly saves efficiency.
Summarize
This article is just to send out some of my own experience, not necessarily the best, but I still hope that my article can be helpful to you!