Ubuntu server commands

 lsb_release -r

 lsb_release -c

 lsb_release -c -d -di


Changing Server name

sudo hostnamectl set-hostname your-server-name

Install Essential Packages

Install common tools and utilities:

sh
sudo apt install build-essential curl wget vim git

To check the hostname of an Ubuntu server using the command line, you can use either of the following commands:

  1. Using the hostname command:

    sh
    hostname
  2. Using the hostnamectl command:

    sh
    hostnamectl
  3. Using the uname command with the -n option:

    sh
    uname -n

Any of these commands will display the current hostname of your Ubuntu server.

12. Time Synchronization

Ensure your server's time is accurate:

sh
sudo apt install ntp sudo systemctl enable ntp sudo systemctl start ntp

Uname
  • To display the kernel name:

    bash
    uname -s
  • To display the kernel release:

    bash
    uname -r
  • To display the machine hardware architecture:

    bash
    uname -m
  • To display all information:

    bash
    uname -a 

  • 10. Automate Backups
  • Use tools like rsync or deja-dup for backups.
  • Rsync Example

    sh
    sudo apt install rsync

    Create a backup script (e.g., backup.sh):

    sh
    #!/bin/bash rsync -av --delete /source/directory /backup/directory

    Make the script executable:

    sh
    chmod +x backup.sh

    Schedule it using cron:

    sh
    crontab -e

    Add a cron job:

    plaintext
    0 2 * * * /path/to/backup.sh

Comments