Renato Ivancic - Software Engineer

Background image

Linux hints

Backend

Linux

List Processes

ps (processes status) is a native Unix/Linux utility for viewing information concerning a selection of running processes on a system

Command for listing all of the processes in a user friendly tree hierarchy.

ps auxf
a = show processes for all users
u = outputs using the "user-oriented" format, which gives more columns, including the user id and CPU/memory usage.
x = also show processes not attached to a terminal
f = ASCII art process hierarchy (forest).

Version

cat /etc/os-release

File Content

Number of lines in file

wc -l <filename>

Disk Size

DU

The du command is very useful to track down disk space hogs. It is useful to find out the names of directories and files that consume large amounts of space on a disk.

Find top files in the current and subdirectories

find -type f -exec du -Sh {} + | sort -rh | head -n 5

Display tree directory with the estimated sizes

tree --du -h

DF

Shows the amount of disk space used and available on Linux file systems.

df -H

Remote Copy

TO

scp {local_directory/file} {username}@{host}:{remote_directory}

FROM

scp {username}@{host}:{remote_directory}/{file} {local_directory}

GZIP

gzip {file}
gunzip {zipped_file}

Distributions

Alpine

Alpine Linux

Alpine Linux is an independent, non-commercial, general purpose Linux distribution designed for power users who appreciate security, simplicity and resource efficiency. It is built around musl libc and busybox. A container requires no more than 8 MB and a minimal installation to disk requires around 130 MB of storage.

Install software

Alpine uses its own package management system, apk-tools, which originally was a collection of shell scripts but was later rewritten in C. Alpine currently contains most commonly used packages such as GNOME, Xfce, Firefox, and others.

apk add

In case of an error

bash-4.4# apk add postgresql-client
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  postgresql-client (missing):
    required by: world[postgresql-client]

run with –update-cache command

apk add --update-cache command

Sources:

30 Useful ‘ps Command’ Examples for Linux Process Monitoring

TecMint - How to Find Out Top Directories and Files (Disk Space) in Linux

nixCraft - Linux Check Disc Space

#Linux