Skip to content
Animesh Trivedi edited this page Aug 19, 2024 · 36 revisions

Who provides a particular file?

https://askubuntu.com/questions/481/how-do-i-find-the-package-that-provides-a-file

dpkg -S /bin/ls

Finding systems information

Who is using a particular device or details:

$ lsblk -f 

NAME        FSTYPE            FSVER LABEL    UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0       squashfs          4.0                                                       0   100% /snap/snapd/21759
nullb0                                                                                           
nvme4n1     linux_raid_member 1.2   XXX:1 f458521f-60b4-e9e2-6385-a4de38e7b1f2                
└─md1       xfs                              74ffc5cc-b273-4084-b2c2-8eba2373bb5f                
nvme2n1     linux_raid_member 1.2   XXX:1 f458521f-60b4-e9e2-6385-a4de38e7b1f2                
└─md1       xfs                              74ffc5cc-b273-4084-b2c2-8eba2373bb5f                
nvme5n1     linux_raid_member 1.2   XXX:1 f458521f-60b4-e9e2-6385-a4de38e7b1f2                
└─md1       xfs                              74ffc5cc-b273-4084-b2c2-8eba2373bb5f                
nvme3n1     linux_raid_member 1.2   XXX:1 f458521f-60b4-e9e2-6385-a4de38e7b1f2                
└─md1       xfs                              74ffc5cc-b273-4084-b2c2-8eba2373bb5f                
nvme0n1                                                                                          
├─nvme0n1p1 vfat              FAT32 efi      845D-9488                             504.9M     1% /boot/efi
└─nvme0n1p2 ext4              1.0   root     5560dbe9-b75a-442c-8d67-ce3bdde75b63  792.3G     5% /
nvme1n1     ceph_bluestore                                                                       
├─nvme1n1p2                                                                                      
└─nvme1n1p3                                                                                      
ublkb0                                                                                           

or then

lsof /dev/nvme1n1

Which system type I have

dmidecode | grep -A3 '^System Information' 

What kind of RAM I have

sudo lshw -short -C memory
# or 
sudo dmidecode | grep DDR
# or 
sudo lshw | grep DDR

What kind of CPU I have

lscpu 

What kind of PCIe slots have

sudo dmidecode --type 9

dmidecode Types:

          0   BIOS
          1   System
          2   Baseboard
          3   Chassis
          4   Processor
          5   Memory Controller
          6   Memory Module
          7   Cache
          8   Port Connector
          9   System Slots
         10   On Board Devices
         11   OEM Strings
         12   System Configuration Options

Upgrading Ubuntu distribution

https://linuxiac.com/how-to-upgrade-ubuntu-server-to-22-04-from-20-04/

change DNS with netplan

https://www.ricmedia.com/set-custom-dns-servers-on-ubuntu-18-or-20/

atr@stosys-qemu-vm:/home/atr/new/zns-resources/stosys-class/stosys-project-code$ cat /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens3:
      dhcp4: true
      nameservers: 
        addresses: [8.8.8.8, 8.8.4.4, 1.1.1.1]
  version: 2
atr@stosys-qemu-vm:/home/atr/new/zns-resources/stosys-class/stosys-project-code$ 

scp

scp * scp://atr@localhost:7777:~/

top memory

https://www.tecmint.com/find-linux-processes-memory-ram-cpu-usage/

# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

Packages on a fresh systems

uuid downgrade on ubuntu 20

Generally you can downgrade the package by specifying the version in "="

atr@atr-xps-13:~/vu/github/xnvme$ sudo apt-get install uuid-dev 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 uuid-dev : Depends: libuuid1 (= 2.34-0.1ubuntu9) but 2.34-0.1ubuntu9.1 is to be installed
E: Unable to correct problems, you have held broken packages.
atr@atr-xps-13:~/vu/github/xnvme$ sudo apt-get install libuuid1=2.34-0.1ubuntu9
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be DOWNGRADED:
  libuuid1
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 20.1 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://nl.archive.ubuntu.com/ubuntu focal/main amd64 libuuid1 amd64 2.34-0.1ubuntu9 [20.1 kB]
Fetched 20.1 kB in 0s (290 kB/s)    
dpkg: warning: downgrading libuuid1:amd64 from 2.34-0.1ubuntu9.1 to 2.34-0.1ubuntu9
(Reading database ... 218997 files and directories currently installed.)
Preparing to unpack .../libuuid1_2.34-0.1ubuntu9_amd64.deb ...
Unpacking libuuid1:amd64 (2.34-0.1ubuntu9) over (2.34-0.1ubuntu9.1) ...
Setting up libuuid1:amd64 (2.34-0.1ubuntu9) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
atr@atr-xps-13:~/vu/github/xnvme$ sudo apt-get install uuid-dev 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  uuid-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 33.6 kB of archives.
After this operation, 171 kB of additional disk space will be used.
Get:1 http://nl.archive.ubuntu.com/ubuntu focal/main amd64 uuid-dev amd64 2.34-0.1ubuntu9 [33.6 kB]
Fetched 33.6 kB in 0s (1,022 kB/s)  
Selecting previously unselected package uuid-dev:amd64.
(Reading database ... 218997 files and directories currently installed.)
Preparing to unpack .../uuid-dev_2.34-0.1ubuntu9_amd64.deb ...
Unpacking uuid-dev:amd64 (2.34-0.1ubuntu9) ...
Setting up uuid-dev:amd64 (2.34-0.1ubuntu9) ...
Processing triggers for man-db (2.9.1-1) ...
atr@atr-xps-13:~/vu/github/xnvme$ 

