显卡管理
nvidia-smi
# Display information on all available GPUs and processes using them:
nvidia-smi
# Display more detailed GPU information:
nvidia-smi --query
# Monitor overall GPU usage with 1-second update interval:
nvidia-smi dmon
小于 1 分钟
nvidia-smi
# Display information on all available GPUs and processes using them:
nvidia-smi
# Display more detailed GPU information:
nvidia-smi --query
# Monitor overall GPU usage with 1-second update interval:
nvidia-smi dmon
fdisk
# List partitions:
sudo fdisk -l
# Start the partition manipulator:
sudo fdisk /dev/sdX
# Once partitioning a disk, create a partition:
n
# Once partitioning a disk, select a partition to delete:
d
# Once partitioning a disk, view the partition table:
p
# Once partitioning a disk, write the changes made:
w
# Once partitioning a disk, discard the changes made:
q
# Once partitioning a disk, open a help menu:
m
ls
# List files one per line:
ls -1
# List all files, including hidden files:
ls -a
# List all files, with trailing `/` added to directory names:
ls -F
# Long format list (permissions, ownership, size, and modification date) of all files:
ls -la
# Long format list with size displayed using human-readable units (KiB, MiB, GiB):
ls -lh
# Long format list sorted by size (descending):
ls -lS
# Long format list of all files, sorted by modification date (oldest first):
ls -ltr
# Only list directories:
ls -d */
journalctl
journalctl
是一种用于查看Systemd系统日志的命令行工具。它可以帮助你查找特定的日志数据或浏览整个日志文件,以便审查系统活动或故障。以下是一些journalctl的常用用法:journalctl
free
# Display system memory:
free
# Display memory in Bytes/KB/MB/GB:
free -b|k|m|g
# Display memory in human-readable units:
free -h
# Refresh the output every 2 seconds:
free -s 2
ping
# Ping host:
ping host
# Ping a host only a specific number of times:
ping -c count host
# Ping host, specifying the interval in seconds between requests (default is 1 second):
ping -i seconds host
# Ping host without trying to lookup symbolic names for addresses:
ping -n host
# Ping host and ring the bell when a packet is received (if your terminal supports it):
ping -a host
# Also display a message if no response was received:
ping -O host
apt
# Update the list of available packages and versions (it's recommended to run this before other `apt` commands):
sudo apt update
# Search for a given package:
apt search package
# Show information for a package:
apt show package
# Install a package, or update it to the latest available version:
sudo apt install package
# Remove a package (using `purge` instead also removes its configuration files):
sudo apt remove package
# Upgrade all installed packages to their newest available versions:
sudo apt upgrade
# List all packages:
apt list
# List installed packages:
apt list --installed
ps
# List all running processes:
ps aux
# List all running processes including the full command string:
ps auxww
# Search for a process that matches a string:
ps aux | grep string
# List all processes of the current user in extra full format:
ps --user $(id -u) -F
# List all processes of the current user as a tree:
ps --user $(id -u) f
# Get the parent PID of a process:
ps -o ppid= -p pid
# Sort processes by memory consumption:
ps --sort size
awk
# Print the fifth column (a.k.a. field) in a space-separated file:
awk '{print $5}' path/to/file
# Print the second column of the lines containing "foo" in a space-separated file:
awk '/foo/ {print $2}' path/to/file
# Print the last column of each line in a file, using a comma (instead of space) as a field separator:
awk -F ',' '{print $NF}' path/to/file
# Sum the values in the first column of a file and print the total:
awk '{s+=$1} END {print s}' path/to/file
# Print every third line starting from the first line:
awk 'NR%3==1' path/to/file
# Print different values based on conditions:
awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' path/to/file
# Print all lines where the 10th column value equals the specified value:
awk '($10 == value)'
# Print all the lines which the 10th column value is between a min and a max:
awk '($10 >= min_value && $10 <= max_value)'
reboot
# Reboot the system:
reboot
# Power off the system (same as `poweroff`):
reboot --poweroff
# Halt the system (same as `halt`):
reboot --halt
# Reboot immediately without contacting the system manager:
reboot --force
# Write the wtmp shutdown entry without rebooting the system:
reboot --wtmp-only