Intermediate Linux

Elementary by Linux systems administrators

Intermediate Linux

#Prerequisite knowledge

  • Listing files (`ls` )

  • Removing files (`rm`)

  • Navigating directories (`cd`)

  • Listing file contents (`cat` and optionally head, tail, less, more)

  • Ability to use one or more standard editors (`vi`, vim, emacs, nano)

  • Relative and absolute paths

#Filesystem Hierarchy Standard (FHS)

The FHS describes the conventional layout of a Linux system. Although there are some variations among different Linux distributions (distros), they tend to be pretty minor and mostly related to the/lib,/bin,/usr/lib, and/usr/bindirectories.

Filesystem Hierarchy Standard (FHS)

  • /home: contains user home directories

  • /bin and /usr/bin: traditionally contain essential and non-essential command binaries, respectively, but these are often merged. For example, on CentOS Linux /bin is a symbolic link to /usr/bin

  • /sbin and /usr/sbin: contain binaries for commands needed mostly by sys admins. Like /bin and /usr/bin, these are often merged

  • /lib and /usr/lib: contain libraries needed by the Linux commands (often merged)

  • /opt: is where software was traditionally installed, but with the rising popularity of package managers like Spack, this directory is not used much anymore

Additional Directories

  • /etc: contains configuration files for Linux shells, schedulers, networking, accounts, package managers, and others

  • /root: home directory for the root user

  • /var: log files

  • /dev: device files for terminals, disks, networking, etc.

  • /proc and /sys: are pseudofile systems (we’ll talk about this later) that contain information about running processes and hardware

  • /tmp: stores temporary files

Resources for FHS

These links give a way to refer to a file or an inode (data structure for file) by a different name. It is useful if you want to avoid writing out a full/relative path name every time.

Inode: stores information about a filesystem object. It contains information like Persmissions, File size, Ownership, Timestamps, Locaation of data (but not the actual data)

$ ln -s file1 soft-file1

A symbolic link is another name for the file. If the original file is deleted or moved, the symbolic link still exists, but can no longer be used to access the data.

$ ln file2 hard-file2

A file is a link to an inode, and a hard link is just another file that links to the same inode. An inode is only deleted when all the links to it have been deleted. If the original file is deleted, the data can still be accessed using the hard link.

Example

$ ls
file1 file2

$ ln file1 file1-hard 
$ ln -s file2 file2-soft 

$ ls -i1 # -i option lists inode 
157076717 file1 
157076717 file1-hard 
157076716 file2 
157076768 file2-soft@ 

$ rm file1 file2 
$ cat file1-hard 
Contents of file1 

$ cat file2-soft

Symbolic links since they let you span file systems and can be created even if the file being linked to doesn't exist.

Source

  • The COMPLECS Team San Diego Supercomputer Center event