Skip to content

Instantly share code, notes, and snippets.

@estysdesu
Last active July 28, 2019 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estysdesu/9fbc57a479884c55ad677c030e13d178 to your computer and use it in GitHub Desktop.
Save estysdesu/9fbc57a479884c55ad677c030e13d178 to your computer and use it in GitHub Desktop.
[Linux: system data locations]

System Data Locations

Processes and Hardware Info

  • /proc and /sys are pseudo filesystems; they're kept in memory by the computer the whole time
  • /proc contains info abt active processes, system hardware, and kernel configuration
  • /dev is how to access hardware devices
  • /sys contains info abt the hardware devices in /dev

Viewing Running Processes

  • pstree: shows parent/child processes' relationship
  • ps: shows current processes running in the current shell
    • --forest: shows a tree view
    • aux/-ef: shows all running processes
    • -u: show process by user (ps -u root)
  • top: show live system processes feedback
    • K: terminate the process (9 == SIGKILL)
    • R: adjust priority of process (-20 to 19)
  • uptime//proc/loadavg: cpu load over past (1, 5, 15) minutes
    • load avgs are proportional to number of CPU cores --> 1.12 on a 4-core is 28% loaded

Memory

  • kernel space: kernel code is stored and executed in a "protected" range of memory addresses and remains isolated from other processes with lower privileges
  • user space: available to all users and programs and communicate with the kernel through "system call" API
  • seperating these memory address like so provides protection, giving the Linux kernel stability -- hence the saying linux is "safer"

Logging and System Messaging

  • /var/log: location of log files
  • syslog: generic meaning whichever daemon is in place
  • daemons: syslogd w/ klogd, rsyslogd, and journald/journalctl
  • binary files
    • file: describes the data type (text vs. data (binary))
    • binary files have their own tools to open: journalctl, lastb, and last

Filesystem Hierarchy Standard (FHS)

  • /: base/root (first hierarchy)

  • /bin: essential binaries

  • /boot: files necessary to boot the system, such as kernel, etc.

  • /dev: files that represent hardware devices and other special files (/dev/null or /dev/random)

  • /etc: host config files

  • /home: user home directories

  • /lib: libraries for /bin//sbin

  • /lib64: essential libraries built for a specific architecture

  • /media: automatically mounted removable media

  • /mnt: manually mounted temporary filesystems

  • /opt: optional third party software install location

  • /proc: virtual filesystem for the kernel to report process information

  • /root: home directory of the root user

  • /sbin: essential binaries for the root user

  • /sys: virtual filesystem for information about connected hardware

  • /srv: location where site-specific services may be hosted

  • /tmp: temporary files that should be cleared at boot time (accessible by all users; often isnt actually cleared)

  • /usr: non-essential files for shared user use (second hierarchy)

  • /usr/local: files for software not originating from distribution (third hierarchy) (often contains user compiled source code)

  • /var: files that change over time (fourth hierachy)

  • /var/cache: files used for caching application data (fifth hierarchy)

  • /var/log: most log files

  • /var/lock: lock files for shared resources

  • /var/spool: spool files for printing and mail

  • /var/tmp: temporary files to be preserved between boots

  • sub-hierarchies repeat the pattern of many of the key directories found under the first hierarchy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment