# Linux
- [Distro](#distro)
- [Graphical Environment](#graphical-environment)
- [Display Managers](#display-managers)
- [cli - utils](#cli---utils)
- [Graphical Applications](#graphical-applications)
- [Gnome Files/Nautilus](#gnome-filesnautilus)
- [Commands and Utilities](#commands-and-utilities)
- [Navigation and File Management](#navigation-and-file-management)
- [Archiving and Compression](#archiving-and-compression)
- [tar](#tar)
- [Users, Groups, and File permissions](#users-groups-and-file-permissions)
- [loginctl](#loginctl)
- [terminate-user](#terminate-user)
- [Network Configuration](#network-configuration)
- [hostname / hostnamectl](#hostname--hostnamectl)
- [static ip](#static-ip)
- [System info](#system-info)
- [System Monitoring Utilities](#system-monitoring-utilities)
- [btop](#btop)
- [memory usage by user](#memory-usage-by-user)
- [Storage](#storage)
- [Disk Space and Used](#disk-space-and-used)
- [Physical Disks and Partition](#physical-disks-and-partition)
- [hdparm](#hdparm)
- [smartctl](#smartctl)
- [Network Storage](#network-storage)
- [smb](#smb)
- [gio](#gio)
- [CLI Diagnostics and System Topology](#cli-diagnostics-and-system-topology)
- [lspci](#lspci)
## Distro
- [Debian](./docs/distros/debian.md)
- [Fedora](./docs/distros/fedora.md)
- [Proxmox pve](https://git.limbosolutions.com/kb/proxmox)
## Graphical Environment
### Display Managers
A display manager is a graphical login manager that:
- starts the Xorg or Wayland display server
- shows a login screen (greeter)
- authenticates the user
- launches the user’s session (desktop environment or window manager)
Examples:
- [LightDM (lightweight and flexible)](./docs/display-managers/lightdm.md)
- [GDM (GNOME Display Manager)](./docs/desktop-environments/gnome.md)
- [SDDM](./docs/display-managers/sddm.md) - Used by [KDE](./docs/desktop-environments/kde.md)
- LXDM (used by LXDE)
- [matchbox-window-manager](./docs/display-managers/matchbox‑wm.md)
#### cli - utils
check which display manager is currently running on your system.
**Debian:**
``` bash
systemctl status display-manager
```
### Graphical Applications
#### Gnome Files/Nautilus
## Commands and Utilities
### Navigation and File Management
📁 List information about the FILEs (the current directory by default).
```bash
#order by date
ls -t
#order by date reverse
ls -r
# list all
ls -lah
```
### Archiving and Compression
#### tar
**📦 tar** is a command-line utility in Unix/Linux used to archive multiple files into a single file, often for backup, compression, or distribution. The name stands for “tape archive”, originally designed for writing data to magnetic tape.
**Flags:**
- -c Create a new archive
- -v Verbose — show progress while archiving
- -p Preserve permissions — keeps original file permissions
- -z Compress using gzip
- -f File name — expects a filename right after this flag
- -I compressor
- -p preserve file permissions
```bash
tar -cvf --exclude='.cache' --exclude='Cache' --exclude='.cache' --exclude='.tmp' --exclude='tmp' /tmp/filename.tar.gz \
$source_path_to_tar
#(Parallel Implementation of Gzip) to to create a fast, compressed archive
tar -I pigz -cvf - /fileserver/media/music/*
# splits the output into 8 GB chunks,
tar -I pigz -cvf - /sourcefolder/* | split --bytes=8GB - /tmp/file.tar.gz
```## Visual Linux
```bash
tar -cvpzf "/vault/.backups/devices/homeserver/tar/backup_$(date +"%Y%m%d%H%M%S").tar.gz \
--exclude=/proc \
--exclude=/tmp \
--exclude=/mnt \
--exclude=/dev \
--exclude=/sys \
--exclude=/run \
--exclude=/media \
--one-file-system \
/
```
### Users, Groups, and File permissions
```bash
#create
useradd USERNAME
# create with home directory
useradd -m USERNAME
#remove
userdel USERNAME
#useradd -r USERNAME
passwd
passwd USERNAME
groups
groupadd GROUPNAME
groups USERNAME
usermod -a -G GROUPNAME USERNAME
```
### loginctl
*command belongs to systemd‑logind.*
#### terminate-user
terminate-user Terminates all processes and sessions belonging to the specified user. This works on any system using systemd — including headless servers with no graphical environment. On headless systems, it closes SSH/TTY sessions and kills all user‑owned processes. On graphical systems, it also terminates Xorg/Wayland sessions and window managers.
``` bash
loginctl terminate-user
```
### Network Configuration
#### hostname / hostnamectl
``` bash
#get hostname
hostname
#set hostname
hostnamectl
sudo nano /etc/hostname
#alterar o nome
sudo nano /etc/hosts
#alterar o nome
Static IP
A configuração para um ip estático poderá ser um pouco diferente de distribuição para distribuição mas a lógica é similar
```
#### static ip
Debian
sudo nano /etc/network/interfaces
Exemplo de configuração
``` bash
# neste exemplo de configuração a place de rede tem o nome enxd0374555c1f8
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug enxd0374555c1f8
iface enxd0374555c1f8 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 89.207.128.252 89.207.130.252
Reiniciar configuração sem reboot de computador
```
``` bash
# restart configuration servicce
sudo /etc/init.d/networking restart
```
### System info
```bash
# get distribution
cat /etc/os-release
# get kernel version
uname -a
```
### System Monitoring Utilities
#### btop
**Install Debian & Ubuntu:**
```bash
apt update && apt install btop -y
```
#### memory usage by user
``` bash
ps -eo user,rss --no-headers \
| awk '{mem[$1]+=$2} END {for (u in mem) printf "%-15s %.1f MB\n", u, mem[u]/1024}'
```
### Storage
#### Disk Space and Used
``` bash
df -h
```
#### Physical Disks and Partition
**List physical disks and partition size:**
``` bash
lsblk
```
**Get Partition id:**
``` bash
blkid /dev/sdX
```
##### Partition Manager
``` bash
fdisk /dev/sdX
```
[check](./docs/file-systems.md) for file systems.
#### hdparm
hdparm is a powerful command-line utility in Linux used to view and configure low-level parameters of SATA, IDE, and some USB hard drives. It’s commonly used for performance tuning, diagnostics, and power management.
``` bash
sudo apt install hdparm
sudo hdparm -Tt /dev/sdc
```
#### smartctl
smartctl is a command-line utility used to monitor and manage the health of storage devices like HDDs and SSDs using S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology).
Here’s a deeper look at what smartctl does and why it’s useful:
```bash
#check smart status
smartctl -a /dev/sdX
```
``` bash
df
df -h
du -h --max-depth=1
```
### Network Storage
#### smb
smb share
Create credentials file
``` bash
#/home/mf/.credentials/smb:mf@nas.lan
username=shareuser
password=sharepassword
domain=domain_or_workgroupname
```
Secure credentials file permission
``` bash
chmod 0600 /home/mf/.credentials/smb:mf@nas.lan
```
Add line
``` bash
#/etc/fstab
//nas.lan/homes /mnt/smb-share:mf@nas.lan,share=homes cifs credentials=/home/mf/.credentials/smb:mf@nas.lan,uid=1000,gid=1000,nofail 0 0
```
#### gio
**mount samba share:**
```bash
#/home/username/.credentials
#username
#SAMBA
#password
gio mount smb://server/share < /home/username/.credentials
```
**unmount:**
```bash
gio mount -u smb://server/share
```
### CLI Diagnostics and System Topology
#### lspci
Displays information about each PCI bus on your system. This includes information about the devices connected to the PCI subsystem.
lspci [options]
| Option | Description |
| -------- | ------------- |
| -v | Verbose |
``` bash
lspci -v
```