modified: README.md

This commit is contained in:
2024-06-26 11:36:07 +01:00
parent c1686b9d25
commit 10df64ff02

138
README.md
View File

@@ -1,11 +1,15 @@
# Linux
## Table of contents
<!-- TOC --> <!-- TOC -->
- [hostname/hostnamectl](#hostnamehostnamectl) - [Linux](#linux)
- [Table of contents](#table-of-contents)
- [Update](#update) - [Update](#update)
- [Debian / Ubuntu](#debian--ubuntu) - [Debian / Ubuntu](#debian--ubuntu)
- [Fedora](#fedora) - [Fedora](#fedora)
- [ls](#ls) - [ls](#ls)
- [Users](#users) - [Users](#users)
- [hostame](#hostame) - [hostname / hostnamectl](#hostname--hostnamectl)
- [static ip](#static-ip) - [static ip](#static-ip)
- [Disks](#disks) - [Disks](#disks)
- [mount](#mount) - [mount](#mount)
@@ -24,34 +28,25 @@
- [Create key](#create-key) - [Create key](#create-key)
- [Copy public key](#copy-public-key) - [Copy public key](#copy-public-key)
- [Add existing Key](#add-existing-key) - [Add existing Key](#add-existing-key)
- [alias](#alias) - [Alias](#alias)
- [Port Binding](#port-binding)
- [Documentation](#documentation)
- [Benchmarking](#benchmarking) - [Benchmarking](#benchmarking)
- [themes](#themes) - [themes](#themes)
- [shell](#shell) - [shell](#shell)
- [terminal](#terminal) - [terminal](#terminal)
- [Backups](#backups) - [Backups](#backups)
- [bash](#bash) - [bash](#bash)
- [disable touh screen](#disable-touh-screen) - [disable touch screen](#disable-touch-screen)
- [disable suspend blackscreen](#disable-suspend-blackscreen) - [disable suspend black screen](#disable-suspend-black-screen)
- [lightdm auto login](#lightdm-auto-login) - [lightdm auto login](#lightdm-auto-login)
- [btop](#btop) - [btop](#btop)
- [Setup](#setup) - [Setup](#setup)
- [Debian & Ubuntu](#debian--ubuntu) - [Debian \& Ubuntu](#debian--ubuntu-1)
- [lspci](#lspci) - [lspci](#lspci)
- [gnome files / nautilus](#gnome-files--nautilus) - [gnome files / nautilus](#gnome-files--nautilus)
<!-- /TOC --> <!-- /TOC -->
# Linux
## hostname/hostnamectl
```bash
#get hostname
hostname
#set hostname
hostnamectl
```
## Update ## Update
@@ -115,9 +110,16 @@ chown [-c|--changes] [-v|--verbose] [-f|--silent|--quiet] [--dereference]
{new-owner|--reference=ref-file} file ... {new-owner|--reference=ref-file} file ...
``` ```
## hostame ## hostname / hostnamectl
``` bash
#get hostname
hostname
#set hostname
hostnamectl
```
sudo nano /etc/hostname sudo nano /etc/hostname
#alterar o nome #alterar o nome
sudo nano /etc/hosts sudo nano /etc/hosts
@@ -132,7 +134,7 @@ Debian
sudo nano /etc/network/interfaces sudo nano /etc/network/interfaces
Exemplo de configuração Exemplo de configuração
``` ``` bash
# neste exemplo de configuração a place de rede tem o nome enxd0374555c1f8 # neste exemplo de configuração a place de rede tem o nome enxd0374555c1f8
# This file describes the network interfaces available on your system # This file describes the network interfaces available on your system
@@ -155,7 +157,7 @@ iface enxd0374555c1f8 inet static
Reiniciar configuração sem reboot de computador Reiniciar configuração sem reboot de computador
``` ```
``` ``` bash
Reiniciar configuração sem reboot de computador Reiniciar configuração sem reboot de computador
#sudo /etc/init.d/networking restart #sudo /etc/init.d/networking restart
``` ```
@@ -164,25 +166,25 @@ Reiniciar configuração sem reboot de computador
File System & Space Usage File System & Space Usage
``` ``` bash
df -h df -h
``` ```
List physical disks and partition size List physical disks and partition size
``` ``` bash
lsblk lsblk
``` ```
List partition ids List partition ids
``` ``` bash
blkid /dev/sdc1 blkid /dev/sdc1
``` ```
Partition Manager Partition Manager
``` ``` bash
fdisk /dev/<DISK NAME> fdisk /dev/<DISK NAME>
#Example: #Example:
fdisk /dev/sdc fdisk /dev/sdc
@@ -201,22 +203,22 @@ mkpart primary ext4 0 4
## mount ## mount
Mount partion on boot fstab Mount partition on boot fstab
``` ``` bash
nano /etc/fstabexemplo de alias nano /etc/fstabexemplo de alias
``` ```
ext4 example ext4 example
``` ``` bash
#add line #add line
PARTUUID=<PARTUUID GIVEN blksid> <FOLDER WHERE TO MOUNT> ext4 defaults,nofail 0 02 PARTUUID=<PARTUUID GIVEN blksid> <FOLDER WHERE TO MOUNT> ext4 defaults,nofail 0 02
``` ```
Mount fstab partions without reboot Mount fstab partions without reboot
``` ``` bash
mount -a mount -a
``` ```
@@ -224,7 +226,7 @@ smb share
Create credentials file Create credentials file
``` ``` bash
#/home/mf/.credentials/smb:mf@nas.lan #/home/mf/.credentials/smb:mf@nas.lan
username=shareuser username=shareuser
password=sharepassword password=sharepassword
@@ -233,13 +235,13 @@ domain=domain_or_workgroupname
Secure credentials file permission Secure credentials file permission
``` ``` bash
chmod 0600 /home/mf/.credentials/smb:mf@nas.lan chmod 0600 /home/mf/.credentials/smb:mf@nas.lan
``` ```
Add line Add line
``` ``` bash
#/etc/fstab #/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 //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
``` ```
@@ -280,7 +282,7 @@ mkfs.ext3 _filesys_
Example Example
``` ``` bash
mkfs.ext3 /dev/sdb1 mkfs.ext3 /dev/sdb1
#exFat #exFat
mkfs.exfat /dev/sdc1 mkfs.exfat /dev/sdc1
@@ -291,13 +293,13 @@ mkfs.exfat /dev/sdc1
mkfs.exfat _filesys_ mkfs.exfat _filesys_
``` ``` bash
mkfs.exfat /dev/sdc1 mkfs.exfat /dev/sdc1
``` ```
### ntfs ### ntfs
``` ``` bash
apt-get install ntfs-3g apt-get install ntfs-3g
mkntfs --fast --label Backups /dev/sdc1 mkntfs --fast --label Backups /dev/sdc1
``` ```
@@ -314,7 +316,7 @@ du -h --max-depth=1
Bad Sectors Bad Sectors
sudo e2fsck -cfpv /dev/sda1 sudo e2fsck -cfpv /dev/sda1
O Exemplo foi com o disco sda1 mas deverá ser subsituido pelo disco desejado O Exemplo foi com o disco sda1 mas deverá ser substituído pelo disco desejado
Os parâmetros têm os seguintes significados: Os parâmetros têm os seguintes significados:
@@ -355,7 +357,8 @@ ssh-keygen -t ecdsa -b 521 -f ~/.ssh/key-ecdsa
### Copy public key ### Copy public key
```bashssh-add ~/.ssh/id_ed25519 ```bash
ssh-add ~/.ssh/id_ed25519
ssh-copy-id -i ~/.ssh//ey-ecdsa.pub example_user@192.0.2.4 ssh-copy-id -i ~/.ssh//ey-ecdsa.pub example_user@192.0.2.4
``` ```
@@ -365,7 +368,7 @@ ssh-copy-id -i ~/.ssh//ey-ecdsa.pub example_user@192.0.2.4
ssh-add ~/.ssh/key-ecdsa ssh-add ~/.ssh/key-ecdsa
``` ```
### alias ### Alias
```bash ```bash
Host srv01 Host srv01
@@ -375,6 +378,56 @@ Host srv01
RequestTTY yes RequestTTY yes
``` ```
### Port Binding
Bind local port 8001 to target-server port 80 using jump-machine.local.
_(local machine without direct access to target-server)_
```bash
ssh -f -N -L localhost:8001:target-server:80 usr@jump-machine.local
```
#### Documentation
``` bash
# man
-f Requests ssh to go to background just before command
execution. This is useful if ssh is going to ask for
passwords or passphrases, but the user wants it in the
background. This implies -n. The recommended way to
start X11 programs at a remote site is with something
like ssh -f host xterm.
-N Do not execute a remote command. This is useful for just
forwarding ports. Refer to the description of
SessionType in ssh_config(5) for details.
-L [bind_address:]port:host:hostport
-L [bind_address:]port:remote_socket
-L local_socket:host:hostport
-L local_socket:remote_socket
Specifies that connections to the given TCP port or Unix socket on the
local (client) host are to be forwarded to the given host and port, or
Unix socket, on the remote side. This works by allocating a socket to
listen to either a TCP port on the local side, optionally bound to the
specified bind_address, or to a Unix socket. Whenever a connection is
made to the local port or socket, the connection is forwarded over the
secure channel, and a connection is made to either host port hostport,
or the Unix socket remote_socket, from the remote machine.
Port forwardings can also be specified in the configuration file. Only
the superuser can forward privileged ports. IPv6 addresses can be
specified by enclosing the address in square brackets.
By default, the local port is bound in accordance with the GatewayPorts
setting. However, an explicit bind_address may be used to bind the
connection to a specific address. The bind_address of “localhost”
indicates that the listening port be bound for local use only, while an
empty address or * indicates that the port should be available from
all interfaces.
```
## Benchmarking ## Benchmarking
@@ -384,7 +437,7 @@ sudo hdparm -Tt /dev/sdc
## themes ## themes
- https://github.com/EliverLara/Nordic - <https://github.com/EliverLara/Nordic>
### shell ### shell
@@ -462,7 +515,7 @@ find $BACKUP_DIR/* -mtime +10 -exec rm {} \;
gio mount -u ftp://ftp.backups@backupsrv01.dev.lan gio mount -u ftp://ftp.backups@backupsrv01.dev.lan
``` ```
## disable touh screen ## disable touch screen
``` bash ``` bash
sudo apt-get -y install xinput sudo apt-get -y install xinput
@@ -485,6 +538,7 @@ Source: https://askubuntu.com/questions/759335/how-to-disable-a-touchscreen-on-s
[Seat:*] [Seat:*]
xserver-command=X -s 0 dpms xserver-command=X -s 0 dpms
``` ```
## lightdm auto login ## lightdm auto login
```bash ```bash
@@ -512,16 +566,14 @@ Displays information about each PCI bus on your system. This includes informatio
lspci [options] lspci [options]
| Option | Description | | Option | Description |
| -------- | ------------- | | -------- | ------------- |
| -v | Verbose | | -v | Verbose |
``` bash ``` bash
lspci -v lspci -v
``` ```
## gnome files / nautilus ## gnome files / nautilus
https://www.maketecheasier.com/useful-nautlius-tweaks-linux/ <https://www.maketecheasier.com/useful-nautlius-tweaks-linux/>