NOTE

Common Linux Commands

Linux commands inspect and manipulate files directly. These notes begin with text viewers such as cat and more and record common behavior and options.

Operating Systems / LinuxCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Processes

1.1. top

1.2. vmstat

1.3. ps

1.4. pstree

1.5. ulimit

1.6. pidstat

pidstat

2. Memory

2.1. free

3. Disk

3.1. df

3.2. iostat

3.3. lsof

lsof

3.4. strace

strace

3.5. chroot

chroot

3.6. Text

  • The cat command can display an entire file at once. If the file is relatively large, it is not very convenient to use.
  • The more command can pause when the screen fills. Press Space to page forward and b to page backward.
  • The less command can also display files page by page. The differences from more are:
    • It supports scrolling with the up/down keys and searching.
    • It does not need to read the entire file at the beginning, so it opens large files faster than more or vim.
  • The head command is used to view the first n lines of a file.
  • The tail command is used to view the last n lines of a file. With the -f option, it is convenient for following live logs because it prints newly appended lines.
    • tail -f grep –color -A xxx -B xxx

3.7. Copying

3.7.1. rsync

rsync

4. Networking

4.1. ifstat

4.2. netstat

4.3. ifconfig

4.4. Test Host Connectivity

  • curl tests HTTP.
curl https://www.baidu.com:443
  • telnet tests TCP.
telnet www.baidu.com 80

4.5. traceroute

traceroute

4.6. dig

dig

4.7. nslookup

nslookup

4.8. nethogs

nethogs

4.9. sar

sar

4.10. Packet Capture

5. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub