Ubuntu Utils - stereoboy/Study GitHub Wiki

Basic Utils

NFS

Boot Repair

coredump

sudo apt-get install systemd-coredump

netcat nc

iperf

$ iperf -s 
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size:  128 KByte (default)
------------------------------------------------------------
[  1] local 192.168.0.2 port 5001 connected with 192.168.0.13 port 55978
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-10.0718 sec   272 MBytes   227 Mbits/sec
$ iperf -c 192.168.0.2
------------------------------------------------------------
Client connecting to 192.168.0.2, TCP port 5001
TCP window size:  162 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.13 port 55978 connected with 192.168.0.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   272 MBytes   228 Mbits/sec

lsof

sudo lsof -i TCP:22
[sudo] password for wom: 
COMMAND    PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
sshd      1184 root    3u  IPv4   34248      0t0  TCP *:ssh (LISTEN)
sshd      1184 root    4u  IPv6   34250      0t0  TCP *:ssh (LISTEN)
ssh     282448  wom    3u  IPv4 2684259      0t0  TCP wom:34832->192.168.0.13:ssh (ESTABLISHED)
ssh     285196  wom    3u  IPv4 2700037      0t0  TCP wom:47238->ec2-54-193-231-0.us-west-1.compute.amazonaws.com:ssh (ESTABLISHED)

gdb

gdb tui

gdb -tui --args /opt/gst/bin/gst-launch-1.0 -v  tcpserversrc host=127.0.0.1 port=5001 ! tcpserversink host=127.0.0.1 port=5002

gdbgui

ddd

Install Debug Symbol by apt-get

locale

truncate

truncate -s 0 /var/log/syslog

Thread Analysis using ps

$ ps -eTf |  awk 'NR==1{print} /main.py/{print}'
UID          PID    SPID    PPID  C STIME TTY          TIME CMD
wom        63003   63003   17808  1 12:57 pts/1    00:00:00 python3 ./main.py
wom        63004   63004   63003  0 12:57 pts/1    00:00:00 python3 ./main.py
wom        63107   63107   57979  0 12:58 pts/8    00:00:00 awk NR==1{print} /main.py/{print}
# ps -aux                                                                                                                          
                                                                                                                                                    
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND                                                                          
root           1  0.0  0.0   3884  3060 pts/2    Ss   02:24   0:00 bash                                                                             
root          50  0.0  0.0   9612  3228 pts/2    S+   02:25   0:00 tmux                                                                             
root          52  0.7  0.1  38908 32288 ?        Rs   02:25   1:41 tmux                                                                             
root          53  0.0  0.0   3884  3096 pts/3    Ss   02:25   0:00 -bash                                                                            
root          63  0.0  0.0   3884  3088 pts/4    Ss+  02:25   0:00 -bash                                                                            
pulse        323  2.8  0.0 460016 27688 ?        S<l  02:29   5:58 pulseaudio -D --verbose --exit-idle-time=-1 --system --disallow-exit             
root         340  0.0  0.0   3884  3084 pts/5    Ss   02:29   0:00 -bash                                                                            
root        2341 85.2  0.1 1284732 41936 pts/5   Sl+  05:58   0:06 ./nesfr_vr_ros2       # <- target_process_to_analyze
root        2380  0.0  0.0   5480  2392 pts/3    R+   05:59   0:00 ps -aux
# ps -T -p 2341
    PID    SPID TTY          TIME CMD
   2341    2341 pts/5    00:00:00 nesfr_vr_main
   2341    2358 pts/5    00:00:02 rs2-gimbal-ctrl
   2341    2359 pts/5    00:00:00 robot-ctrl
   2341    2360 pts/5    00:00:00 robot-ctrl
   2341    2361 pts/5    00:00:00 robot-ctrl
   2341    2362 pts/5    00:00:00 robot-ctrl
   2341    2363 pts/5    00:00:00 robot-ctrl
   2341    2364 pts/5    00:00:00 robot-ctrl
   2341    2365 pts/5    00:00:00 robot-ctrl
   2341    2366 pts/5    00:00:00 robot-ctrl
   2341    2367 pts/5    00:00:00 robot-ctrl
   2341    2368 pts/5    00:00:00 robot-ctrl
   2341    2369 pts/5    00:00:00 robot-ctrl
   2341    2370 pts/5    00:00:02 v4l2src-right:s
   2341    2371 pts/5    00:00:02 v4l2src-left:sr
   2341    2372 pts/5    00:00:02 v4l2src-main:sr
   2341    2373 pts/5    00:00:00 threaded-ml
   2341    2374 pts/5    00:00:00 pulsesrc-audio-
   2341    2375 pts/5    00:00:00 threaded-ml
   2341    2376 pts/5    00:00:00 queue0:src
   2341    2377 pts/5    00:00:00 udpsrc-audio-ou
   2341    2378 pts/5    00:00:00 pulsesrc-audio-
   2341    2379 pts/5    00:00:00 pool-nesfr_vr_r
 ps -eLf | grep gst
