01 Linux Basics and SUSE Linux Enterprise Server (SLES)


  • .

Introduction to Linux and SUSE Distribution

Linux is a free and open-source operating system, developed based on a Unix-like design. As a result, Linux shares many characteristics with Unix, such as being lightweight, relatively secure, stable, and portable.

Unlike Windows or Mac, Linux can run without a graphical user interface (GUI) or desktop, meaning it doesn't require high system resources. This makes Linux widely used in server devices and IoT due to its efficient performance.

To operate Linux on a server, you can use a text-based interface or TUI (Text-based User Interface) by running specific commands. In this journal article, we aim to introduce some basic Linux commands that you need to understand to operate your Linux server optimally.

List of Basic Linux Commands

These are commands to view the contents of a directory or folder. Type ls to view the contents of a folder, and ls -al to view the contents of a folder along with hidden files inside it.

  • sudo
    A command to execute commands that require administrator privileges for non-root users.

  • pwd
    A command to view the current folder location. For example, if you are in the home folder and type the pwd command, the output will be /home/user.

  • cd
    A command to move to a specific location. For example, if you want to move to /home/user/public_html, the command is as follows:

    cd /home/user/public_html
  • cp
    A command to copy a file from one location to another. For example, if you want to copy file1.php from /home/user/public_html/ to /home/user/public_html/subdomain, the command is as follows:

    cp /home/user/public_html/file1.php /home/user/public_html/subdomain
  • cp -rf
    A command to copy a folder along with all its contents from one location to another. For example, if you want to copy folder1 from /home/user/public_html to /home/user/public_html/subdomain, the command is as follows:

    cp -rf /home/user/public_html/folder1 /home/user/public_html/subdomain
  • mv
    A command to move a file or folder from one location to another. For example, if you want to move file1.php from /home/user/public_html to /home/user/public_html/subdomain, the command is as follows:

    mv /home/user/public_html/file1.php /home/user/public_html/subdomain

Additionally, mv can also be used to rename a file or folder. For example, if you want to rename file1.php to file2.php, the command is as follows:

