微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VirtualBox 安装Ubuntu20配置

1.virtualBox安装ubuntu虚拟机

2.网络设置

2.1 安装ssh-server

执行sudo apt-get install openssh-server

2.2启动ssh服务

执行sudo /etc/init.d/ssh start

2.3 检查ssh启动成功

ps -aux | grep ssh

3 网络配置

3.1 方法

选中ubuntu20->右击->设置->网络,如下图

增加映射规则

 

 创建远程登录会话:

 3.2 方法

登录成功后如 下图显示:

4 安装samba

4.1 查看ubuntu版本

ubuntu@ubuntu-VirtualBox:~/SoftWare$ cat /etc/issue
Ubuntu 20.04.2 LTS \n \l

4.2 更新ubuntu

ubuntu@ubuntu-VirtualBox:~/SoftWare$ sudo apt-get upgrade

4.3 查看samba安装情况

ubuntu@ubuntu-VirtualBox:~/SoftWare$ sudo dpkg -l | grep samba
[sudo] password for ubuntu:
ii  python3-samba                              2:4.11.6+dfsg-0ubuntu1.9            amd64        Python 3 bindings for Samba
ii  samba                                      2:4.11.6+dfsg-0ubuntu1.9            amd64        SMB/CIFS file, print, and login server for Unix
ii  samba-common                               2:4.11.6+dfsg-0ubuntu1.9            all          common files used by both the Samba server and client
ii  samba-common-bin                           2:4.11.6+dfsg-0ubuntu1.9            amd64        Samba common files used by both the server and the client
ii  samba-dsdb-modules:amd64                   2:4.11.6+dfsg-0ubuntu1.9            amd64        Samba Directory Services Database
ii  samba-libs:amd64                           2:4.11.6+dfsg-0ubuntu1.9            amd64        Samba core libraries
ii  samba-vfs-modules:amd64                    2:4.11.6+dfsg-0ubuntu1.9            amd64        Samba Virtual FileSystem plugins
ubuntu@ubuntu-VirtualBox:~/SoftWare$

4.4 安装samba

ubuntu@ubuntu-VirtualBox:~/SoftWare$ sudo apt-get install samba samba-common

4.4 修改smb.conf

ubuntu@ubuntu-VirtualBox:~$ sudo vim /etc/samba/smb.conf

增加如下片段:

[ubuntu]
 comment = my home
 browseable = yes
 path = /home/ubuntu
 create mask = 0777
 directory mask = 0777
 valid users = ubuntu
 writable = yes
 guest ok = no
 public = yes

4.5 添加 samba用户

 sudo smbpasswd -a ubuntu

4.6 重启samba

ubuntu@ubuntu-VirtualBox:~$ sudo service smbd restart

5 GIT

5.1 安装git

ubuntu@ubuntu-VirtualBox:~/SoftWare$ sudo apt-get install git

5.2 Git配置

5.3 大文件上传配置

sudo apt-get install  git-lfs   # 安装git lfs
git lfs track "*.zip"    # track指定文件
git add .gitattributes

git add .  # 添加文件
git commit -m 'commit msg'
git push -u origin master


 

6 Coredump

6.1 设定coredump文件大小

认情况下 coredump文件不生成的,其大小为0,可通过ulimit -c命令查看,若需生成coredump文件,则需调整coredump文件大小

ubuntu@ubuntu-VirtualBox:~$ ulimit -c
0                                           #认情况下 coredump文件不生成
ubuntu@ubuntu-VirtualBox:~$ ulimit -c 1024  #指定coredump文件大小为1024字节
ubuntu@ubuntu-VirtualBox:~$ ulimit -c
1024
ubuntu@ubuntu-VirtualBox:~$ ulimit -c       #指定coredump文件大小不受限制
unlimited

上述设定只在当前窗口有效,系统重启或切换其他窗口,则不起作用,若要永久有效,则需修改~/.bash_profile

#core dump设定
ulimit -c unlimited

ubuntu@ubuntu-VirtualBox:~$ source ~/.bash_profile   #重新加载
ubuntu@ubuntu-VirtualBox:~$ ulimit -c                #查看coredump配置
unlimited

6.2 设置coredump文件存储位置

文件/etc/sysctl.conf中追加如下内容

ubuntu@ubuntu-VirtualBox:~$ sudo vim  /etc/sysctl.conf

#coredump 文件配置
kernel.core_pattern = /home/ubuntu/coredump/coredump_%e_%p
#生成的coredump文件加上pid
kernel.core_uses_pid = 0

在/proc/sys/kernel/core_pattern文件中设置了apport.service,该服务是ubuntu官方为自动收集系统错误的,会直接导致core_pattern的设置不能生效,需要修改/etc/default/apport文件,将enabled 设置为0.

ubuntu@ubuntu-VirtualBox:~$ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E


#查看apport.service配置
ubuntu@ubuntu-VirtualBox:~$ cat /etc/default/apport      
# set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1
enabled=1

#修改apport配置
ubuntu@ubuntu-VirtualBox:~$ sudo vim /etc/default/apport


enabled=0  #设置为0