wom       185873  185872  185873  0    1  9월18 ?      00:00:11 cscope -dl -f /home/wom/jylee/gstreamer/cscope.out
wom       284977  228559  284977  1    4 16:53 pts/3    00:00:00 /opt/gst/bin/gst-launch-1.0 -v tcpserversrc host=127.0.0.1 port=5001 ! tcpserversink host=127.0.0.1 port=5002
wom       284977  228559  284978  0    4 16:53 pts/3    00:00:00 /opt/gst/bin/gst-launch-1.0 -v tcpserversrc host=127.0.0.1 port=5001 ! tcpserversink host=127.0.0.1 port=5002
wom       284977  228559  284979  0    4 16:53 pts/3    00:00:00 /opt/gst/bin/gst-launch-1.0 -v tcpserversrc host=127.0.0.1 port=5001 ! tcpserversink host=127.0.0.1 port=5002
wom       284977  228559  284980  0    4 16:53 pts/3    00:00:00 /opt/gst/bin/gst-launch-1.0 -v tcpserversrc host=127.0.0.1 port=5001 ! tcpserversink host=127.0.0.1 port=5002

ldconfig & /etc/ld.so.conf

cpp to print defined macros recursively

cpp -dM /usr/include/errno.h | grep 'define E' | sort -n -k 3

diff

diff --color  -u test0.txt test1.txt 
--- test0.txt	2022-12-21 13:13:54.344511510 +0900
+++ test1.txt	2022-12-21 13:13:47.704507874 +0900
@@ -1,5 +1,5 @@
 abcdefg
 fadsafdf
-adfafadsf
-fdsfaadsf
+fadfadfadfadsfad
 adfadfasd
+

Network Utils

nmcli: network device setup

brctl: bridge setup

iptables

Package Utils

Download Packages from Web

Example of libeigen3-dev of bionic

Use add-apt-repository

sudo apt-get install software-properties-common

Install Graphics Drivers

sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update
sudo apt-get install nvidia-driver-xxx
$ ubuntu-drivers list
nvidia-driver-525, (kernel modules provided by linux-modules-nvidia-525-generic)
nvidia-driver-418-server, (kernel modules provided by linux-modules-nvidia-418-server-generic)
nvidia-driver-515-server, (kernel modules provided by linux-modules-nvidia-515-server-generic)
nvidia-driver-470, (kernel modules provided by linux-modules-nvidia-470-generic)
nvidia-driver-510, (kernel modules provided by linux-modules-nvidia-510-generic)
nvidia-driver-450-server, (kernel modules provided by linux-modules-nvidia-450-server-generic)
nvidia-driver-470-server, (kernel modules provided by linux-modules-nvidia-470-server-generic)
nvidia-driver-515, (kernel modules provided by linux-modules-nvidia-515-generic)
nvidia-driver-525-server, (kernel modules provided by nvidia-dkms-525-server)
nvidia-driver-390, (kernel modules provided by linux-modules-nvidia-390-generic)

Intel integrated HD graphics for Display, NVIDIA-GPU for CUDA