https://askubuntu.com/questions/881629/problem-installing-uuid-dev

ssh need 600 files

atr@atr-xps-13:~/.ssh$ chmod 600 ~/.ssh/* 
chown $USER:$USER ~/.ssh/config 

Change default editor

    sudo update-alternatives --config editor

https://www.howtogeek.com/howto/ubuntu/change-the-default-editor-from-nano-on-ubuntu-linux/

Evince/AppArmor issue

libmount.so.1: failed to map segment from shared object AppArmor

https://askubuntu.com/questions/486150/evince-error-while-loading-shared-libraries-permission-denied

Did sudo aa-complain /usr/bin/evince

Sudo management

https://unix.stackexchange.com/questions/215412/allow-certain-guests-to-execute-certain-commands

https://kifarunix.com/run-only-specific-commands-with-sudo-in-linux/

john ALL=(ALL) NOPASSWD: /bin/systemctl restart NetworkManager

Put it after the %sudo line

Disabling kernel smt

vim /etc/defaults/grub
"nosmt=force" 

Ubuntu services

List user sessions

loginctl list-sessions

https://unix.stackexchange.com/questions/394709/how-to-return-the-currently-active-user-session-on-a-graphical-linux-desktop-ses

disable hyperthreading

#echo off > /sys/devices/system/cpu/smt/control

https://serverfault.com/questions/235825/disable-hyperthreading-from-within-linux-no-access-to-bios

io monitoring

-d is duration, watch -n 1 is a wrong way as it always prints the stats from the boot time.

sudo iostat -d 1 /dev/nullb0

hung ssh connection

~. #reset 

https://www.cyberciti.biz/faq/openssh-linux-unix-osx-kill-hung-ssh-session/

deb file query

user@host:~$ dpkg-query -S /bin/bash 
bash: /bin/bash

https://superuser.com/questions/179353/how-do-i-find-out-which-package-owns-a-file

Compiling kernel on ubuntu from scratch

https://wiki.ubuntu.com/KernelTeam/GitKernelBuild

#make olddefconfig
make menuconfig
make -j $(getconf _NPROCESSORS_ONLN) deb-pkg LOCALVERSION=-custom
sudo dpkg -i linux-image-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb
sudo dpkg -i linux-headers-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb
sudo dpkg -i linux-libc-dev_5.12.0+-6_amd64.deb

sudo update-grub2 
sudo sync 
sudo reboot

the libc development files are owned by the libc packages

atr@node3:/usr/include/linux$ dpkg-query -S blkzoned.h 
linux-headers-5.4.0-90: /usr/src/linux-headers-5.4.0-90/include/uapi/linux/blkzoned.h
linux-libc-dev:amd64: /usr/include/linux/blkzoned.h
linux-headers-5.12.0+: /usr/src/linux-headers-5.12.0+/include/uapi/linux/blkzoned.h

Deb management

dpkg -l | grep urserver 
dpkg -P urserver # remove 
dpkg -i ./*.deb #install 

Certificate compilation issue

https://unix.stackexchange.com/questions/293642/attempting-to-compile-kernel-yields-a-certification-error

-> did not solve, module_intall error.

Now trying

cd /lib/modules/$(uname -r)/build/certs

sudo tee x509.genkey > /dev/null << 'EOF'
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = myexts
[ req_distinguished_name ]
CN = Modules
[ myexts ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid
EOF

sudo openssl req -new -nodes -utf8 -sha512 -days 36500 -batch -x509 -config x509.genkey -outform DER -out signing_key.x509 -keyout signing_key.pem
Oct 7th 2022

Permission key errors https://askubuntu.com/questions/1329538/compiling-the-kernel-5-11-11

  $ scripts/config --disable SYSTEM_TRUSTED_KEYS
  $ scripts/config --disable SYSTEM_REVOCATION_KEYS

WORKED!

Compilation error with vmlinux-gdb.py

dpkg-source: error: cannot represent change to vmlinux-gdb.py:
dpkg-source: error:   new version is symlink to /home/fab-user/Documents/Source/linux/scripts/gdb/vmlinux-gdb.py
dpkg-source: error:   old version is nonexistent

just delete the vmlinux-gdb.py sym link file. https://stackoverflow.com/questions/56149191/linux-latest-stable-compilation-cannot-represent-change-to-vmlinux-gdb-py

Debugging network traffic

netstat -pan | grep "10.149.0"

This should show you the applications that are using the network

Setup NAT forwarding

sysctl file cat /etc/sysctl.conf

# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -I POSTROUTING --out-interface eno2 -j MASQUERADE

https://linuxconfig.org/how-to-turn-on-off-ip-forwarding-in-linux

User management

  • add a new user with sudo rights: sudo useradd -s /bin/bash -d /home/atr/ -m -G sudo atr

https://www.cyberciti.biz/faq/create-a-user-account-on-ubuntu-linux/

SSH stuff

ssh-keygen -> generate a key pair and give it a name ssh-copy-id -i file username@host or if you want to add manually then add the public key in the authorized_keys file as a new line (making a new file, (umask 077 && touch ~/.ssh/authorized_keys))

ssh-copy-id -i key.pub demo@198.51.100.0

when sshing: ssh -i key.pub username@host

Or in the ssh config file (~/.ssh/config`):

  1 ServerAliveInterval 10
  2 
  3 Host vu-ssh
  4   HostName ssh.data.vu.nl
  5   User xxxx
  6   IdentityFile ~/.ssh/xxx.key
  7 
  8 Host das5
  9   HostName fs0.das5.cs.vu.nl
 10   User xxx
 11   ProxyJump vu-ssh

https://linuxize.com/post/using-the-ssh-config-file/ https://serverpilot.io/docs/how-to-use-ssh-public-key-authentication/

Linux dev

Setting up kdump : https://www.linuxjournal.com/content/oops-debugging-kernel-panics-0 (might not work with Virtual Box)

How to find NIC NUMA node

cat /sys/class/net/[NIC]/device/numa_node

Set a device IRQ affinity

sudo /usr/sbin/set_irq_affinity_cpulist.sh 8 enp134s0f1

Bash history of TCP tuning

sudo /usr/sbin/set_irq_affinity_cpulist.sh 8 enp134s0f1
top
sudo /usr/sbin/set_irq_affinity_cpulist.sh 16 enp134s0f1
sudo /usr/sbin/set_irq_affinity_cpulist.sh 15 enp134s0f1
cd src/
s
ls
sudo ./a.out 
cd zrl/netperf/
ll
./src/netserver -D 
cat ~/crail-deployment/crail/bin/crail
cat ~/crail-deployment/crail/bin/crail~
numactl 
numactl -N 1 -m 1 ./src/netserver -D 
sudo cpufreq-set -r -g performance
numactl -N 1 -m 1 ./src/netserver -D 
./src/netserver -D 
numactl -N 1 -m 1 ./src/netserver -D 
numactl -C 8 -m 1 ./src/netserver -D 
numactl -C 16 -m 1 ./src/netserver -D 
numactl -C 15 -m 1 ./src/netserver -D 
top
sudo /usr/sbin/set_irq_affinity_cpulist.sh 8 enp134s0f1
top
sudo /usr/sbin/set_irq_affinity_cpulist.sh 16 enp134s0f1
sudo /usr/sbin/set_irq_affinity_cpulist.sh 15 enp134s0f1
cd src/
s
ls
sudo ./a.out 
htop
ifstat -l
cp ./backup/sysctl-100g.conf /etc/sysctl.conf 
sudo cp ./backup/sysctl-100g.conf /etc/sysctl.conf  
sudo sysctl -p 
cd backup/
sudo cp ./sysctl.conf /etc/sysctl.conf
sudo sysctl -p 
ifstat -l
ifconfig 
cd zrl/netperf/ ; 10.100.0.15
ll
./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 4K 
./src/netperf -H 10.100.0.14 -t RDMA_SEND_LAT 
./src/netperf -H 10.100.0.14 -t RDMA_SEND_LAT -- -m 128
./src/netperf -H 10.100.0.14 -t RDMA_SEND_LAT -- -m 128,128
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_SEND_LAT -- -m 128,128
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 128K -s 1 -i 1 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 128K -s 1 -i 1 -h 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 256K -s 1 -i 1 -P 1,1 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 512K -s 1 -i 1 -P 1,1 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 1M -s 1 -i 1 -P 1,1 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 1M  -i 1 -P 1,1 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t RDMA_READ_BW -- -m 1M  -P 1,1 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M 
ifconfig 
vim README_STORAGE 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -s 128K -S 128K -- -m 8M 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -s 64K -S 64K -- -m 8M 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -s 64K -S 64K -h -- -m 8M 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -s 64K -S 64K -- -m 8M -h 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -s 128K,128K -S 128K,128K 
B=64K; numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -s $B,$B -S $B,$B 
B=32K; numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -s $B,$B -S $B,$B 
B=16K; numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -s $B,$B -S $B,$B 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -S ,128K
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -S ,64K
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -S ,45K
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M -S ,43690
cpufreq-set
cat /proc/cpuinfo 
cpufreq-set -r -g performance
sudo cpufreq-set -r -g performance 
cat /proc/cpuinfo 
sudo cpufreq-set -r -g performance 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M
watch -n 1 grep MHz /proc/cpuinfo
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 8M
for ((i=1; i < 64; i*=2)); do echo $i; done ; numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M
for ((i=1; i < ; i*=2)); do numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m "$i"M; done 
iconv
ifconfig 
ethtool enp134s0f1
ethtool -i enp134s0f1
ethtool -a enp134s0f1
ethtool -c enp134s0f1
ethtool -k enp134s0f1
for ((i=1; i < 64; i*=2)); do echo $i; done ; numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -h 
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -P 22221,22222 &&  numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -P 22223,22224
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -P 22221,22222 &  numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -P 22223,22224
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -P 22221,22222 &  numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -P 22223,22224 & numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M -P 22225,22226
./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M
numactl -N 1 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M
cat /sys/class/net/enp134s0f1/device/numa_node
cat/sys/devices/system/node/node1/cpulist
cat /sys/devices/system/node/node1/cpulist
cat /sys/devices/system/node/node0/cpulist
/usr/sbin/set_irq_affinity_cpulist.sh 8 ethN
/usr/sbin/set_irq_affinity_cpulist.sh 
/usr/sbin/set_irq_affinity_cpulist.sh 8 enp134s0f1 
sudo /usr/sbin/set_irq_affinity_cpulist.sh 8 enp134s0f1  
numactl 
numactl -C 8 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M
numactl -C 15 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -- -m 1M
numactl -C 15 -m 1 ./src/netperf -H 10.100.0.14 -t TCP_STREAM -l 20 -- -m 1M
w
ifconfig 
mlnx_tune
sudo mlnx_tune 
sudo mlnx_tune -h
ls -l /home/jpf/test.c 
cat  /home/jpf/test.c 
sudo cp -r /home/jpf/Tools/i7z/ src/
cd src/
ll
cd i7z/
ll
./i7z 
sudo ./i7z  
cd ..
ll
cp /home/jpf/test.c . 
ll
cpp test.c 
man cpp
gcc test.c 
ll
./a.out 
sudo ./a.out  
vim test.c 
gcc test.c 
./a.out 
sudo ./a.out  
sudo cpufreq-set -r -g
sudo cpufreq-set -r -g performance 
sudo cpufreq-set -r -g performance --min 3.8
cat /proc/cpuinfo 
sudo cpufreq-set -r -g performance --min 2.9GHz --max 2.9GHz 
cat /proc/cpuinfo 
vim ~/local/bin/watch-cpufreq.sh 
chmod +x ~/local/bin/watch-cpufreq.sh 
watch-cpufreq.sh 
vim ~/local/bin/set-cpufreq.sh 
chmod +x  ~/local/bin/set-cpufreq.sh 
sudo cpufreq-set -r -g userspace --min 2.9GHz --max 2.9GHz 
lsmod | grep pstate
lsmod | grep gov
lsmod | grep intel
modinfo cpufreq_userspace
modinfo intel_powerclamp 
modinfo acpi-cpufreq
cat /sys/devices/system/cpu/intel_pstate/no_turbo
echo 1 cat /sys/devices/system/cpu/intel_pstate/no_turbo 
echo 1 >  /sys/devices/system/cpu/intel_pstate/no_turbo 
sudo echo 1 >  /sys/devices/system/cpu/intel_pstate/no_turbo  
sudo su 
watch-cpufreq.sh 
cpupower freq-info
cpupower frequency-info
sudo cpupower frequency-info
cat /proc/sys/net/core/rmem_max 
cat /proc/sys/net/core/rmem_default 
cat /proc/sys/net/ipv4/tcp_rmem 
cat /proc/sys/net/ipv4/tcp_wmem 
sysctl -p
sudo sysctl -p 
man sysctl
lspci | grep Ethernet
lspci -s 86:00.0 -vvv | grep PCIeGen
lspci -s 86:00.0 -vvv 
sudo lspci -s 86:00.0 -vvv  
sudo lspci -s 86:00.0 -vvv  | grep PCIeGen
sudo lspci -s 86:00.0 -vvv  | grep MaxReadReq
cd src/i7z/
sudo ./i7z 
top
sudo ./i7z 
top
sudo ./i7z 
cd crail-deployment/spark
ll
jps -l 
numactl 
numactl -a
numactl 
numactl -s
Clone this wiki locally