Cross-Compilation Overview
Cross-compilation involves building executables on a high-performance host architecture (like x86) to run on a different target architecture (like ARM). This approach leverages the host's superior resources and tooling, streamlining the development process before deployment to resource-constrained embedded devices.
Command Reference
1. apt
Advanced Package Tool (apt) serves as the primary package management front-end for Debian-based distributions. It simplifies software retrieval, installation, upgrades, and removal. Administrative privileges are mandatory for operations that modify the system state.
apt [options] [command] [package ...]
Frequently utilized operations include updating the local package index, upgrading installed software, and managing dependencies.
sudo apt update # Synchronize package index files
sudo apt upgrade # Install available upgrades
apt list --upgradeable # Show packages with available updates
apt list --installed # Display all installed packages
sudo apt full-upgrade # Perform a full system upgrade, handling dependency changes
sudo apt install vim wget # Install multiple packages
sudo apt show nginx # Retrieve detailed package metadata
sudo apt remove vim # Uninstall a package
sudo apt autoremove # Purge orphaned dependencies
sudo apt purge wget # Remove package along with configuration files
sudo apt search text-editor # Search the repository for packages
2. dmesg
The dmesg utility reads or controls the kernel ring buffer. Boot-time messages and hardware detection logs are stored here, making it invaluable for troubleshooting kernel and driver issues.
dmesg [options]
dmesg # Print all kernel log messages
dmesg > kernel_logs.txt # Redirect logs to a file for analysis
dmesg -C # Clear the ring buffer (useful before reproducing driver bugs)
3. dpkg-deb
This tool manipulates Debian archive (.deb) files. It allows developers to extract, inspect, and build Debian packages without installing them.
dpkg-deb [option...] command
Key actions include extracting control information and unpacking the payload.
dpkg-deb -x custom-pkg_1.0_arm64.deb ./dest_dir # Extract package files to a directory
dpkg-deb -e custom-pkg_1.0_arm64.deb ./dest_dir/DEBIAN # Extract control files
dpkg-deb -c custom-pkg_1.0_arm64.deb # List contents of the archive
4. dpkg
Acting as the underlying engine for apt, dpkg installs, removes, and provides information about individual .deb packages. It operates at a lower level and does not automatically resolve dependencies.
dpkg [option...] command
dpkg -i package.deb # Install a local .deb file
dpkg -r packagename # Remove an installed package
dpkg -P packagename # Purge package along with configuration files
dpkg -L packagename # List files installed to your system from the package
dpkg -l packagename # Display package status and version
dpkg -S /usr/bin/binary # Find which package owns a specific file
dpkg -l # List all installed packages
dpkg -c package.deb # List contents of an uninstalled .deb file
dpkg --configure packagename # Perform package configuration
5. find
The find command recursively traverses a directory hierarchy based on criteria such as name, size, modification time, or permissions.
find [path...] [expression]
Expressions can combine file attributes and logical operators for complex searches.
find . -name "document.md" # Locate a specific file by name
find /var/log -name "*.log" # Find all log files
find . -iname "*.Py" # Case-insensitive name search
find . -type d # List only directories
find /home -user admin # Find files owned by admin
find . -type f -size +10M # Locate files larger than 10 Megabytes
find /tmp -mtime +7 # Files modified more than 7 days ago
find . -ctime -3 # Files with status changed in the last 3 days
find /var/log -type f -mtime +7 -exec rm {} \; # Delete old log files interactively
find . -type f -perm 755 -exec ls -l {} \; # List files with exact 755 permissions
find . \( -name "*.jpg" -o -name "*.png" \) # Search for multiple extensions
find . ! -name "*.tmp" # Exclude files ending in .tmp
find . -maxdepth 2 -name "*.conf" # Limit directory traversal depth
find . -type f -empty # Locate zero-length files
6. ifconfig
While largely superseded by the ip command, ifconfig remains widely used for configuring and querying network interface parameters like IP addresses, netmasks, and hardware addresses.
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>] ...
ifconfig # Display active interfaces
ifconfig -a # Show all interfaces, including disabled ones
ifconfig enp3s0 # Inspect a specific interface
ifconfig enp3s0 up # Enable the interface
ifconfig enp3s0 down # Disable the interface
ifconfig enp3s0 10.0.0.15 # Assign an IPv4 address
ifconfig enp3s0 10.0.0.15 netmask 255.255.255.0 # Assign IP and netmask
ifconfig enp3s0 hw ether 00:11:22:33:44:55 # Modify the MAC address
7. ip
The ip command is the modern, feature-rich replacement for ifconfig, designed to manage routing, network devices, interfaces, and tunnels.
ip [ OPTIONS ] OBJECT { COMMAND | help }
ip link show # Display all network interfaces
ip link set enp3s0 up # Bring an interface online
ip link set enp3s0 down # Take an interface offline
ip link set enp3s0 mtu 1400 # Adjust the Maximum Transmission Unit
ip addr show # List IP addresses associated with interfaces
ip addr add 10.0.0.15/24 dev enp3s0 # Add an IP address to an interface
ip addr del 10.0.0.15/24 dev enp3s0 # Remove an IP address
ip route show # Display the routing table
ip route add 192.168.50.0/24 via 10.0.0.1 # Add a static route
ip route add default via 10.0.0.1 # Set the default gateway
ip route del 192.168.50.0/24 # Delete a route
8. mount
Mount attaches a filesystem found on a device to the global file hierarchy at a specified mount point.
mount [-fnrsvw] [-t fstype] [-o options] device dir
mount /dev/sda1 /mnt/data # Attach a disk partition
mount -o ro /dev/sda1 /mnt/data # Mount as read-only
mount -o remount,rw / # Remount the root filesystem as read-write
mount -t nfs -o nolock 10.0.0.20:/export /mnt/nfs # Mount an NFS share
9. ssh
Secure Shell (ssh) establishes encrypted remote login sessions and enables command execution on distant machines.
ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-l login_name] destination [command]
ssh admin@10.0.0.20 # Connect to a remote host
ssh -p 2222 admin@10.0.0.20 # Specify a non-default port
ssh -i ~/.ssh/id_rsa admin@10.0.0.20 # Authenticate using a specific private key
ssh admin@10.0.0.20 "uname -a" # Execute a command remotely
ssh -L 8080:localhost:80 admin@10.0.0.20 # Create a local port forward
10. tar
tar archives multiple files into a single tarball, often paired with compression utilities like gzip or bzip2. It is essential for backups and software distribution.
tar [OPTION...] [FILE]...
tar -czvf project.tar.gz /home/admin/project # Create a gzip-compressed archive
tar -cjvf archive.tar.bz2 documents/ # Create a bzip2-compressed archive
tar -tzvf project.tar.gz # List contents of a gzip archive
tar -xzvf project.tar.gz # Extract a gzip archive into the current directory
tar -xzvf project.tar.gz -C /opt/target/ # Extract to a specific directory
11. top
top provides a dynamic, real-time view of running system processes, CPU utilization, and memory consumption.
top -hv | -bcEHiOSs1 -d secs -n max -u|U user -p pid(s)
Interactive commands allow process manipulation while top is running. Press 'k' to kill a process, 'M' to sort by memory usage, or 'P' to sort by CPU usage.
top # Launch the default system monitor
top -c # Display absolute command paths
top -u admin # Show processes owned by a specific user
top -p 1024,2048 # Monitor specific PIDs
top -d 2 # Set the refresh interval to 2 seconds
top -n 5 # Limit iterations before exiting
12. zip
zip compresses files into a ZIP archive, maintaining compatibility across various operating systems.
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
zip -r archive.zip /var/www/html # Recursively compress a directory
zip -r archive.zip * # Compress all items in the current directory
zip -d archive.zip unwanted.txt # Delete a file from the archive
zip -u archive.zip updated.txt # Update or add files to the archive