0%

Consolidating the foundation of Linux, linux tips

Linux Tips

Record the commands that I use more frequently in the form of a memo, and will continue to increase according to usage in the future.

# Commands Comment
Basis:
apt update
apt upgrade
apt autoremove
apt install update-manager-core
do-release-upgrade
flameshot``flameshot gui Capture screen
Ctrl + Alt + F1/../F7 Enter or quit terminal
killall <nautilus> Kill file manager
pkill Xorg, restart lightdm Log out
1 ls -alrRt -r: reverse, -R: Recursive
cp -ar(R)pv -p keep mode,ownership,timestamps; -r equals -R
tail -nf Output the last n line appended data as the file grows
more/less File perusal filter for crt viewing, less opposite of more
wc Print newline, word, and byte couts for each file,-l line
tar -czf/cjf -j bzip2, .tar.bz2, max compression; -z gzip, tar.gz
$(date "+%Y%m%d-%H%M%S") Get the current system time
sshfs user@ip:/dir name mount sshfs
fuser mount -u name unmount sshfs , umount -l name for busy error
Supper Mode
find . -type f -exec cat {} + find and cat flies recursively
find . -type f -exec ls {} + find . type f -exec ls {} \;
find ./ -type f -exec sed -i 's/old/new/g' {} \; Replace all old in the current directory with new
Performance:
swapon --show Check swap space
swapoff -a
dd if=/dev/zero of=/swapfile bs=1G count=8
mkswap /swapfile
swapon /swapfile
grep SwapTotal /proc/meminfo
Extend swap space to 8G
free -h
top,htop Interactive process viewer
vmstat Report virtual memory statistics
pmap Report memory map of a process
kmemleak Embeded memeory analysis tool
Directory:
/var/cache/apt/archives/ All archived debs
hexedit,hex Hexdump
xxd Make a hexdump or do the reverse
strings -a -a Scan the whole file
cpio -if Copy files to and from archives
Other
addgroup lee vboxusers Make virtual box recognize USB
*/?/[xyz]/[^xyz]/[!xyz]/[a~z] Regular expression
make > /dev/null
`while true; do adb shell cat /proc/interrupts grep kgsl; sleep 0.5; done`
adb shell cd sdcard nohup watch -n 5 'cat /sys/bus/cpu/devices/cpu0/online >> online.log' &
readelf -h vmlinux
nm List symbols from object files, `nm -n vmlinux
ldd Print shared object dependencies, list dynamic dependencies, likes xxx.so
objdump Display information from object files, disassembler
ndisasm -u The Netwide Disassembler, an 80x86 binary file disassembler
c++filt Demangle C++ and Java symbols
hexdump, hd ASCII, decimal, hexadecimal, octal dump, hexdump -s 0x18408a8 -n 1024 vmlinux
file Determine file type, file *.img, *.mbn, *.bin ...
readelf Displays information about ELF files,`readelf -hlSVAI vmlinux
objdump Display information from object(files) xxx-objdump -afphG vmlinux
objcopy Copy and tranlate objects, eg:Generate zImage with vimlinux
[android-unpackbootimg](https://github.com/anestisb/android-unpackbootimg) -i boot.img -o boot_img/
python3 [extract-dtb.py](https://github.com/PabloCastellano/extract-dtb) kernel Get dts from kernel
dtc -I dtb -O dts ... -o ... Disassembler
od Dump files in octal and other formats
vim -b file + :%!xxd -u + :%!xxd -r Edit ELF file, -u to hex, -r to binary
ltrace A library call tracer
strace Trace system calls and signals
gdb The GNU debugger
strip Discard symbols from object files
lsof List open files opened by processes
fuser Identify processes using files or sockets
/proc Process information pseudo-filesystem
ELF Format of Executable and Linking Format(ELF) files