/proc/meminfo
rita@rita-localhost:~$ cat /proc/meminfo
MemTotal: 7071452 kB
MemFree: 4655216 kB
MemAvailable: 5373196 kB
Buffers: 74844 kB
Cached: 874236 kB
SwapCached: 0 kB
Active: 1591648 kB
Inactive: 516584 kB
Active(anon): 1160800 kB
Inactive(anon): 39156 kB
Active(file): 430848 kB
Inactive(file): 477428 kB
Unevictable: 32 kB
Mlocked: 32 kB
SwapTotal: 1555964 kB
SwapFree: 1555964 kB
Dirty: 444 kB
Writeback: 0 kB
AnonPages: 1159220 kB
Mapped: 399064 kB
Shmem: 40808 kB
Slab: 106308 kB
SReclaimable: 58056 kB
SUnreclaim: 48252 kB
KernelStack: 12384 kB
PageTables: 47620 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 5091688 kB
Committed_AS: 5826664 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 316036 kB
DirectMap2M: 3813376 kB
DirectMap1G: 4194304 kB
ps -aux | sort -k3nr | head -1
rita@rita-localhost:~$ ps -aux | sort -k3nr | head -1
rita 1859 22.8 4.0 2165836 283696 tty2 Sl+ 15:43 5:59 /usr/lib/firefox/firefox -new-window
ps命令:
sort命令:
head命令:
查看 /etc/profile的前10行内容应该是:# head -n 10 /etc/profile
查看/etc/profile的最后50行内容应该是:# tail -n 50 /etc/profile
rita@rita-localhost:~$ head -n 10 /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
rita@rita-localhost:~$ tail -n 50 /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
JAVA_HOME=/usr/java/jdk1.8.0_201
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
head命令与tail命令详解
grep "ERROR" file_name
cat file_name | grep "ERROR"
netstat -anp | grep port_number
rita@rita-localhost:~$ netstat -anp | grep 3471
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
unix 3 [ ] 流 已连接 214485 3471/zeitgeist-daem
unix 3 [ ] 流 已连接 214484 3471/zeitgeist-daem
unix 3 [ ] 流 已连接 214483 3471/zeitgeist-daem
netstat命令:
grep命令:
ps -ef | grep ps_name
ps -ef | grep ps_number
rita@rita-localhost:~$ ps -ef | grep colord
colord 1541 1 0 10:13 ? 00:00:00 /usr/lib/colord/colord
rita 6026 4035 0 11:16 pts/0 00:00:00 grep --color=auto colord
rita@rita-localhost:~$ ps -ef | grep 1541
colord 1541 1 0 10:13 ? 00:00:00 /usr/lib/colord/colord
rita 6047 4035 0 11:16 pts/0 00:00:00 grep --color=auto 1541
ps命令:
ifconfig
rita@rita-localhost:~$ ifconfig
enp2s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 84:7b:eb:0d:18:c2 txqueuelen 1000 (以太网)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 3671 bytes 355575 (355.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3671 bytes 355575 (355.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.97.3.150 netmask 255.255.224.0 broadcast 10.97.31.255
inet6 fe80::1394:f933:f409:f613 prefixlen 64 scopeid 0x20<link>
inet6 2001:da8:4002:2738:fc1d:795e:d466:fed2 prefixlen 64 scopeid 0x0<global>
inet6 2001:da8:4002:2738:f707:b130:3ad7:5f8f prefixlen 64 scopeid 0x0<global>
ether 44:1c:a8:26:73:09 txqueuelen 1000 (以太网)
RX packets 282168 bytes 89237671 (89.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 42099 bytes 5633804 (5.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
mkdir -p ./a/b
rm -rf ./a
mkdir命令:
rm命令:
find ./ -name haha.txt
rita@rita-localhost:~$ find ./ -name 123.txt
./practice/test1/123.txt
find命令:
ps -ef | grep tomcat
kill -9 tomcat_port
ps top kill
kill命令:
tail -f log_file
tail命令:
df -aTh
rita@rita-localhost:~$ df -aTh
文件系统 类型 容量 已用 可用 已用% 挂载点
sysfs sysfs 0 0 0 - /sys
proc proc 0 0 0 - /proc
udev devtmpfs 3.4G 0 3.4G 0% /dev
devpts devpts 0 0 0 - /dev/pts
tmpfs tmpfs 691M 1.9M 689M 1% /run
/dev/sdb10 ext4 32G 9.3G 21G 32% /
securityfs securityfs 0 0 0 - /sys/kernel/security
tmpfs tmpfs 3.4G 60M 3.4G 2% /dev/shm
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 3.4G 0 3.4G 0% /sys/fs/cgroup
cgroup cgroup2 0 0 0 - /sys/fs/cgroup/unified
cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore pstore 0 0 0 - /sys/fs/pstore
cgroup cgroup 0 0 0 - /sys/fs/cgroup/perf_event
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct
cgroup cgroup 0 0 0 - /sys/fs/cgroup/devices
cgroup cgroup 0 0 0 - /sys/fs/cgroup/blkio
cgroup cgroup 0 0 0 - /sys/fs/cgroup/pids
cgroup cgroup 0 0 0 - /sys/fs/cgroup/hugetlb
cgroup cgroup 0 0 0 - /sys/fs/cgroup/freezer
cgroup cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio
cgroup cgroup 0 0 0 - /sys/fs/cgroup/memory
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpuset
cgroup cgroup 0 0 0 - /sys/fs/cgroup/rdma
systemd-1 autofs 0 0 0 - /proc/sys/fs/binfmt_misc
mqueue mqueue 0 0 0 - /dev/mqueue
debugfs debugfs 0 0 0 - /sys/kernel/debug
hugetlbfs hugetlbfs 0 0 0 - /dev/hugepages
configfs configfs 0 0 0 - /sys/kernel/config
fusectl fusectl 0 0 0 - /sys/fs/fuse/connections
/dev/loop0 squashfs 15M 15M 0 100% /snap/gnome-logs/37
/dev/loop1 squashfs 35M 35M 0 100% /snap/gtk-common-themes/1122
/dev/loop2 squashfs 4.2M 4.2M 0 100% /snap/gnome-calculator/406
tracefs - - - - - /sys/kernel/debug/tracing
/dev/loop3 squashfs 15M 15M 0 100% /snap/gnome-logs/45
/dev/loop7 squashfs 35M 35M 0 100% /snap/gtk-common-themes/818
/dev/loop8 squashfs 141M 141M 0 100% /snap/gnome-3-26-1604/74
/dev/loop13 squashfs 2.3M 2.3M 0 100% /snap/gnome-calculator/260
/dev/loop9 squashfs 3.8M 3.8M 0 100% /snap/gnome-system-monitor/57
/dev/loop10 squashfs 13M 13M 0 100% /snap/gnome-characters/103
/dev/loop12 squashfs 90M 90M 0 100% /snap/core/6673
/dev/loop19 squashfs 3.8M 3.8M 0 100% /snap/gnome-system-monitor/51
/dev/loop11 squashfs 2.4M 2.4M 0 100% /snap/gnome-calculator/180
/dev/loop4 squashfs 15M 15M 0 100% /snap/gnome-characters/254
/dev/loop14 squashfs 3.8M 3.8M 0 100% /snap/gnome-system-monitor/77
/dev/loop15 squashfs 54M 54M 0 100% /snap/core18/941
/dev/loop5 squashfs 1.0M 1.0M 0 100% /snap/gnome-logs/61
/dev/loop16 squashfs 91M 91M 0 100% /snap/core/6350
/dev/loop17 squashfs 91M 91M 0 100% /snap/core/6405
/dev/loop6 squashfs 36M 36M 0 100% /snap/gtk-common-themes/1198
/dev/loop18 squashfs 141M 141M 0 100% /snap/gnome-3-26-1604/78
/dev/loop20 squashfs 141M 141M 0 100% /snap/gnome-3-26-1604/82
/dev/loop21 squashfs 13M 13M 0 100% /snap/gnome-characters/139
tmpfs tmpfs 691M 20K 691M 1% /run/user/121
tmpfs tmpfs 691M 52K 691M 1% /run/user/1000
gvfsd-fuse fuse.gvfsd-fuse 0 0 0 - /run/user/1000/gvfs
df命令:
netstat -tlnp
rita@rita-localhost:~$ netstat -tlnp
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
激活Internet连接 (仅服务器)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
netstat命令:
压缩:tar zcvf xxx.tar.gz file
解压:tar zxvf xxx.tar.gz
tar命令:
lrzsz
cat /etc/passwd | head -n 5 | cut -d : -f 1
rita@rita-localhost:~$ cat /etc/passwd | head -n 5 | cut -d : -f 1
root
daemon
bin
sys
sync
cat命令:
如有错误,请指正!