Files
linux/README.md
Márcio Fernandes 1fcbabd754 modified: README.md
modified:   docs/file-systems.md
2025-11-01 22:38:37 +00:00

329 lines
6.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Linux
- [Distros](#distros)
- [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)
- [Network Configuration](#network-configuration)
- [hostname / hostnamectl](#hostname--hostnamectl)
- [static ip](#static-ip)
- [System Monitoring Utilities](#system-monitoring-utilities)
- [btop](#btop)
- [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)
## Distros
- [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 the graphical login screen you see when you boot your system.
Main job: It handles user sessions — letting you log in, choose a user, select a desktop environment, and start the graphical session.
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)
#### cli - utils
check which display manager is currently running on your system.
**Debian:**
``` bash
systemctl status display-manager
```
### Graphical Applications
#### Gnome Files/Nautilus
<https://www.maketecheasier.com/useful-nautlius-tweaks-linux/>
## 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 8GB 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
```
### 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 Monitoring Utilities
#### btop
**Install Debian & Ubuntu:**
```bash
apt update && apt install btop -y
```
### 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. Its 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).
Heres a deeper look at what smartctl does and why its 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
```