Ubuntu's three protocols and the beautification of Vim

I. Introduction

        Three commonly used network protocols in Ubuntu: saamba, tftp, nfs. Used to implement file sharing and network transfer in computers

 2. Briefly introduce what Samba, TFTP and NFS are?

  1.   Samba: Samba is an open source implementation of the Windows file sharing protocol (such as SMB/CIFS), allowing file and printer sharing between Linux/UNIX systems and Windows systems. Through Samba, Linux/UNIX systems can interact with Windows systems as file servers, allowing Windows systems to access and operate shared files and printers on Linux/UNIX systems. Samba also provides some additional features such as user authentication and security settings.
  2.   TFTP: TFTP (Trivial File Transfer Protocol) is a simple file transfer protocol, usually used to transfer small files in computer networks, such as configuration files, firmware upgrades, etc. Compared with other file transfer protocols, TFTP has simpler functions and does not support list viewing of files and directories. It communicates based on the UDP protocol, using a simple request-response mode, and is usually used within a local area network.
  3. NFS: NFS (Network File System) is a UNIX-based file sharing protocol that allows different computers to access and share files through the network. NFS uses a client-server architecture, in which the file server shares part or all of the local file system to the client. Clients can access shared files as if they were local files without knowing the underlying details of the server. NFS supports cross-platform operations, so file sharing can be achieved between different operating systems, such as UNIX, Linux, and Windows.

   3. Samba protocol:

1. Install samba protocol:

sudo apt update 
sudo apt install samba samba-common

2. Create a shared directory:

mkdir shared

3. Modify the configuration file: configure shared in the smb.conf file:

sudo vim /etc/samba/smb.conf
在文件末尾加上共享文件信息。

[shared] 
//改为希望在 Windows 中看到共享目录的名字—自定义 
path = /home/pm/shared 
//路径改为要共享的目录路径 
browseable = yes 
public = yes 
available = yes 
writable = yes 
valid users = pm 
//用户名改为:当前 ubuntu 系统的用户名

4. Set a password for the samba user , such as: p m 

pm@ubuntu:~$ sudo smbpasswd -a pm

5. Restart the samaba service

pm@ubuntu:~$ sudo /etc/init.d/smbd restart 
[ ok ] Restarting smbd (via systemctl): smbd.service.

6. Access the shared directory in Windows, execute cmd and enter //ip (linux IP)

 7. Enter the account password (set in Part 4)

8. Click Mapping in Windows.


 4. TFTP service:

1. Update the software source first

sudo apt update

 2. Download tftp protocol

sudo apt-get install tftp-hpa tftpd-hpa

3. Create a tftp working directory in the root directory

sudo mkdir/tftpboot

4. Give permissions to the tftpboot folder

sudo chmod  777 /tftpboot/

5. Configuration

sudo vim /etc/default/tftpd-hpa

Modify the tftp path: /var/lib/tftpboot to /tftpboot (depending on the individual, some people may have different working paths, you can modify it yourself)

 6. Restart tftp:

sudo service tftpd-hpa restart

7. Test, as shown in the figure 

 You can explore more tftp commands by yourself.

5. NFS service:

1. Update the source first

2. Install NFS service     

sudo apt-get install nfs-kernel-server

3. Copy the system files to the opt directory and extract them:

Decompression command: tar -cvzf filesystem

解压命令:tar -cvzf  filesystem
Ps 补充一下解压相关知识:
tar [ -t | -x | -u | -c | -v | -f | -j | -z ] tarfile filelist 选项 描述 -t 显示归档文件中的内容
-x 释放归档文件
-u 更新归档文件
-c 创建一个新的归档文件
-v 显示归档和释放的过程信息
-f 用户指定归档文件的文件名,否则使用默认名称
-j 由tar生成归档,然后由bzip2压缩
-z 由tar生成归档,然后由gzip压缩                      
  具体用法: 
    压缩: 
       tar -zvf hello.gz 1.c 2.c 3.c 
       tar -jvf hello.bz2 1.c 2.c 3.c
                        
    解压:通用: 
      tar -cxvf hello.gz
      tar -cxvf hello.bz2

4. cd to the opt directory to check whether it is successful.

5.  Add the shared file system path in the configuration file

pm@ubuntu:/opt/filesystem$ sudo vim /etc/exports

If you want to set the "/opt/ filesystem  " directory as an NFS shared directory, add the following line at the end of the file:

Pay attention to the position of " , " and "_" in line 12

 6. Enable NFS V2 version

pm@ubuntu:/opt/filesystem$ sudo vim /etc/default/nfs-kernel-server 

Add the following configuration at the end of the file:

RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"

 7. Restart NFS

pm@ubuntu:/opt/rootfs$ sudo /etc/init.d/nfs-kernel-server restart

8. Test

1 》Create a mount point in the user’s home directory:

p m @ubuntu:~$ mkdir mnt

2 》Mount NFS shared file system: rootfs

pm@ubuntu:~$ sudo mount 192.168.90.114:/opt/rootfs ./mnt

3 》View the mount point

If you can see the contents of the filesystem directory in the mount point mnt , it means that the nfs service is configured successfully! 

6. Vim beautification

(1) Configure vim in the user directory

Configure under user permissions: vim ~/.vimrc

The following is my personal vim beautification: (available for everyone to choose)

"共享剪贴板  
set clipboard=unnamed 
set ruler                  " 打开状态栏标尺
set cursorline              " 突出显示当前行
set magic                  " 设置魔术
set guioptions-=T          " 隐藏工具栏
set guioptions-=m          " 隐藏菜单栏
" 语法高亮
set syntax=on
" 自动缩进
set autoindent
set cindent
" Tab键的宽度
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 不要用空格代替制表符
set noexpandtab
" 在行和段开始处使用制表符
set smarttab
" 显示行号
set number
" 历史记录数
set history=1000
"搜索逐字符高亮
set hlsearch
set incsearch
"行内替换
set gdefault
"编码设置
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
"语言设置
set langmenu=zh_CN.UTF-8
set helplang=cn
" 总是显示状态行
set laststatus=2
" 命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight=2
" 侦测文件类型
filetype on
" 载入文件类型插件
filetype plugin on
" 为特定文件类型载入相关缩进文件
filetype indent on
" 保存全局变量
set viminfo+=!
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" 字符间插入的像素行数目
set linespace=0
" 增强模式中的命令行自动完成操作
set wildmenu
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=2
" 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
set report=0
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
" 光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" 为C程序提供自动缩进
set smartindent

(2) Root directory configuration file:

sudo vim /etc/vim/vimrc

Just append the above content to the end, save and exit (all created users can use it)

        

Guess you like

Origin blog.csdn.net/apple_71040140/article/details/131985006