Skip to content

General

Linux

Permissions

Shared Libraries

  • update libraries and still support programs that want to use older, non-backward-compatible versions of those libraries;
  • override specific libraries or even specific functions in a library when executing a particular program.
  • do all this while programs are running using existing libraries.

LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories

Systemd

systemctl

To enable a service to start automatically at boot, type:

$ sudo systemctl enable nginx.service

To disable the service type:

$ sudo systemctl disable nginx.service

systemctl list-units: list all active unit files systemctl list-units --all: list all unit files active & inactive (that were attempted to load into memory) systemctl list-unit-files: list all unit files on the system

journalctl: log entries (related to systemd) journalctl -b: entries of current boot

systemctl status nginx.service: current state of unit journalctl -u nginx.service: all logs related to unit journalctl -b -u nginx.service: logs related to unit from current boot

Filesystems

ZFS

ZFS - silent corruption detection and automatic data repair - dynamic striping across all devices to maximize throughput - Copy-on-write design makes most disk writes sequential

zpool

consists of 1 or more vdevs

vdev

group of hard disks, partitions, or files

vdev’s must have redudancy, if one vdev is lost, the whole zpool is lost

vdev will have the same base capacity as the smallest drive in the group

data compression via variable block sizes can be enabled, the downside of variable block sizes is increased CPU usage (for compression and decompression operations)

recommendations range between 1 and 5 GB of RAM for every TB of storage

4TB x (3) = 12 GiB RAM

shutdown

Shutdown computer after 60 minutes.

sudo shutdown -P +60

This will also broadcast to all terminals to warn about the shutdown.

You can cancel a shutdown with

sudo shutdown -c

Suspend System

via https://askubuntu.com/a/96450

If you want your computer to suspend in one hour because you want to go to bed listening to your favorite radio station, open terminal and type:

sudo bash -c "sleep 1h; pm-suspend"

and your computer will fall asleep in 1 hour. When you awake, it will have kept your open images and all your stuff.

You can replace 1h by what you want: h for hours, m for minutes, s for seconds, d for days.

Streams

streams are referred to by numbers, called file descriptors (FDs) 0 = stdin 1 = stdout 2 = stderr

This sends “OK?” to FILE and “Oops!” to ERRORFILE

printf '%s\n%v\n' OK? Oops! > FILE 2> ERRORFILE

redirected to another I/O stream by using >&N where N is the number of the file descriptor.

printf '%s\n%v\n' OK? Oops! > FILE 2>&1 ERRORFILE

Job control

Close shell without stopping running jobs

Ctrl-Z: stop (pause) program bg: run program/job in background disown -h [job-spec] where [job-spec] is a job number i.e. %1 jobs -l List running jobs

System Monitoring

Disk Space

df -h

Hard drives

tom@computer:~$ lsblk -io KNAME,TYPE,SIZE,MODEL
KNAME TYPE   SIZE MODEL
sda   disk 223.6G SanDisk SDSSDHII
sda1  part   243M 
sda2  part     1K 
sda5  part 223.3G 
dm-0  lvm  207.4G 
dm-1  lvm     16G 
sdb   disk   2.7T ST3000DM001-9YN1
sdb1  part   2.7T 

Cron

Security

How to remove unused kernels

Out of space in /boot

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

via http://askubuntu.com/a/90219/22568