To remote debug using gdb:
Run the following command on the remote machine:
gdbserver :<port> --attach <pid>
gdbserver will attach to the process with the pid of <pid> and listens on <port>.
Now on the local machine,
gdb <path to binary>
target remote <remote ip>:<port>
For more information checkout the gdbserver and gdb man pages.
This article explains the top command and what each line means.
top – 10:29:46 up 44 min, 4 users, load average: 0.40, 0.31, 0.44
Tasks: 220 total, 2 running, 218 sleeping, 0 stopped, 0 zombie
Cpu(s): 24.4%us, 4.9%sy, 0.0%ni, 70.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 4135036k total, 3234068k used, 900968k free, 94480k buffers
Swap: 4192252k total, 0k used, 4192252k free, 825100k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2798 root 20 0 152m 71m 9340 S 17.3 1.8 6:15.56 ruby
1028 root 20 0 287m 219m 31m R 3.3 5.4 0:18.03 Xorg
What does all the numbers on the CPU line means?
The third line indicates how the cpu is used. If you sum up all the percentages the total will be 100% of the cpu. Let’s see what these values indicate in order:
Percentage of the CPU for user processes (0.3%us)
Percentage of the CPU for system processes (0.0%sy)
Percentage of the CPU processes with priority upgrade nice (0.0%ni)
Percentage of the CPU not used (99,4%id)
Percentage of the CPU processes waiting for I/O operations(0.0%wa)
Percentage of the CPU serving hardware interrupts (0.3% hi — Hardware IRQ
Percentage of the CPU serving software interrupts (0.0% si — Software Interrupts
The amount of CPU ‘stolen’ from this virtual machine by the hypervisor for other tasks (such as running another virtual machine) this will be 0 on desktop and server without Virtual machine. (0.0%st — Steal Time)
I tried to copy a folder from a remote machine:
acm@acm-docker2:/$ sudo rsync -avz email@example.com:/opt/symas /opt/
The authenticity of host ‘10.40.8.168 (10.40.8.168)’ can’t be established.
ECDSA key fingerprint is 38:0c:ee:74:49:65:7d:74:35:b3:a0:76:13:db:5e:74.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘10.40.8.168’ (ECDSA) to the list of known hosts.
Permission denied, please try again.
..and failed because the root account is locked by default so I have to set a password first:
sudo passwd root
I ran the command again and this time it works.
This creates a user called testuser and gives it a home directory
sudo useradd -d /home/testuser -m testuser