[Linux Part 2] Setting up a development environment under Ubuntu (NFS\SSH\FTP\Smba\...)

  Currently, I am developing Linux-related projects, and my Linux development is 版本20.04carried out under Ubuntu ( ). For this purpose, I need to build a lot of Linux-related development environments to facilitate my work. The main purpose here is to make a summary and record of the construction of various development environments, which will be convenient for later reference and for colleagues who encounter difficulties on the road to Linux development. Okay, without further ado, let’s just list the installation steps for various development environments.

FTP

  During the development process, you may frequently transfer files between Windows and Ubuntu, such as writing code under Windows, and then passing the written code to Ubuntu for compilation. At this time, we can use the FTP service to implement Windows and Ubuntu Transfer files between each other (of course you can also use Samba).

FTP server (Ubuntu)

  1. Open a terminal window in Ubuntu, and then execute the following command to install the FTP service:
sudo apt-get install vsftpd
  1. After the FTP service is installed, open the vsftpd.conf file and modify the configuration as follows:
sudo vi /etc/vsftpd.conf

After opening, modify the following two lines:
Insert image description here
5. After the modification is completed, save and exit, and use the following command to restart the FTP service:

sudo /etc/init.d/vsftpd restart

At this point, the FTP Server on Ubuntu has been started.

FTP client (Windows)

  There are many FTP clients for Windows, you can choose one according to your preference. The FTP client I use is XFTP. For an introduction to the FTP client, you can refer to this article: https://zhuanlan.zhihu.com/p/301653835 .
Insert image description here
Insert image description here

NFS

  When developing Linux, network mounting (NFS) is generally not bypassed. Using NFS can greatly improve the efficiency of our development and debugging. To do this, we must first install and enable the NFS service on Ubuntu. Use the following command to install the NFS service.

  1. Install NFS server
sudo apt-get install nfs-kernel-server rpcbind 

  When installing nfs-kernel-server, apt will automatically install nfs-common and portmap

  1. Create an NFS shared directory.
    Create a shared folder under the path you want to set. For example, my shared folder is:
jack-virtual-machine:~/linux_imx6ull/nfs$ pwd
/home/jack/linux_imx6ull/nfs
  1. Modify the permissions of a shared directory
jack@jack-virtual-machine:~/linux_imx6ull/nfs$ chmod 777 . -R
  1. Modify the configuration file (/etc/exports),
    open the configuration file ( sudo vi /etc/exports), and add your own shared directory in the last line, as follows:
/home/jack/linux_imx6ull/nfs *(rw,async,no_root_squash)
  • /home/jack/linux_imx6ull/nfs: The shared directory of the nfs server. All files that need to be mounted through nfs can be placed in this directory.
  • *: Indicates that all network segments can be accessed (a specific IP can also be specified)
  • rw: Specify that the client mounting the shared directory has read and write permissions
  • sync: Data is written to the memory or hard disk synchronously
  • no_root_squash: When the client uses root to access the shared folder, the root user is not mapped.
  1. Modify the configuration file (/etc/default/nfs-kernel-server)
RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"

Insert image description here
  Versions after Ubuntu 18.04 should only support nfs3 and nfs4, and uboot uses nfs2 by default. Therefore, in order to make uboot's nfs command work normally, the above sentence must be added to make Ubuntu compatible with versions 2, 3, and 4.

  1. Restart NFS service
sudo /etc/init.d/nfs-kernel-server restart
  1. Verify that NFS is configured successfully
$ sudo mount -t nfs 192.168.100.113:/home/jack/linux_imx6ull/nfs /mnt
$ showmount -e
Export list for jack-virtual-machine:
/home/jack/linux_imx6ull/nfs *
$ sudo umount /mnt
  1. sudo mount -t nfs 192.168.100.113:/home/jack/linux_imx6ull/nfs /mnt

    • 192.168.100.113: The host address of the shared NFS directory (if it is mounted locally, it can be written as localhost)
    • /home/jack/linux_imx6ull/nfs: path to shared NFS
    • /mnt: mount point (can be specified arbitrarily)
  2. showmount -e: Display the configured shared directory (this command actually reads the /etc/exports file for parsing)

  3. sudo umount /mnt: cancel the mount