```bash
mv file1.php file2.php
```
  • rm
    A command to delete a file. This command will permanently delete the file, so you must ensure the file name is correct. For example, if you want to delete file1.php, the command is as follows:

    rm file1.php
  • rm -rf
    A command to delete a folder along with all its contents. This command will permanently delete the folder, so you must ensure the folder name is correct. For example, if you want to delete folder1 and its contents, the command is as follows:

    rm -rf folder1
  • find
    A command to search for a file or folder in a specific location. For example, if you want to search for file1.php inside /home/user, the command is as follows:

    find /home/user -name file1.php
  • grep

    The grep command is used to search for a specific string or text within a file or to find files containing specific text.

    • Example 1: If you want to search for files containing the word "apple" inside /home/user, the command is as follows::

      grep "apple" -r /home/user
    • Example 2: If you want to find lines containing the word "apple" in file1.php, the command is as follows:

      grep "apple" file1.php
  • cat
    A command to view the entire contents of a file. For example, if you want to view the contents of file1.php, the command is as follows:

    cat file1.php
  • tail
    A command to view the last few lines of a file. For example, if you want to view the last 5 lines of file1.php, the command is as follows:

    tail -n 5 file1.php
  • head
    A command to view the first few lines of a file. For example, if you want to view the first 5 lines of file1.php, the command is as follows:

    head -n file1.php
  • touch
    A command to create a new file. For example, if you want to create a new file named file2.php, the command is as follows:

    touch file2.php
  • mkdir
    A command to create a folder. For example, if you want to create a folder named folder1, the command is as follows:

    mkdir folder1
  • df
    A command to view information about active storage partitions in your system. The output of the df command includes Filesystem, Size, Used, Avail, Use%, and Mounted on. The main partition of your Linux system will be displayed as / under Mounted on.

  • du -h
    A command to view the size of a file or folder in KB, MB, and GB. For example, if you want to view the size of the folder /home/user, the command is as follows:

    du -h /home/user
  • chmod
    A command to change the permissions of a file or folder.

    • Example 1, If you want to change the permissions of file1.php to 644, the command is as follows:

      chmod 0644 file1.php
    • Example 2, If you want to change the permissions of folder1 to 755, the command is as follows:

      chmod -Rf 0755 folder1
  • chown
    A command to change the owner of a file or folder. For example, if you want to change the owner of folder1 to www-data, the command is as follows:

    chown -Rf www-data:www-data folder1
  • echo
    A command to add text to a file. For example, if you want to add the text "apple and pineapple" to file1.php, the command is as follows:

    echo apple and pineapple >> file1.php
  • ln
    A command to create a symbolic link (shortcut) from one file or folder to another location as a shortcut. To create a symbolic link, the command is as follows:

    ln -s /source_location/original_file /destination_location/shortcut

    Example: If you want to create a symbolic link /home/user/public_html/file2.php linked to the original file /home/user/public_html/file1.php, the command is as follows:

    ln -s /home/user/public_html/file1.php /home/user/public_html/file2.php
  • wget

    A command to download a file from a specific URL. For example, if you want to download the latest WordPress installer, the command is as follows:

    wget URL/filename
    wget https://wordpress.org/latest.zip
  • curl
    A command to check the connectivity of a URL. For example, if you want to check file1.php that has been uploaded to public_html of domainname.com, the command is as follows:

    curl domainname.com/file1.php
  • ping

    A command to check the connection status of a server. For example, if you want to check the connection status of dommainname.com, the command is as follows:

    ping domainname.com

    If domainname.com is online, the response will show time=xxx ms. If domainname.com is offline, the response will show "request timed out" or "destination host unreachable."

  • dig
    A command to check the IP address information of a domain. For example, if you want to check the IP address information of domainname.com, the command is as follows:

    dig domainname.com
  • whois

    A command to check the whois information of a domain. For example, if you want to check the information of domainname.com, the command is as follows:

    whois domainname.com
  • traceroute

    A command to trace the network route to access a specific domain or IP address. This command is typically used to identify problematic routes when there are issues accessing or contacting a specific server.

    To run traceroute, the command is as follows:

    traceroute IP-Address
    traceroute domainname.com
  • tar
    A command to extract or compress archive files in tar.gz or tar.bz2 format. For example, if you want to extract file1.tar.gz or file1.tar.bz2, the command is as follows:

    tar -xvf file1.tar.gz
    tar -xvf file1.tar.bz2
  • unzip
    A command to extract archive files in .zip format. For example, if you want to extract file1.zip, the command is as follows:

    unzip file1.zip
  • nano
    A command to edit text using the nano editor. For example, if you want to edit file1.php, the command is as follows:

    nano file1.php

    To save changes, press Ctrl+X together, type Y, and press Enter.

  • apt
    A command to install, remove, and update packages on Ubuntu and Debian Linux.

    • Example 1, To update the software database and upgrade the system, the command is as follows:

      apt update
      apt dist-upgrade
    • Example 2, To install a package, the command is as follows:

      apt install packagename
      apt install apache2 (Installing the apache2 package)
    • Example 3, To remove a package, the command is as follows:

      apt remove namapaket
      apt remove apache2 (Removing the apache2 package)
  • dnf
    A command to install, remove, and update packages on AlmaLinux, Rocky Linux, and RHEL.

    • Example 1, To update the system, run the following command:

      dnf update
    • Example 2, To install a package, run the following command:

      dnf install namapaket
      dnf install httpd (Installing the apache package)
    • Example 3, To remove a package, run the following command:

      dnf remove packagename
      dnf remove httpd (Removing the apache package)
  • zypper
    A command to install, remove, and update the system on OpenSUSE Linux.

    • Example 1: To update the system, run the following command:

      zypper refresh
      zypper dup
    • Example 2: To install a package, run the following command:

      zypper install packagename
      zypper install httpd (Installing the apache package)
    • Example 3: To remove a package, run the following command:

      zypper remove packagename
      zypper remove httpd (Removing the apache package)
  • systemctl
    A command commonly used to start, stop, and restart a service on a server. The command format is as follows:

    systemctl start/stop/restart nama-service
    • Example 1, To start the Apache service, run the following command:

      systemctl start httpd
    • Example 2, To stop the Apache service, run the following command:

      systemctl stop httpd
    • Example 3, To restart the Apache service, run the following command:

      systemctl restart httpd
  • ps -ax
    A command to view all processes running on the server. Its function is similar to the Task Manager in Windows. The output of ps -ax includes PID, TTY, STAT, TIME, and COMMAND.

  • Kill

    A command to forcefully stop a running process on the server. The command to stop a process with kill is as follows:

    kill -9 PID
  • reboot
    A command to restart the entire system. This process is typically run after making certain changes that require a system restart. If your server is running MySQL, it is recommended to stop the MySQL service before running the reboot command:

    systemctl stop mysql
  • iptables
    A command to configure the firewall in Linux, such as opening and closing ports.

    • Example 1, To open port 443, run the following command:

      iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT
    • Example 2, To close port 443, run the following command:

      iptables -I INPUT -p tcp -m tcp --dport 443 -j REJECT
  • free -m
    A command to check the current memory (RAM) usage in MB. After running free -m, the output will include: total (total RAM), used (RAM in use), and available (unused RAM).

  • Hostname
    A command to check the hostname of your server.

  • History
    A command to display a list of previously executed commands. This command is useful if you have run a long command that is difficult to remember or if you want to avoid typing it again.

  • Screen
    A command that allows you to run a command in the background. This is useful when running processes that take a long time, so you don't need to monitor them continuously. Commands run through screen will continue running even if the computer used for SSH connection is turned off.

    Screen is not installed by default on Ubuntu or AlmaLinux. You must install it first using the following command:

    apt install screen (on Ubuntu/Debian)
    dnf install screen (on AlmaLinux)
  • Scp
    A command to upload or transfer files from one server to another running Linux. For example, if you want to transfer file1.tar.gz to another Linux server into the /home folder, the command is as follows:

    scp -P port file user@IP-address:/location
    scp -P 22 file1.tar.gz root@xxx.xxx.xxx.xxx:/home
  • Ifconfig
    A command to configure the network on your server or to view active network information. Running this command will display network information, including IP Address, MAC Address, and more.

  • Date
    A command to view the current date in your system.

  • Clear
    A command to clear the shell/Terminal display. Alternatively, you can press Ctrl+L simultaneously.

  • Exit
    A command to exit the SSH session to your server. Alternatively, you can press Ctrl+Dsimultaneously.

SUSE Linux

SUSE is a Linux-based operating system that provides server and desktop solutions for enterprise-level customers. It is one of the oldest and largest open-source software companies, offering a range of products including SUSE Linux Enterprise Server, SUSE Linux Enterprise Desktop, and SUSE Manager. SUSE provides enterprise-level support, training, and consulting services to its customers.

Main Functions of SUSE

SUSE is a Linux-based operating system that provides various solutions for enterprise-level customers. Its purpose is to provide a stable and secure platform for running server and desktop applications. SUSE Linux Enterprise Server is designed to run critical workloads, while SUSE Linux Enterprise Desktop is designed for end-user desktop computing. The operating system also provides various management tools, including SUSE Manager, to help administrators manage and maintain their systems. Overall, SUSE aims to meet the needs of enterprise-level customers by offering reliable, secure, and flexible computing solutions.

Kegunaan SUSE

The best use of SUSE depends on the specific needs and requirements of an organization. SUSE Linux Enterprise Server is designed to run critical workloads, making it suitable for use as a server operating system in various applications, including database servers, web servers, and file servers.

The best use of SUSE depends on an organization's specific needs and requirements, offering a range of flexible and scalable solutions to meet diverse computing demands.

Benefits of SUSE

There are several benefits of using SUSE, including:

  1. Stability and Reliability: SUSE is designed for enterprise use, providing a stable and reliable platform for running essential workloads.

  2. Security: SUSE is built with security in mind and offers various security features, such as integrated firewall protection, to help ensure system and data security.

  3. Scalability: SUSE provides various cloud computing solutions, including SUSE OpenStack Cloud and SUSE CaaS Platform, enabling organizations to build and manage scalable and flexible cloud infrastructure.

  4. Interoperability: SUSE offers solutions for diverse environments, allowing organizations to run Linux, Windows, and other operating systems on the same network.

  5. Support and Maintenance: SUSE provides a range of support and maintenance services, including long-term support for enterprise-level solutions and expert support for specialized solutions.

  6. Cost Savings: SUSE provides an open-source alternative to proprietary operating systems, helping organizations reduce software licensing costs and improve return on investment for their technology infrastructure.

