Category Archives: CLI

Install Cockpit management on Ubuntu

If you want to install cockpit on your server, follow these steps:

To install cockpit on Ubuntu, run the following command:

sudo apt install cockpit

Additionally, install the following package for more detailed metrics:

sudo apt install cockpit-pcp

Now there is a bug in Ubuntu, prohibiting cockpit to update the system through the webinterface (packagekit cannot refresh cache whilst offline). This seems to have to do with differences in netplan and network manager. To overcome this, you have to create a a placeholder file and a network interface:

nano /etc/NetworkManager/conf.d/10-globally-managed-devices.conf

Add the following two lines to that file. Save the file ant quit the nano editor.

 [keyfile]
 unmanaged-devices=none

Optionally: If you run Ubuntu on an ARM system, you may need to install the following packages:

sudo apt install linux-modules-extra-raspi

Now set up a dummy network interface:

nmcli con add type dummy con-name fake ifname fake0 ip4 1.2.3.4/24 gw4 1.2.3.1

Reboot your machine. Now you should be able to update the packages in the web interface.

Cockpit should be starting automatically. If this does not happen, configure it to do so:

systemctl start cockpit
systemctl enable cockpit

Access your cockpit installion under https://my.server.IP.address:9090

Source: https://cockpit-project.org/faq.html

Auto start issues?

If you happen to see the following error when enabling cockpit:

The unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section, and DefaultInstance= for template units). This means they are not meant to be enabled using systemctl.

Than you have to edit the configuration file:

sudo nano /usr/lib/systemd/system/cockpit.service

And add the following lines at the end, save and start the service:

[Install]
WantedBy=multi-user.target
systemctl enable cockpit.service
systemctl start cockpit.service

source: https://mj57.github.io/2021/03/Installer-Cockpit/

Make new disk usable in Linux

After installing a new hard drive, you have to follow a few steps to make it usable on your Linux system. Be sure not to erase an existing file system.

  • (1) Identify the disk “fdisk -l
fdisk -l
  • (2) Partition the disk with fdisk or cfdisk
cfdisk /dev/sdX
  • (3) Create the filesystem (format the disk) on each created partition. To create an ext4 filesystem on partition /dev/sdXY run:
mkfs.ext /dev/sdXY
  • (4) Define the mount point for the newly created filesystem editing fstab:
nano /etc/fstab

Add the line for the newly created filesystem. I prefer to refer to it by UUID and not by device ID (these might change). Get the ID using this command “cd /dev/disk/by-uuid” and “ls -l”.

/dev/disk/by-uuid/3a9128c0-c9c2-47e7-b9f0-edc049ff4d3f /data ext4 defaults 0 1

source: https://superuser.com/questions/872257/how-to-make-a-new-disk-usable-on-ubuntu-linux

    Using ACL permissions in Ubuntu

    List ACL’s for a given directory

    getfacl /var/www
    # file: www
    # owner: root
    # group: root
    user::rwx
    group::r-x
    other::r-x

    You might need to install ACL (apt install acl).

    Add a group to an ACL

    Use setfacl to add a group to the ACL

    setfacl -m g:family:rwx /var/www/

    This leads your check on ACL like this:

     # file: www
     # owner: root
     # group: root
     user::rwx
     group::r-x
     group:family:rwx
     mask::rwx
     other::r-x

    Removing an ACL entry:

    setfacl -x g:family /var/www

    Granting an additional user read-write access

    setfacl -m u:jhemp:rw /var/www

    More information: https://help.ubuntu.com/community/FilePermissionsACLs

    Enable root user to login via SSH

    sudo nano /etc/ssh/sshd_config

    Uncomment the following entry in the sshd configuration file and change it to yes:

    PermitRootLogin Yes

    Restart the SSH service

    sudo systemctl restart sshd

    You have to create a password for the root user:

    sudo passwd root

    Error treatment

    Have the live system log displayed:

    tail -f /var/log/syslog
    tail -f /var/log/kern.log

    Get all error messages across log files

    journalctl -p err -f

    or

    /cat var/log/syslog |grep -iE "error|fail"
    dmesg |grep -iE "error|failed"

    Grab the system log from a remote server (and save on your desktop):

    scp root@10.X.Y.Z://var/log/syslog ~/Desktop/syslog