为了在 Linux 上从访客访问主机,我正在阅读多个答案,我发现了两种方法。
但是,他们不为我工作。
我使用VirtualBox
Version 6.1.12 r139181 (Qt5.12.5)
$ uname -r
5.7.8-1.el8.elrepo.x86_64
$
现在,来自嘉宾
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
$
$ uname -r
5.4.0-42-generic
$
地点
$ pwd
/home/anita
$
anita@ubuntu--k8s-master:~$ ll
total 112
drwxr-xr-x 19 anita anita 4096 jul 29 19:58 ./
drwxr-xr-x 3 root root 4096 jul 23 00:10 ../
-rw------- 1 anita anita 5909 jul 31 09:15 .bash_history
-rw-r--r-- 1 anita anita 220 jul 23 00:10 .bash_logout
-rw-r--r-- 1 anita anita 3771 jul 23 00:10 .bashrc
drwx------ 15 anita anita 4096 jul 27 00:33 .cache/
drwxr-xr-x 14 anita anita 4096 jul 26 14:22 .config/
drwxr-xr-x 2 anita anita 4096 jul 23 00:34 Desktop/
drwxr-xr-x 3 anita anita 4096 jul 28 00:05 Documents/
drwxr-xr-x 2 anita anita 4096 jul 23 00:34 Downloads/
drwx------ 3 anita anita 4096 jul 28 00:00 .gnupg/
drwxrwx--- 1 root vboxsf 4096 jul 31 08:34 host/
drwxrwxr-x 4 anita anita 4096 jul 29 12:04 .kube/
drwxr-xr-x 3 anita anita 4096 jul 23 00:34 .local/
drwx------ 5 anita anita 4096 jul 23 23:03 .mozilla/
drwxr-xr-x 2 anita anita 4096 jul 23 00:34 Music/
drwxr-xr-x 2 anita anita 4096 jul 23 00:34 Pictures/
-rw-r--r-- 1 anita anita 807 jul 23 00:10 .profile
drwxr-xr-x 2 anita anita 4096 jul 23 00:34 Public/
drwxr-xr-x 3 anita anita 4096 jul 23 21:57 snap/
drwx------ 2 anita anita 4096 jul 26 14:20 .ssh/
-rw-r--r-- 1 anita anita 0 jul 23 22:03 .sudo_as_admin_successful
drwxr-xr-x 2 anita anita 4096 jul 23 00:34 Templates/
-rw-r----- 1 anita anita 5 jul 29 19:57 .vboxclient-clipboard.pid
-rw-r----- 1 anita anita 5 jul 29 19:57 .vboxclient-display-svga-x11.pid
-rw-r----- 1 anita anita 5 jul 29 19:57 .vboxclient-draganddrop.pid
-rw-r----- 1 anita anita 5 jul 29 19:57 .vboxclient-seamless.pid
drwxr-xr-x 2 anita anita 4096 jul 23 00:34 Videos/
anita@ubuntu--k8s-master:~$
使用usermod
anita@ubuntu--k8s-master:~$ sudo usermod -aG vboxsf $USER
anita@ubuntu--k8s-master:~$
使用adduser
anita@ubuntu--k8s-master:~$ sudo adduser $USER vboxsf
The user `anita' is already a member of `vboxsf'.
anita@ubuntu--k8s-master:~$
测试顺序为访问(读/写)
anita@ubuntu--k8s-master:~$ cd host/
bash: cd: host/: Permission denied
anita@ubuntu--k8s-master:~$
而不是根。
anita@ubuntu--k8s-master:~$ sudo -i
[sudo] password for anita:
root@ubuntu--k8s-master:~# ls -l /home/anita/host/
total 69032
drwxrwx--- 1 root vboxsf 4096 jul 21 06:02 bin
drwxrwx--- 1 root vboxsf 4096 jul 5 20:30 Desktop
drwxrwx--- 1 root vboxsf 4096 jul 23 00:00 Develops
drwxrwx--- 1 root vboxsf 4096 ago 1 10:31 Documents
drwxrwx--- 1 root vboxsf 4096 ago 1 10:12 Downloads
-rwxrwx--- 1 root vboxsf 58477923 jul 21 07:26 minikube
drwxrwx--- 1 root vboxsf 4096 jul 5 20:30 Music
drwxrwx--- 1 root vboxsf 4096 jul 23 01:03 Pictures
drwxrwx--- 1 root vboxsf 4096 jul 7 19:16 Programs
drwxrwx--- 1 root vboxsf 4096 jul 5 20:30 Public
drwxrwx--- 1 root vboxsf 4096 ago 1 10:55 snap
drwxrwx--- 1 root vboxsf 4096 jul 5 20:30 Templates
-rwxrwx--- 1 root vboxsf 1764044 jul 6 01:03 test.wav
-rwxrwx--- 1 root vboxsf 1905 jul 6 02:50 text
drwxrwx--- 1 root vboxsf 4096 jul 6 05:40 Videos
drwxrwx--- 1 root vboxsf 4096 jul 25 21:08 'VirtualBox VMs'
root@ubuntu--k8s-master:~#
会发生什么?
我该如何解决这个问题?
答案1
通过查看您提供的命令序列,您应该能够访问您~/host
安装的目录。
我假设您需要从当前注销+登录shell
才能重新读取您的组并允许您访问组权限。打开新的终端窗口/选项卡或从 X 窗口管理器注销/登录,以便在访问文件夹时能够使用 GUI 应用程序~/host
。