SSH

  After enabling the SSH service, we can use terminal software to log in to Ubuntu under Windows, such as Xshell, etc. Use the following command to enable the SSH service under Ubuntu.
4. Use the following command to check whether SSH has been installed
. If openssh-client and openss-server appear, it means that OpenSSH has been installed on the system.

$ dpkg --list | grep ssh
ii  libssh-4:amd64                             0.9.3-2ubuntu2.3                    amd64        tiny C SSH library (OpenSSL flavor)
ii  openssh-client                             1:8.2p1-4ubuntu0.9                  amd64        secure shell (SSH) client, for secure access to remote machines
ii  openssh-server                             1:8.2p1-4ubuntu0.9                  amd64        secure shell (SSH) server, for secure access from remote machines
ii  openssh-sftp-server                        1:8.2p1-4ubuntu0.9                  amd64        secure shell (SSH) sftp server module, for SFTP access from remote machines
ii  ssh-import-id                              5.10-0ubuntu1                       all          securely retrieve an SSH public key and install it locally
  1. Install SSH.
    You can use the following command to install SSH under Ubuntu:
sudo apt-get install ssh
  1. Check whether the SSH server is started
$ ps -auxf | grep ssh
root         891  0.0  0.1  12192  7148 ?        Ss   9月21   0:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
root       20934  0.0  0.2  14004  8848 ?        Ss   9月21   0:00  \_ sshd: jack [priv]
jack       21012  0.0  0.1  14004  6044 ?        S    9月21   0:00      \_ sshd: jack@notty
jack       21013  0.0  0.1   5892  4104 ?        Ss   9月21   0:00          \_ /usr/lib/openssh/sftp-server
jack        1609  0.0  0.0   6040   100 ?        Ss   9月21   0:00              \_ /usr/bin/ssh-agent /usr/bin/im-launch env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntu
jack       23312  0.0  0.0  17672   716 pts/1    S+   13:49   0:00  |       \_ grep --color=auto ssh

Cross-compilation tool chain

  1. Create a directory on Ubuntu to store the "cross-compilation tool chain". The directory I created is: /usr/local/arm;
  2. Copy the cross-compilation toolchain to the directory (/usr/local/arm), my toolchain is: gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz;
  3. Unzip
sudo tar -vxf gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz

  After decompression is completed, a folder named "gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf" will be generated. Under this folder is our cross-compilation tool chain.

  1. Modify environment variables
//打开配置文件
sudo vi /etc/profile
// 在配置文件中添加如下一行内容
export PATH=$PATH:/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin

Insert image description here

  1. Restart the Ubuntu system and the cross-compilation tool chain will be installed successfully.
  2. Install other related libraries
sudo apt-get install lsb-core lib32stdc++6
  1. Query the version and verify whether the installation is successful
arm-linux-gnueabihf-gcc -v

Insert image description here

samba

The following is the process of setting up the samba server environment:

  1. sudo apt-get update
sudo apt-get update
  1. Install samba server
sudo apt-get install samba samba-common
  1. Create a shared directory and set permissions on the shared directory
sudo mkdir samba 	// 创建完成之后,我的目录为 /home/jack/linux_imx6ull/samba
sudo chmod 777 . -R	// 将samba目录的权限修改为 777
  1. Modify the configuration file
    Open the configuration file ( vi /etc/samba/smb.conf) and make the following modifications:
[myshare]
comment=my share directory
path=/home/jack/linux_imx6ull/samba
browseable=yes
public=yes
writable=yes

Insert image description here

  1. set password
$ sudo smbpasswd -a jack	// 添加一个用户,jack
New SMB password: 			// 创建一个密码
Retype new SMB password:	// 再次确认密码
Added user jack.			// jack用户添加成功
  1. Restart samba server
sudo service smbd restart
  1. Run win+R on Windows and enter Ubuntu’s IP address. For example, my IP is 192.168.100.113
    Insert image description here
    Insert image description here

Guess you like

Origin blog.csdn.net/KXue0703/article/details/133139696