How to use Kali Linux, on termux to perform system administration tasks like managing files, running cron jobs.



 System administration tasks on a mobile device using Kali Linux and Termux can be a highly effective way to manage a Linux environment when you're on the go. Kali Linux, being a Debian-based distribution, comes with a wide array of tools that you can use for system administration tasks, all of which are available to be run directly from Termux, a terminal emulator for Android.

In this guide, I will explain how to perform system administration tasks such as managing files, running cron jobs, and installing software packages within Termux on Kali Linux. This guide will cover step-by-step instructions to help you master these tasks.


1. Getting Started with Kali Linux in Termux

Before we dive into system administration tasks, it’s important to set up Kali Linux properly in Termux. Here's how you can do it:

1.1. Installing Termux

To use Kali Linux within Termux, you need to first install Termux from the Google Play Store or an alternative source if it is unavailable in your region.

  1. Go to the Google Play Store and search for Termux.
  2. Install it, and once the installation is complete, open the app.

1.2. Installing Kali Linux in Termux

Once you have Termux installed, follow these steps to install Kali Linux:

  1. Update Termux Packages: Before installing Kali, make sure that your Termux environment is updated.

    pkg update && pkg upgrade -y
    
  2. Install Required Packages: You need to install wget and proot for the Kali Linux installation to proceed smoothly.

    pkg install wget proot tar -y
    
  3. Download and Install Kali Linux: Use the following command to download and set up Kali Linux in your Termux environment:

    wget https://raw.githubusercontent.com/EXALAB/AnLinux-Resources/master/Scripts/kali/kali.sh
    chmod +x kali.sh
    ./kali.sh
    

    This script downloads and installs the Kali Linux environment.

  4. Launch Kali Linux: Once the installation is complete, you can start Kali Linux by using the following command:

    ./startkali.sh
    

2. Managing Files on Kali Linux in Termux

File management is a core part of system administration. Kali Linux on Termux allows you to manage your files through standard Linux commands. You can perform basic file operations, such as listing, moving, copying, and deleting files.

2.1. Listing Files

The ls command is used to list files and directories.

  • To list files in the current directory:
    ls
    
  • To list files with detailed information, including file permissions and sizes:
    ls -l
    

2.2. Moving and Renaming Files

To move or rename files, you can use the mv command.

  • To move a file to another directory:
    mv filename /path/to/destination/
    
  • To rename a file:
    mv oldname newname
    

2.3. Copying Files

To copy files, use the cp command.

  • To copy a file to another directory:
    cp filename /path/to/destination/
    
  • To copy a directory and its contents recursively:
    cp -r sourcedir /path/to/destination/
    

2.4. Deleting Files

To remove files, use the rm command. Be careful when using this command because it permanently deletes files without asking for confirmation.

  • To remove a single file:
    rm filename
    
  • To remove a directory and all of its contents:
    rm -r directory
    

2.5. Creating Files and Directories

To create new files and directories, you can use the touch and mkdir commands, respectively.

  • To create an empty file:
    touch filename
    
  • To create a directory:
    mkdir new_directory
    

2.6. Editing Files

For editing files in Kali Linux within Termux, you can use text editors like nano or vim.

  • To open a file in nano:

    nano filename
    
  • To open a file in vim:

    vim filename
    

3. Installing and Managing Software Packages

One of the essential aspects of system administration is installing, updating, and removing software packages. Kali Linux uses the APT (Advanced Package Tool) to manage packages.

3.1. Installing Software Packages

You can install software packages from the Kali repository using the apt command.

  • To install a package:
    sudo apt install package_name
    

For example, to install the nmap tool:

sudo apt install nmap

3.2. Updating Software Packages

It’s important to keep your system updated. The APT package manager makes it easy to update all installed packages.

  • To update the package list from the repositories:

    sudo apt update
    
  • To upgrade all installed packages:

    sudo apt upgrade
    
  • To perform a complete system upgrade, which includes removing obsolete packages:

    sudo apt full-upgrade
    

3.3. Removing Software Packages

If you need to uninstall a package, you can use the apt remove command.

  • To remove a package:

    sudo apt remove package_name
    
  • To completely remove a package and its configuration files:

    sudo apt purge package_name
    
  • To remove unused packages and free up space:

    sudo apt autoremove
    

3.4. Searching for Packages

If you want to search for available packages, you can use the apt search command.

  • To search for a specific package:
    apt search package_name
    

4. Running Cron Jobs

Cron is a time-based job scheduler in Unix-like operating systems. You can use cron jobs to automate system administration tasks like backups, file management, and periodic maintenance.

4.1. Checking if Cron is Installed

Before you begin, you need to ensure that cron is installed in your Kali Linux environment.

  • To check if cron is installed:
    crontab -l
    

If cron is not installed, you can install it using:

sudo apt install cron

4.2. Starting the Cron Service

Once installed, you need to start the cron service.

  • To start cron:
    sudo service cron start
    

4.3. Setting Up a Cron Job

Cron jobs are set up by editing the crontab file. Each user on a Linux system has their own crontab file, and you can schedule tasks to run at specific intervals.

  • To edit your crontab:
    crontab -e
    

In the crontab file, the format for scheduling tasks is:

* * * * * /path/to/command

Each asterisk represents a time field, and they represent the following:

  • The first asterisk is for the minute (0-59).
  • The second is for the hour (0-23).
  • The third is for the day of the month (1-31).
  • The fourth is for the month (1-12).
  • The fifth is for the day of the week (0-7, where both 0 and 7 represent Sunday).

For example, to run a command at 3 AM every day:

0 3 * * * /path/to/command

4.4. Checking Cron Logs

To verify if your cron jobs are running correctly, you can check the cron logs:

grep CRON /var/log/syslog

5. Monitoring System Resources

A key part of system administration is monitoring the resources on your system. In Kali Linux, you can use several commands to monitor CPU, memory, disk usage, and more.

5.1. Checking CPU Usage

The top command provides a dynamic real-time view of the system's resource usage, including CPU usage.

  • To start top:
    top
    

5.2. Checking Memory Usage

To see memory usage, you can use the free command:

free -h

This shows the total, used, free, and available memory.

5.3. Checking Disk Usage

To see disk space usage, you can use the df command:

df -h

For more detailed file system usage, use du:

du -sh /path/to/directory

Conclusion

System administration in Kali Linux on Termux provides a powerful and flexible environment for managing a Linux system directly from your Android device. By mastering tasks like file management, package installation, cron jobs, and system resource monitoring, you can efficiently manage and administer your system on the go. While the mobile interface may not be as intuitive as a full desktop environment, Termux, combined with Kali Linux, offers a wide range of powerful tools for experienced users to perform administrative tasks, and with the commands and techniques shared in this guide, you’re well on your way to becoming proficient in system administration with Termux.

Post a Comment

Cookie Consent
Zupitek's serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.