前言
记录一些常用的Linux(主要是ubuntu)命令,免得一直上网查。
远程上传下载 1 2 3 4 5 6 scp [-P port] [-i pbulickey] [-r] <LocalFilePath> username@ipaddress:<RemoteFilePath>
系统信息 1 2 3 4 5 6 7 8 9 10 11 12 $ uname -a $ cat /proc/cpuinfo $ cat /proc/meminfo $ getconf LONG_BIT $ hostname $ lspci -tv $ lsusb -tv $ lsmod $ env $ lsb_release -a $ cat /etc/issue $ dmidecode
cat /proc/cpuinfo的一些查找命令
1 2 3 4 $ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c $ cat /proc/cpuinfo | grep physical | uniq -c
系统资源 1 2 3 4 5 6 7 $ free -m $ df -h $ du -sh <目录名> $ grep MemTotal /proc/meminfo $ grep MemFree /proc/meminfo $ uptime $ cat /proc/loadavg
磁盘相关 1 2 3 4 $ mount | column -t $ fdisk -l $ swapon -s $ hdparm -i /dev/hda
df和fdisk遇到过显示磁盘大小不一致的情况:参考资料 ,下面是在一台VPS上的处理过程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 $ df -h Filesystem Size Used Avail Use% Mounted on udev 105M 0 105M 0% /dev tmpfs 23M 2.6M 21M 12% /run /dev/vda1 1.9G 1.3G 400M 68% / tmpfs 115M 0 115M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 115M 0 115M 0% /sys/fs/cgroup tmpfs 23M 0 23M 0% /run/user/0 $ fdisk -l Disk /dev/vda: 10 GiB, 10737418240 bytes, 20971520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type : dos Disk identifier: 0xc8d5eddc Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 20444799 20442752 9.8G 83 Linux /dev/vda2 20444800 20969087 524288 256M 82 Linux swap / Solaris $ resize2fs /dev/vda1 $ df -h Filesystem Size Used Avail Use% Mounted on udev 105M 0 105M 0% /dev tmpfs 23M 2.6M 21M 12% /run /dev/vda1 9.6G 1.3G 7.9G 15% / tmpfs 115M 0 115M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 115M 0 115M 0% /sys/fs/cgroup tmpfs 23M 0 23M 0% /run/user/0
网络相关 1 2 3 4 5 6 7 $ ip a $ ifconfig $ iptables -L $ route -n $ netstat -lntp $ netstat -antp $ netstat -s
看进程
看用户 1 2 3 4 5 $ w $ id <用户名> $ last $ cut -d: -f1 /etc/passwd $ cut -d: -f1 /etc/group