日常问题日志

 

Q1: 如何解决虚拟机挂起后,重新登录Ubuntu系统时间无法自动更新的问题. [Linux] [220708]

A: 安装ntpdate,并输入以下命令,可以解决每次开机自动更新时间问题. [S]

  • sudo apt install ntpdate
  • echo "natpdate edu.ntp.org.cn" >> /etc/profile
  • chmod +s /usr/sbin/ntpdate
  • source /etc/profile

Q2: 如何解决 VM VirtualBox 上 Ubuntu 无法粘贴来自 windows 的网址链接问题. [Linux] [git]

A:

  • 调整虚拟机设置-常规-高级里的“共享粘贴板”和“拖放”设置为“双向”. 依然无法粘贴. [F]
  • 键入命令行 VBoxClient --clipboard 开起剪切板服务. [S]
  • 将剪切板服务加入启动项,自动开启. [S] [220709]
    • echo "VBoxClient --clipboard" | sudo tee -a /etc/profile [More Q4]
    • Ctrl + Shift + v 粘贴操作在 terminal 中已可将 windows 下复制网址进行粘贴.
  • 如果之后还是会出现无法复制情况,按下列命令键入. [S] [220709]
apt-get remove -y virtualbox-guest-x11
apt-get remove -y virtualbox-guest-dkms
apt-get remove -y virtualbox-guest-utils
reboot
wget https://download.virtualbox.org/virtualbox/6.1.2/VBoxGuestAdditions_6.1.2.iso
mkdir /media/iso
mount VBoxGuestAdditions_6.1.2.iso /media/iso -o loop
/media/iso/VBoxLinuxAdditions.run
yes
reboot

Q3: git 为何设立 staging area ,而不是直接 commit. [git]

A: https://stackoverflow.com/questions/49228209/whats-the-use-of-the-staging-area-in-git

  • staging helps you split up one large change into multiple commit.
  • staging helps in reviewing changes.
  • staging helps when a merge has conflicts.
  • staging helps you keep extra local files hanging around.
  • staging helps you sneak in small changes.

Q4: 如何使用 sudo 重定向写入一个没有权限的文件. [Linux] [220709]

A: https://stackoverflow.com/questions/82256/how-do-i-use-sudo-to-redirect-output-to-a-location-i-dont-have-permission-to-wr

  • 例如问题 -bash: /etc/profile: Permission denied.
  • The redirection of the output is not performed by sudo.

Q5: 如何修改PS1值并保存设置. [Linx] [220712]

A: https://askubuntu.com/questions/984060/export-ps1-for-customizing-shell-prompt

  • 进入 ~/.bashrc 里对 PS1 进行编辑,退出后利用 source ~/.bashrc 重新加载. [S]
  • PS1颜色的设置格式:\[ \033[ @m \ ]. 其中 @ 代表颜色值,如浅绿 1;32, 浅红 1;31.

Q6: SIGSTKSZ 值的问题. [Gcc] [220714]

A: /usr/include/x86_64-linux-gnu/bits/sigstack.h

  • #define SIGSTKSZ 8192.

Q7: No manul entry for errno in section 3 [Linux] [220717]

A: https://unix.stackexchange.com/questions/12702/no-manual-page-for-regex-in-section-3-where-is-it

  • In Ubuntu this man page belongs to manpages-dev package.
  • sudo apt-get install manpages manpages-dev manpages-posix manpages-posix-dev.

Q8: Git 设置:连接SSH [Git] [220723]

A: 关键命令

  • Check for existing SSH Key: ls -al ~/.ssh.
  • Generate new SSH Key: ssh-keygen -t ed25519 -C "your_email@example.com"
  • Adding SSH Key to the ssh-agent: ssh-add ~/.ssh/id_rsa.
  • Copy the SSH public key to github account: cat ~/.ssh/id_rsa.pub.
  • Test SSH connection: ssh -T git@github.com.

Q9: Segmentation Fault/Core Dump [C] [220725]

A: A segmentation fault ( SEGFAULT ) occurs when you are trying to access memory which you should not be trying to access ( the memory which you have not allocated ) .

  • Writing to read-only memory rasies a segmentation fault.
  • Out of array range: Core Dump.
  • Global variable and local variable use the same name.
    [220914]
  • When dereferencing a NULL pointer.
  • When dereferencing an uninitialized or dangling pointer.
  • When you get a Buffer Overflow.
  • when you get a Stack Overflow.
  • When you try to change the value of a variable marked as const using pointers.
  • When you try to access free'd memory.
    [S] [221120]
  • 使用gdb调试找出问题程序行.

Q10: What are the differences between exit(0) and exit(1) [C/C++] [220807]

A:

  • Both exit(0) and exit(1) are jump statments and are used to terminate the program.
    And both report the status of termination of the program to the operating system.
  • exit(0) define the clean exit without any error in the program.
  • exit(1) means that it is an abnormal or unsuccessful termianation of the program.

Q11: 如何在 vim 中按界定符对齐 [Linux] [Vim] [220808]

A: Tabular plugin


Q12: Error: relocation R_X86_64_32 against '[SYMBOL]' [Gcc] [220810]

A: https://wiki.ubuntu.com/SecurityTeam/PIE

  • In Ubuntu 16.10, has enabled “--enable-default-pie” option by default.
  • specify “-no-pie” option during link stage of generating final executable binary.

Q13: Error: undefined reference to `initscr' [Gcc] [220810]

A: https://stackoverflow.com/questions/805343/undefined-reference-when-using-ncurses-on-linux

  • the linker needs the library file to find the actual code to link into your program.
  • gcc hello1.c -o hello1 -lcurses. ( "-l"+"header" )

Q14: Error: Calling memset causes segmentation fault [C][221022]

A: https://stackoverflow.com/questions/16793612/calling-memset-causes-segmentation-fault

  • attempts to write to an uninitialised pointer.

Q15: Difference between Real User ID, Effective User ID and Saved User ID [Linux] [221222]

A: https://stackoverflow.com/questions/32455684/difference-between-real-user-id-effective-user-id-and-saved-user-id


Q16: C fopen VS open [Linux] [230104]

A: https://stackoverflow.com/questions/1658476/c-fopen-vs-open


posted @ 2022-07-15 19:05  Dy2MoRaw  阅读(100)  评论(0)    收藏  举报