SUSE Linux Enterprise Server (SLES)

SUSE Linux Enterprise Server (SLES) is a Linux distribution designed to meet enterprise needs by providing stability, security, and high performance. SLES is suitable for various scenarios, such as servers, cloud infrastructure, and critical applications.

Fitur Utama SLES

  1. Security Stability :
    • Fast security patches.
    • Certified for enterprise applications like SAP HANA and Oracle.
  2. High Availability (HA):
    • Fast security patches.
    • Certified for enterprise applications like SAP HANA and Oracle.
  3. Virtualization :
    • Supports hypervisors such as KVM, Xen, and VMware.
    • Supports containerization with Docker and Kubernetes.
  4. Management and Automation :
    • Uses SUSE Manager to manage multiple servers simultaneously.
    • Simplifies patching, configuration, and monitoring.
  5. Cloud Compatibility: :
    • Uses SUSE Manager to manage multiple servers simultaneously.
    • Simplifies patching, configuration, and monitoring.

Key Components of SLES

  1. YaST(Yet Another Setup Tool):
    • The main tool for system configuration.
    • Used to manage disk partitions, networking, firewalls, services, and software updates.
  2. Zypper:
    • The built-in package manager for installing, updating, and removing software.
  3. Snapper:
    • Used to create and manage system snapshots.
    • Simplifies rollback after configuration changes or system updates.
  4. Btrfs:
    • The default file system with snapshot and self-healing features.
  5. SUSE Manager :
    • A management tool for large-scale server administration.

Kegunaan SLES

  1. Running Enterprise Applications:
    • Database: SAP HANA, Oracle, MySQL.
    • Application server: Apache, Nginx.
  2. Virtualization Infrastructure:
    • Hosting Virtual Machines (VMs).
    • Supports multi-cloud and hybrid cloud systems.
  3. High-Performance Computing (HPC) Clusters:
    • Used for workloads requiring high computing capacity.
  4. DevOps and Development:
    • Integration with containers and CI/CD tools.

Installation and Configuration of SUSE Linux Enterprise Server (SLES)

  1. Installing SLES:
    • Download the ISO from SUSE's official website.
    • Create a bootable USB or DVD.
    • Follow the installation guide using YaST.
  2. Basic Configuration:
    • Set up networking, hostname, and time zone.
    • Add software repositories.
  3. System Management Introduction:
    • Learn basic Linux commands.
    • Use YaST for advanced configuration.
  4. Practice and Experimentation:
    • Try snapshots with Snapper.
    • Manage packages with Zypper.

User and Group Management in Linux

User and group management is a crucial aspect of Linux system administration. Linux allows administrators to create and manage users and groups to control system resource access.

User Management

  1. Adding a User

    • To add a new user, use the useradd command:

      sudo useradd username
    • To set a password for the user:

      sudo passwd username
  2. Deleting User

    • To delete a user:

      sudo userdel username
    • To also remove the user’s home directory, use the -r option:

      sudo userdel -r username
  3. Modifying User Information To modify user details (such as full name, shell, etc.):

    sudo usermod -c "Full Name" username

Group Management

  1. Adding a Group To create a new group:

    sudo groupadd group_name
  2. Adding a User to a Group To add a user to a group:

    sudo usermod -aG group_name username
  3. Deleting a Group
    To delete a group:

    sudo groupdel group_name

Software Management with Zypper and RPM