#再次查看apport
ubuntu@ubuntu-VirtualBox:~$ cat /etc/default/apport
# set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1
#enabled=1
enabled=0

6.3 重启系统

    6.1 6.2 步骤完成后,ubuntu系统重启

6.4 验证

   找到一个出现coredump的程序运行, 该程序需加入支持gdb调试功能, 修改相应的CMakeList.txt

SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
ubuntu@ubuntu-VirtualBox:~/C_ENV/OpenGL/cmake-build-debug$ ./OpenGL
2022-08-24 17:25:56.229  [ INFO]  /home/ubuntu/C_ENV/OpenGL/src/simple/TestAccumulation.cpp TestAccumulation 16  ========constructor===========
2022-08-24 17:25:56.230  [ INFO]  /home/ubuntu/C_ENV/OpenGL/src/simple/TestAccumulation.cpp drawTestAccumulation 162  ========drawTestAccumulation===========
2022-08-24 17:25:56.230  [ INFO]  /home/ubuntu/C_ENV/OpenGL/src/simple/TestAccumulation.cpp init 26  ========init===========
2022-08-24 17:25:58.429  [ INFO]  /home/ubuntu/C_ENV/OpenGL/src/simple/TestAccumulation.cpp init 39  ========init====finish=======
2022-08-24 17:25:58.429  [ INFO]  /home/ubuntu/C_ENV/OpenGL/src/util/WindowUtil.cpp createWindow 23  ======createWindow====width=640 height=400==windowName=test accumulation===
Segmentation fault (core dumped)

在6.2设置的coredump文件存储位置/home/ubuntu/coredump可以看到coredump文件已经生成

ubuntu@ubuntu-VirtualBox:~/coredump$ cd /home/ubuntu/coredump
ubuntu@ubuntu-VirtualBox:~/coredump$ ll
total 15476
drwxrwxr-x  2 ubuntu ubuntu     4096 8月  24 17:25 ./
drwxr-xr-x 29 ubuntu ubuntu     4096 8月  24 17:25 ../
-rw-------  1 ubuntu ubuntu 28868608 8月  24 17:25 coredump_OpenGL_1682

6.5 coredump 分析

     使用readlef查看coredump文件

ubuntu@ubuntu-VirtualBox:~/coredump$ readelf -h coredump_OpenGL_1682
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              CORE (Core file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          0 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         327
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0

使用objdump 查看时, 可以看到 no symbols, 表明当前的coredump文件无符号表信息

ubuntu@ubuntu-VirtualBox:~/coredump$ objdump -x coredump_OpenGL_1682 | tail
383 load324       00004000  00007ffd62bdb000  0000000000000000  01b81000  2**12
                  CONTENTS, ALLOC, LOAD, READONLY
384 load325       00002000  00007ffd62bdf000  0000000000000000  01b85000  2**12
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
385 load326       00001000  ffffffffff600000  0000000000000000  01b87000  2**12
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
SYMBOL TABLE:
no symbols

使用GDB分析

ubuntu@ubuntu-VirtualBox:~/C_ENV/OpenGL/cmake-build-debug$ gdb OpenGL /home/ubuntu/coredump/coredump_OpenGL_2335
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from OpenGL...
[New LWP 2335]
[New LWP 2336]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./OpenGL'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
65      ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
[Current thread is 1 (Thread 0x7f4859b89780 (LWP 2335))]
(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
#1  0x00007f4859c5fd45 in __vfprintf_internal (s=0x7f4859dd46a0 <_IO_2_1_stdout_>,
    format=0x7f4859bb80f0 "%s \033[0;32m [ INFO] \033[0m %s %s %d  ======createWindow====width=%d height=%s==windowName=%s===\n",
    ap=ap@entry=0x7ffecae61a20, mode_flags=mode_flags@entry=0) at vfprintf-internal.c:1688
#2  0x00007f4859c48d6f in __printf (format=<optimized out>) at printf.c:33
#3  0x00007f4859bb72fa in WindowUtil::createWindow (width=640, height=400, windowName=0x5599609ec004 "test accumulation")
    at /home/ubuntu/C_ENV/OpenGL/src/util/WindowUtil.cpp:30
#4  0x00007f485a126505 in TestAccumulation::drawTestAccumulation (this=0x7ffecae61b97, width=640, height=400, windowName=0x5599609ec004 "test accumulation")
    at /home/ubuntu/C_ENV/OpenGL/src/simple/TestAccumulation.cpp:168
#5  0x00005599609c87f5 in main (argc=1, argv=0x7ffecae61ca8) at /home/ubuntu/C_ENV/OpenGL/main.cpp:47
(gdb)

可以看到问题出现在

#1  0x00007f4859c5fd45 in __vfprintf_internal (s=0x7f4859dd46a0 <_IO_2_1_stdout_>,
    format=0x7f4859bb80f0 "%s \033[0;32m [ INFO] \033[0m %s %s %d  ======createWindow====width=%d height=%s==windowName=%s===\n",
    ap=ap@entry=0x7ffecae61a20, mode_flags=mode_flags@entry=0) at vfprintf-internal.c:1688

输出时,参数的格式化出现了错误

原文地址:https://www.jb51.cc/wenti/3285833.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