## check display card and driver status
sudo lshw -c display
# or sudo lshw -c video

## check loaded display card and driver
lsmod | grep nvidia
# or nvidia-smi
# or lsmod | grep nouveau

## remove old Nvidia driver
sudo apt purge nvidia-*
# or sudo apt remove nvidia-*

## add driver repository
sudo add-apt-repository ppa:graphics-drivers/ppa

## identify suitable driver version
sudo ubuntu-drivers devices
## if ubuntu-drivers command not found
sudo apt install ubuntu-drivers-common

## install drivers from ppa database
sudo apt install nvidia-driver-430
# sudo apt install nvidia-XYXYX nvidia-settings
# v430 was the recommended and the latest by writing this gist

## this installs drivers from Nvidia
wget http://us.download.nvidia.com/tesla/418.67/NVIDIA-Linux-x86_64-418.67.run
# or wget http://us.download.nvidia.com/XFree86/Linux-x86_64/418.74/NVIDIA-Linux-x86_64-418.74.run
# supporting packages may need to be installed before running following
sudo bash ./NVIDIA-Linux-x86_64-418.67.run --dkms

## reboot
sudo reboot

## check driver details and settings
nvidia-smi or nvidia-settings

## select driver
prime-select query
## usage: sudo prime-select nvidia or sudo prime-select intel

## set nvidia
sudo prime-select nvidia 

## Reboot and Goto BIOS
## Set BIOS Display Setup as Integrated Graphics, not External GPU or External PCI
## connect HDMI cable to intel GPU Head
## Reboot

## display usage
dpkg -L nvidia-driver-430

Downgrade pkg version

apt-cache showpkg <package_name>
apt-cache show <package_name>
apt-cache madison <package_name>

apt-cache madison vim
       vim | 2:8.1.2269-1ubuntu5.4 | http://ftp.daum.net/ubuntu focal-updates/main amd64 Packages
       vim | 2:8.1.2269-1ubuntu5.4 | http://ftp.daum.net/ubuntu focal-security/main amd64 Packages
       vim | 2:8.1.2269-1ubuntu5 | http://ftp.daum.net/ubuntu focal/main amd64 Packages
apt list -a vim
Listing... Done
vim/focal-updates,focal-security,now 2:8.1.2269-1ubuntu5.4 amd64 [installed]
vim/focal 2:8.1.2269-1ubuntu5 amd64

vim/focal-updates,focal-security 2:8.1.2269-1ubuntu5.4 i386
vim/focal 2:8.1.2269-1ubuntu5 i386

Remove PPA Repository

sudo apt-add-repository --remove ppa:inivation-ppa/inivation-bionic
 Neuromorphic vision company.
Packages for Ubuntu Bionic 18.04 LTS.
 More info: https://launchpad.net/~inivation-ppa/+archive/ubuntu/inivation-bionic
Press [ENTER] to continue or Ctrl-c to cancel removing it.

Window Mode

systemctl get-default
sudo systemctl set-default multi-user.target
sudo systemctl reboot
systemctl get-default
sudo systemctl set-default graphical.target
sudo reboot

jounalctl -b -1 for Shutdown Process

 Change the line in /etc/systemd/journald.conf from the compiled-in default...
#Storage=auto

Power Key Setup

Shut down immediately by Power Key

Graphical Mode

$ gsettings list-recursively | grep logout-prompt
org.gnome.SessionManager logout-prompt true
$ gsettings set org.gnome.SessionManager logout-prompt false
$ gsettings get  org.gnome.SessionManager logout-prompt
true
$ dconf write /org/gnome/gnome-session/logout-prompt false
$ dconf read /org/gnome/gnome-session/logout-prompt 
true

Text Mode

  • Nothing to do

Ignore Power Key

sudo vim /etc/systemd/logind.conf
...
HandlePowerKey=ignore
...

sudo systemctl restart systemd-logind

Dell Aurora Kernel Panics

Google Remote Setup for Ubuntu

Hangul Korean Setup with ibus on Ubuntu