Software management involves installing, updating, removing, and handling applications or libraries within the operating system. In Linux environments, tools like Zypper and RPM efficiently manage software.

  • RPM (Red Hat Package Manager): A package format and tool for managing software on RPM-based distributions (e.g., Red Hat, Fedora, openSUSE).

  • Zypper: A command-line tool for package management in openSUSE and SUSE Linux Enterprise, based on the RPM system.

Software Management with RPM

  • Installing a Package Use the following command to install an RPM package:

    sudo rpm -ivh package_name.rpm
  • Updating a Package To update an installed package:

    sudo rpm -Uvh package_name.rpm
  • Removing a Package To remove a package:

    sudo rpm -e nama_paket
  • Viewing Installed Packages To list installed packages:

    rpm -qa
  • Viewing Package Information To view details about a specific package:

    rpm -qi nama_paket

Software Management with Zypper

  • Adding a Repository:

    sudo zypper ar REPOSITORY_URL repository_name
  • Refreshing Repositories:

    sudo zypper refresh
  • Installing a Package:

    sudo zypper install package_name
  • Removing a Package:

    sudo zypper remove package_name
  • Updating the System:

    sudo zypper update
  • Searching for a Package:

    zypper search package_name

Linux File Structure and File System

Linux Directory Structure

Linux has a well-organized directory structure. Some essential directories include:

  • / (Root)\*\*: The primary directory, acting as the starting point of the entire file system.

  • /bin: Contains essential executable files used for the basic system.

  • /etc: Stores system configuration files.

  • /home: Stores user data.

  • /var: Holds frequently changing data such as logs and spools.

  • /tmp: Stores temporary files used by applications.

  • /dev: Contains device files for hardware.

  • /proc: Provides information about running processes and the kernel.

  • /usr: Contains user-based applications and files.

Linux File Permissions and Basic Security

The Linux file system is a way to organize and store data. Some common file systems used in Linux include:

  • ext4: The default file system for many Linux distributions.

  • XFS: A file system designed for high performance.

  • Btrfs: A file system that supports advanced features such as snapshots and compression.

  • NTFS: A file system used by Windows, accessible in Linux with additional packages.

File Permissions and Basic Security in Linux

File Permissions in Linux

Linux uses an Access Control Model based on File Permissions to regulate who can access files and directories. Each file or directory has three types of permissions:

  • Read (r)**: Allows reading the file contents.
  • Write (w)**: Allows modifying or deleting the file.
  • Execute (x)**: Allows executing the file as a program.
  1. Viewing File Permissions To check file permissions, use the ls -l command:

    ls -l file_name

    Example output:

    rwxr-xr-- 1 user group 1234 Jan 8 12:00 file_name

    Explanation:

    • rwxr-xr--\*\*: File permissions.
    • rwx: The owner has read, write, and execute permissions.
    • r-x: The group has read and execute permissions.
    • r--: Others only have read permission.
    • 1: Number of hard links.
    • user: File owner.
    • group: Group that owns the file.
    • 1234: File size.
    • Jan 8 12:00: Last modified time.
  2. Changing File Permissions To modify file permissions, use the chmod command:

    chmod 755 file_name

    Explanation :

    • 7: The owner has read (4), write (2), and execute (1) permissions, totaling 7.
    • 5: The group has read (4) and execute (1) permissions, totaling 5.
    • 5 : Others have read (4) and execute (1) permissions, totaling 5.
  3. Changing File Owner and Group To change the file owner and group, use the chown command:

    sudo chown owner:group file_name

Basic Security in Linux

File and system security in Linux is crucial. Here are some basic steps to maintain security:

  1. Using Sudo To execute commands with administrator privileges, use sudo:

    sudo perintah
  2. Menggunakan Firewall Linux provides firewall tools like iptables or firewalld to control network traffic. Example commands to enable the firewall with firewalld:

    sudo systemctl start firewalld
    sudo systemctl enable firewalld
  3. System Updates Ensure the system is always up-to-date to receive the latest security patches:

    sudo apt update && sudo apt upgrade