Category: Linux

  • lsblk

    lsblk list all block level devices available on your system.

    Example

    root@ok:~# lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0  100G  0 disk 
    ├─sda1   8:1    0   98G  0 part /
    ├─sda2   8:2    0    1K  0 part 
    └─sda5   8:5    0    2G  0 part [SWAP]
    sdb      8:16   0  700G  0 disk 
    └─sdb1   8:17   0  700G  0 part /backup
    sr0     11:0    1  655M  0 rom  
    loop0    7:0    0 36.4M  1 loop /snap/heroku/1513
    loop1    7:1    0 83.8M  1 loop /snap/core/3748
    loop2    7:2    0   16M  1 loop /snap/heroku/1527
    root@ok:~# 
    

    See fs

  • Add Server to R1Soft Server Backup Manager

    After installing r1soft backup agent, you need to add the server to R1Soft Server Backup Manager SE.

    Click on “Protected Machines” link on left side menu.

    Click on “New Machine” button.

    r1soft backup

    On this page, enter following details “Machine Name” and “Hostname / IP”. I used host name as Machine Name. Then used IP address. I don’t enable Encryption, you can enable it for added security.

    Click Save button.

    Now login to server where Backup Agent is installed (Protected Machine) and run

    serverbackup-setup --get-key http://url-of-backup-manager-server

    Example

    [root@server1 ~]# serverbackup-setup --get-key https://22536.r1softlicenses.com
    Key '22536.r1softlicenses.com' successfully installed
    [root@server1 ~]#

    Now verify key is added with command

    [root@server1 ~]# serverbackup-setup --list-keys
    Installed keys:
        22536.r1softlicenses.com
    1 keys installed
    
    [root@server1 ~]#

    Next, you need to Configure Server Backup in R1Soft Backup Manager

  • Install R1Soft Agent

    To install R1Soft Agent on CentOS, create a file

    vi /etc/yum.repos.d/r1soft.repo

    Add

    [r1soft]
    name=R1Soft Repository Server
    baseurl=http://repo.r1soft.com/yum/stable/$basearch/
    enabled=1
    gpgcheck=0

    Now you can install Agent with command

    yum install serverbackup-enterprise-agent -y

    Install module with command

    r1soft-setup --get-module

    Restart cdp-agent

    /etc/init.d/cdp-agent restart

    You can stop/start agent with command

    service cdp-agent stop
    service cdp-agent start
    service cdp-agent status

    Once installed, verify connectivity with command

    serverbackup-setup --test-connection

    See r1soft

  • Delta RPMs disabled

    When i install software on CentOS server, i get following warning

    Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

    You can install deltaparm package

    yum install deltarpm -y
    

    This will save you some bandwidth as yum will only download difference between previous package.

  • btrfs

    On Ubuntu, install it with

    apt install btrfs-tools
    

    To format a partition in btrfs, run

    root@backup:~# mkfs.btrfs -L mydisk /dev/sdc
    btrfs-progs v4.4
    See http://btrfs.wiki.kernel.org for more information.
    
    Performing full device TRIM (32.00GiB) ...
    Label:              mydisk
    UUID:               14049348-3ebd-4e4e-b932-f4a041e72e46
    Node size:          16384
    Sector size:        4096
    Filesystem size:    32.00GiB
    Block group profiles:
      Data:             single            8.00MiB
      Metadata:         DUP               1.01GiB
      System:           DUP              12.00MiB
    SSD detected:       no
    Incompat features:  extref, skinny-metadata
    Number of devices:  1
    Devices:
       ID        SIZE  PATH
        1    32.00GiB  /dev/sdc
    
    root@backup:~# parted /dev/sdc print
    Model: ATA QEMU HARDDISK (scsi)
    Disk /dev/sdc: 34.4GB
    Sector size (logical/physical): 512B/512B
    Partition Table: loop
    Disk Flags: 
    
    Number  Start  End     Size    File system  Flags
     1      0.00B  34.4GB  34.4GB  btrfs
    
    root@backup:~# 
    

    To mount, use

    mkdir /mydisk
    mount /dev/sdc /mydisk
    

    Since we don’t create any partition inside /dev/sdc, we just use sdc instead of normal sdc1.

    I tried with /dev/sdc1, but did not work.

    root@backup:~# mount /dev/sdc1 /mydisk
    mount: special device /dev/sdc1 does not exist
    root@backup:~# mount /dev/sdc /mydisk
    root@backup:~# 
    
  • zypper

    zypper

    zypper command is used for package management in OpenSUSE.

    To update your system, run

    zypper update
    

    Install a Software

    zypper install PACKAGE_NAME
    

    Example

    zypper install

    Finding Package

    To find package that provide the software need, you can use

    zypper search PACKAGE_NAME
    

    Example

    zypper search php
    

    SUSE | openSUSE

  • yast

    yast is configuration manager for openSUSE linux.

    openSUSE

  • ufw

    The Uncomplicated Firewall (ufw) is a user-friendly interface for managing netfilter, the standard firewall utility included with most Ubuntu and Debian-based Linux distributions. ufw simplifies firewall configuration by providing straightforward commands for enabling, disabling, and managing firewall rules without requiring extensive networking knowledge.

    To enable ufw to start automatically at boot:

    systemctl enable ufw

    To start or stop the firewall:

    ufw enable
    ufw disable

    To see the status, run

    ufw status
    ufw status numbered

    Open Ports

    Here are some commands to open ports.

    ufw allow ssh
    ufw allow http
    ufw allow https
    ufw allow 3333/tcp

    Following command open tcp ports 8000 to 9000.

    ufw allow 8000:9000/tcp

    Disable all other ports by default for incoming and allow all outbound traffic

    ufw default deny incoming
    ufw default allow outgoing

    Block a port, below example will block port 80

    ufw deny 80/tcp

    Whitelist an IP

    To allow an IP to access all services

    ufw allow from IP_ADDR_HERE

    To allow to specific PORT

    ufw allow from IP_ADDR_HERE proto tcp to any port PORT_HERE
    ufw allow from IP_ADDR_HERE proto udp to any port PORT_HERE

    Enable Logging

    To enable logging, run

    ufw logging on

    By default ufw logs to /var/log/kern.log.

    To log to different file, edit

    vi /etc/rsyslog.d/20-ufw.conf

    Uncomment the line

    :msg,contains,"[UFW " /var/log/ufw.log

    rstart rsyslog

    systemctl restart rsyslog

    To allow all Cloudflare IP addresses for web traffic, use the following command. This is useful if your server is behind Cloudflare’s CDN:

    for cfip in `curl -sw '\n' https://www.cloudflare.com/ips-v{4,6}`; do ufw allow proto tcp from $cfip comment 'Cloudflare IP'; done

    To list available apps, run

    ufw app list

    See firewall