Operating System - Knowledge Base Archives - Hivelocity Hosting https://www.hivelocity.net/kb/category/operating-system/ Dedicated Servers, Private Cloud & Colocation Mon, 21 Oct 2024 16:32:40 +0000 en-US hourly 1 https://wordpress.org/?v=6.6 Text Editors in Linux and How to Use Them https://www.hivelocity.net/kb/text-editors-in-linux-and-how-to-use-them/ Fri, 18 Oct 2024 14:07:45 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=35251 Text editors are essential for anyone working in a Linux environment, whether you’re a system administrator, developer, or enthusiast. They allow you to quickly create, modify, and manage files from the terminal or through graphical interfaces. Linux offers a variety of editors, from lightweight command-line options like nano and vim to more feature-rich graphical editors …

Text Editors in Linux and How to Use Them Read More »

The post Text Editors in Linux and How to Use Them appeared first on Hivelocity Hosting.

]]>
Text editors are essential for anyone working in a Linux environment, whether you’re a system administrator, developer, or enthusiast. They allow you to quickly create, modify, and manage files from the terminal or through graphical interfaces. Linux offers a variety of editors, from lightweight command-line options like nano and vim to more feature-rich graphical editors like VS Code and Sublime Text. In this article, we will explore some of the most popular text editors in Linux, highlighting their unique features and providing practical usage guides. Whether you need a simple tool for quick edits or a powerful editor for complex programming, you’ll find the right fit here. We will specifically focus on vim and nano, offering detailed instructions for each

Popular Text Editors in Linux

There are quite a few options for text editors for Linux. The most popular ones are listed below for reference while this article will focus on Vim and Nano.

  • Vim: A highly configurable and powerful text editor that is an improved version of the original Vi. It offers advanced features like syntax highlighting, code folding, and a robust plugin system.

  • Nano: A user-friendly, lightweight text editor that is easy to use, making it a great choice for beginners. It provides simple commands displayed at the bottom of the interface, making navigation intuitive.

  • Emacs: A highly extensible and customizable text editor known for its powerful editing capabilities. It supports a wide range of programming languages and comes with built-in tools for version control, debugging, and more.

Vim

Vim serves as a powerful command-line text editor designed for efficient text manipulation and navigation. Its modal editing system enables users to perform tasks quickly using keyboard shortcuts. Although it has a steep learning curve, Vim offers extensive features like syntax highlighting and customizable macros, making it ideal for coding and advanced editing. Whether you are a beginner or an experienced developer, Vim equips you with the tools you need for a streamlined editing experience.

Vim Installation

Vim could be provided with your distro but might also require manual installation. Proceed with the commands below to install based on the distribution you’re using.

  • Debian/Ubuntu
    • sudo apt update
    • sudo apt install vim
  • Fedora
    • sudo dnf install vim
  • CentOS/RHEL
    • sudo yum install vim
  • Arch Linux
    • sudo pacman -S vim
  • openSUSE
    • sudo zypper install vim

Operating with Vim

  1. Once installed proceed to open the software by typing vim filename.txt. The command will create filename.txt in your current working directory and open vim to edit it. Alternatively, you can type vim /path/to/filename.txt to create the file in a specific path.
  2. Vim works in two modes, Normal mode and Insert mode. Normal mode works for reviewing while insert works for adding text to it and making changes. Proceed to press “i” on your keyboard to enter insert mode. 
    1. At this point, the bottom left of the editor will have “–INSERT–” displayed.
  3. Proceed to enter text as needed.

    Vim Text Editor
    Vim Text Editor
  4. Once done, proceed to press the “Esc” key on your keyboard to exit the Insert mode and enter Normal mode.
  5. Type :w to save the file. To save and quit type :wq!. To quit without saving changes type :q!.
  6. The content of the file can be reviewed within the editor or by using the cat command.

    Text File Output Confirmation
    Text File Output Confirmation

Additional Vim Operations

Within Normal mode there are other basic functions which can help make changes.

  • Deleting a line can be done with dd once you’re on the line you wish to remove.  
  • Undoing a change can be done with u.
  • Redoing a change can be done with Ctrl+r.
  • Searching can be done with a forward slash / and then search term so for example /search_term to search forward.
    • Searching backwards is done as such ?search_term.
    • Navigating the results is done with n to go to the next occurrence of the search term or N to go to the previous one.

GNU nano

GNU Nano is a lightweight, user-friendly command-line text editor that simplifies file editing for everyone. Its straightforward interface displays helpful commands at the bottom, guiding you through the process. With features like syntax highlighting and search functionality, Nano is perfect for quick edits and simple coding tasks, ensuring a smooth editing experience.

Nano Installation

Nano could be provided with your distro but might also require manual installation. Proceed with the commands below to install based on the distribution you’re using.

  • Debian/Ubuntu
    • sudo apt update
    • sudo apt install nano
  • Fedora
    • sudo dnf install nano
  • CentOS/RHEL
    • sudo yum install nano
  • Arch Linux
    • sudo pacman -S nano
  • openSUSE
    • sudo zypper install nano

Operating with Nano

  1. Once installed proceed to open the software by typing nano filename.txt. The command will create filename.txt in your current working directory and open nano to edit it. Alternatively, you can type nano /path/to/filename.txt to create the file in a specific path.
  2. Nano is more straightforward than Vim as it allows to write text immediately upon opening it.

    Nano Text Editor
    Nano Text Editor
  3. Once you wish to save the file, proceed to press Ctrl+O to save it. You will see a prompt that says “File Name to Write: filename2.txt.” In this case, I am saving the file in the current working directory as filename2.txt. Press “Enter” to confirm.
  4. To exit the editor press Ctrl+X.
  5. The content of the file can be reviewed within the editor or by using the cat command.

    Nano Text File Output
    Nano Text File Output

Additional Nano Operations

Nano provides the ability to perform other tasks such as the items below.

  • Searching for text can be done with Ctrl+W followed by typing the search term and pressing “Enter”.
  • Undoing changes can be done with Ctrl+Z.
  • Cutting a line is done with Ctrl+K and pasting it with Ctrl+U
  • For further help check with Ctrl+G to open the manual.

Further Assistance

For any further assistance involving text editing in Linux, do not hesitate to reach out to the Hivelocity Support team via a chat, support ticket, or phone at 888-869-4678. 

The post Text Editors in Linux and How to Use Them appeared first on Hivelocity Hosting.

]]>
Creating Bootable Flash Drives (USB) in Windows and MacOS https://www.hivelocity.net/kb/creating-bootable-flash-drives-usb-in-windows-and-macos/ Fri, 18 Oct 2024 14:06:50 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=35217 Creating bootable flash drives is a crucial skill for anyone who wants to install operating systems, run diagnostic tools, or troubleshoot computer issues. Whether you use Windows or Mac, knowing how to make a bootable USB drive can save you time and effort in critical situations. In this article, we will walk you through the …

Creating Bootable Flash Drives (USB) in Windows and MacOS Read More »

The post Creating Bootable Flash Drives (USB) in Windows and MacOS appeared first on Hivelocity Hosting.

]]>
Creating bootable flash drives is a crucial skill for anyone who wants to install operating systems, run diagnostic tools, or troubleshoot computer issues. Whether you use Windows or Mac, knowing how to make a bootable USB drive can save you time and effort in critical situations. In this article, we will walk you through the simple steps to create bootable flash drives on both platforms, equipping you with the tools you need for a smooth installation experience. From selecting the right software to formatting your USB drive, we’ll cover everything you need to get started.

Case Uses

Creating bootable flash drives can be incredibly useful for a variety of tasks. Moreover, each of these use cases highlights the versatility of bootable flash drives in both personal and professional settings. As a result, they become a valuable tool for various computing tasks.

  1. Operating System Installation: Install new operating systems like Windows, Linux, or macOS on a computer without a CD/DVD drive.

  2. System Recovery: Boot from a flash drive to access recovery tools for troubleshooting or repairing a malfunctioning operating system.

  3. Data Recovery: Use bootable drives with recovery software to retrieve lost or corrupted data from hard drives.

  4. Testing New Operating Systems: Run live versions of operating systems (e.g., Linux distributions) from a USB drive to test functionality without installing it on your hard drive.

  5. Creating System Backups: Boot from a USB drive to create system backups using backup software.

  6. Malware Removal: Use bootable antivirus tools to scan and remove malware from an infected system.

  7. Firmware Updates: Update BIOS or firmware on systems that do not support direct updates from within the operating system.

  8. Network Booting: Boot a computer over a network using PXE (Preboot Execution Environment) configurations set up on a flash drive.

  9. Portable Applications: Carry portable versions of applications that can run directly from the USB drive without installation on the host system.

  10. Custom Recovery Solutions: Create tailored recovery environments with specific tools and applications for troubleshooting.

  11. Secure Environments: Set up bootable drives for secure environments to ensure that sensitive tasks are performed without traces left on the local system.

  12. System Performance Testing: Run diagnostic tools and benchmarking software from a USB drive to assess hardware performance without interference from the main operating system.

  13. Multi-Boot Systems: Create a multi-boot USB drive to install or run multiple operating systems from a single flash drive.

  14. Software Deployment: Deploy software packages or updates across multiple systems in an organization.

  15. Virtual Machine Creation: Use bootable USB drives to install operating systems in virtual machines for development or testing purposes.

ISO Files

ISO files, short for International Organization for Standardization files, are disk image files that contain the complete contents and structure of a CD, DVD, or Blu-ray disc. These files serve as a digital replica of the original disc, preserving not only the data but also the file system information.

Creating a Bootable Flash Drive in Windows

Popular Flashing Software

Here are some popular applications to flash ISO files onto USB drives in Windows.

  • Rufus:
    A lightweight and user-friendly tool, Rufus allows you to create bootable USB drives from ISO files quickly. It supports various file systems and partition schemes.

  • UNetbootin:
    This cross-platform tool enables you to create bootable USB drives for a variety of operating systems, including Linux distributions. It offers a straightforward interface and can also download some ISO files directly.

  • Etcher (balenaEtcher):
    Known for its simple and intuitive interface, Etcher is a cross-platform tool that lets you flash images to USB drives and SD cards easily. It supports a wide range of image formats, including ISO.

ISO Flashing Procedure

For our example we will use Rufus. The software can be installed in Windows OS and downloaded from https://rufus.ie/downloads/.

  1. Ensure to download the latest version that is not in beta. An example of the correct version to get is shown in the image below.

    Rufus Download Page
    Rufus Download Page
  2. Select the USB Flash Drive within “Device” section. 
  3. Select the type of boot requirement within “Boot Selection” section, for this we would be flashing an ISO file so we would need to select “Disk or ISO image”.
  4. Press on the “SELECT” button to select the ISO file.

    Rufus ISO Selection
    Rufus ISO Selection
  5. Once the ISO is selected the “Boot Selection” field will be populate with the ISO filename.
  6. For “Partition Scheme” select the appropriate one for your system. Normally I go with “GPT”.
  7. Proceed to press the “START” button, note that all data on the USB Flash drive will be removed.
  8. If prompted with a window related to “ISOHybrid image detected” proceed with “Write in ISO Image mode (Recommended)”.

    ISOHybrid Image Detection Check
    ISOHybrid Image Detection Check
  9. The next prompt will explain that all data will be destroyed on the Flash drive as part of the process. Confirm and proceed.

    <yoastmark class=

  10. Once the process starts you will see the progress bar filling up until the Status shows a green “Ready” bar.

    Flashing in Progress
    Flashing in Progress
  11. At this point, you could begin to use the drive for whichever purpose. In the example I’ve used systemrescue from https://www.system-rescue.org/ to enter a rescue environment.

Creating a Bootable Flash Drive in MacOS

Popular Flashing Software

Here are some popular applications to flash ISO files onto USB drives in MacOS.

  1. Etcher (balenaEtcher):

    Etcher offers a user-friendly, cross-platform solution that lets you quickly create bootable USB drives and SD cards from ISO files. It features a clean interface and supports a wide range of image formats. Etcher actively verifies the flashing process, ensuring the integrity of the data written to the USB drive.

  2. UNetbootin:
    UNetbootin is another cross-platform tool that enables users to create bootable USB drives for various operating systems, including many Linux distributions. It allows you to either select an ISO file from your computer or download one directly within the application. UNetbootin provides a straightforward interface and is suitable for both beginners and advanced users.

  3. Terminal (using dd command):
    While not a standalone application, you can use the built-in Terminal on macOS to create bootable USB drives by using the dd command. This method is more technical but offers great flexibility for users who are comfortable with command-line interfaces. It allows you to specify the exact source and destination for the ISO image and the USB drive.

ISO Flashing Procedure

For our example we will use UNetbootin. The software can be installed in MacOS and downloaded from https://unetbootin.github.io/.

  1. Download the required version of UNetbootin from the portal.

    UNetbootin Download Page
    UNetbootin Download Page
  2. Install the downloaded application and proceed to open the “Disk Utility” application.
  3. Initialize/erase your USB flash drive while selecting “ExFAT” for “Format” and “GUID Partition Map” for “Scheme”.

    Disk Utility Drive Formatting
    Disk Utility Drive Formatting
  4. Proceed to open UNetbootin and select either the distribution you want the software to download or the ISO Diskimage. Select the USB drive and the the correct drive. Once ready, press on “OK”.

    UNetbootin ISO Selection and Prompts
    UNetbootin ISO Selection and Prompts
  5. Once the process began you shall see the steps being taken as the USB flash drive is being flashed with the ISO of choice.

    UNetbootin ISO Flashing in Progress
    UNetbootin ISO Flashing in Progress
  6. At this point, you could begin to use the drive for whichever purpose. In the example I’ve used systemrescue from https://www.system-rescue.org/ to enter a rescue environment.

Further Assistance

For any further assistance involving ISO flashing and mounting, do not hesitate to reach out to the Hivelocity Support team via a chat, support ticket, or phone at 888-869-4678.

The post Creating Bootable Flash Drives (USB) in Windows and MacOS appeared first on Hivelocity Hosting.

]]>
TCP/IP Information in Linux https://www.hivelocity.net/kb/tcp-ip-information-in-linux/ Fri, 18 Oct 2024 14:05:30 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=35166 TCP/IP (Transmission Control Protocol/Internet Protocol) is the fundamental communication protocol suite that underpins the internet and networking in Linux-based web hosting environments. It not only ensures reliable transmission of data across networks but also enables seamless connectivity between servers, clients, and other network devices. For web hosting professionals, understanding TCP/IP in a Linux environment is …

TCP/IP Information in Linux Read More »

The post TCP/IP Information in Linux appeared first on Hivelocity Hosting.

]]>
TCP/IP (Transmission Control Protocol/Internet Protocol) is the fundamental communication protocol suite that underpins the internet and networking in Linux-based web hosting environments. It not only ensures reliable transmission of data across networks but also enables seamless connectivity between servers, clients, and other network devices. For web hosting professionals, understanding TCP/IP in a Linux environment is crucial because it empowers them to configure and troubleshoot network issues effectively, ultimately ensuring the smooth operation of hosted websites and applications. Furthermore, this article will delve into the essentials of TCP/IP within Linux, thoroughly covering key concepts such as IP addressing and routing.

TCP/IP Within a Linux OS

Overview

In this example, we will review the networking information within AlmaLinux, a RHEL-based distribution.

To display network interface details, you can use the ip addr command. Additionally, this command and its output prove particularly useful, as they help users understand which configurations are currently running and on which interface within the system. Moreover, this information aids in troubleshooting and effectively managing network settings.

ip addr Output to Display Network Interface Details

ip addr Output to Display Network Interface Details

ip addr Information Breakdown

  • Interface Information:
    • Each network interface is represented by a numbered section (e.g., 1: for lo and 2: for ens18).
    • The name of the interface follows the number. Here, lo is the loopback interface, and ens18 is the Ethernet interface.
    • The status (UP/DOWN) and the MTU (Maximum Transmission Unit) size are listed:
      • mtu 65536 for lo means it can handle packet sizes up to 65536 bytes.
      • mtu 1500 for ens18 means it can handle packet sizes up to 1500 bytes, a typical value for Ethernet.
  • Link Information:
    • link/loopback for lo indicates that it is a loopback interface, which is used for internal communication within the host.
    • link/ether for ens18 shows that this is an Ethernet interface.
    • The MAC address is listed after link/ether. For example, b6:ea:ae:71:00:c3 is the MAC address of the ens18 interface.
  • IPv4 Address:
    • The line inet 127.0.0.1/8 for lo indicates the loopback address, which is commonly used for internal server communication.
    • In contrast, inet 23.111.182.195/29 for ens18 is the public IP address assigned to this server. The /29 denotes the subnet mask, which means that this address is part of a network with up to 8 IP addresses.
  • Broadcast Address:
    • Furthermore, brd represents the broadcast address used for sending data to all devices in the network. Specifically, for ens18, brd 23.111.182.199 serves as the broadcast address within the /29 subnet.
  • Scope:
    • Additionally, scope host means that the address is limited to the host itself, which is typical for the loopback interface (127.0.0.1). On the other hand, scope global indicates that the address is publicly accessible and used for external communication, as seen with 23.111.182.195.
  • IPv6 Address:
    • inet6 shows IPv6 addresses assigned to the interface. 2604:4500:6:6db::2/64 is a global IPv6 address, while fe80::b4ea:aeff:fe71:c3/64 is a link-local address, used for communication within the local network.
  • Status and Additional Information:
    • The state keyword indicates the current state of the interface:
      • UNKNOWN for lo means it is not associated with an actual physical link.
      • UP for ens18 means the interface is active and ready to send/receive data.
    • qlen 1000 shows the queue length, which determines how many packets can be held in the queue before being processed.

Checking Routing Information

Routing is a fundamental aspect of network configuration within the TCP/IP protocol, especially on Linux servers used in web hosting. It involves determining the path that data packets take to reach their destination across interconnected networks. Proper routing is crucial because it ensures that data travels efficiently from one network to another, thereby enabling smooth communication between clients, servers, and other networked devices.

Additionally, a routing table is a set of rules that the Linux kernel uses as part of the TCP/IP protocol to determine where to forward network traffic. Specifically, each entry in the table specifies a destination network and how to reach it. Furthermore, the routing table helps the system make decisions about the most efficient routes, ensuring optimal network performance and connectivity.

To review the current routes in the system ip route command can be used. 

ip route Used to Show the Routing Table of the Linux Server
ip route Used to Show the Routing Table of the Linux Server

ip route Information Breakdown

  1. The default route is used for any network traffic that does not match a more specific route.

    1. default via 23.111.182.193 dev ens18 which indicates the default route, via the gateway IP, using dev (Network interface) ens18.

  2. The Local Network Route 23.111.182.192/29 dev ens18 proto kernel scope link src 23.111.182.195 represents the network route, with /29 as the subnet mask, the ens18 network interface, and proto kernel indicating that the kernel added the route. The src specifies the source IP used when sending packets.

  3. The link-local route handles traffic for the 169.254.0.0/16 range, which devices typically use when they cannot obtain an IP address via DHCP. You can observe this behavior even if you do not enable DHCP, thanks to the automatic functions of the network stack.

Network Configuration Files

Network configuration in Linux involving the TCP/IP protocol establishes how a system connects to networks by defining IP addresses, gateways, and DNS servers. Consequently, this configuration enables communication within local networks or with the internet, ensuring proper data routing. Moreover, tools like ifcfg files, netplan, or /etc/network/interfaces manage this across different distributions, allowing for stable and secure network connections.

Furthermore, the configuration varies between each OS, and we will detail it below according to the main OSs that Hivelocity offers.

AlmaLinux/CentOS Configuration

  • The configuration file location should be present at “/etc/sysconfig/network-scripts/ifcfg-<interface_name>”.
    • Note that AlmaLinux does come equipped with NetworkManager in some cases and might require utilizing nmtui instead of performing the in-file configuration changes.
  • You can find the example configuration below.

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
NAME=ens18
UUID=910cd91f-8798-4435-9070-dcf556b3f82b
DEVICE=ens18
ONBOOT=yes
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
IPV6ADDR=2604:4500:6:6db::2/64
IPV6_DEFAULTGW=2604:4500:6:6db::1

Ubuntu Configuration

  • The configuration file location should be present at “/etc/netplan/*.yaml”.
    • The settings are applied using the netplan apply command.
    • Note that the spacing in the file is crucial.
  • You can find the example configuration below.
network:
  version: 2
  ethernets:
      ens18:
          dhcp4: no
          addresses:
               – 192.168.1.100/24
          gateway4: 192.168.1.1
          nameservers:
               addresses:
                    – 8.8.8.8
                    – 8.8.4.4

Debian Configuration

  • The configuration file location should be present at “/etc/network/interfaces”.
  • You can find the example configuration below.

auto ens18
iface ens18 inet static
  address 192.168.1.100
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 8.8.8.8 8.8.4.4

Further Assistance

For any further assistance involving TCP/IP and configuration, do not hesitate to reach out to the Hivelocity Support team via a chat, support ticket, or phone at 888-869-4678. The team can assist with recommendations, explanations, and reviewing/adjusting configuration files in your Linux OS.

The post TCP/IP Information in Linux appeared first on Hivelocity Hosting.

]]>
Powering Down and Rebooting Your Linux System https://www.hivelocity.net/kb/powering-down-and-rebooting-your-linux-system/ Tue, 27 Feb 2024 14:37:21 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=31550 Powering down and rebooting your Linux system involve fundamental processes that impact its operation and state. Initiating the shutdown command halts processes, ends user sessions, and unmounts file systems for a graceful shutdown. It sends signals to all running processes, instructing them to close properly to prevent data loss or corruption. Once it completes all …

Powering Down and Rebooting Your Linux System Read More »

The post Powering Down and Rebooting Your Linux System appeared first on Hivelocity Hosting.

]]>
Powering down and rebooting your Linux system involve fundamental processes that impact its operation and state. Initiating the shutdown command halts processes, ends user sessions, and unmounts file systems for a graceful shutdown. It sends signals to all running processes, instructing them to close properly to prevent data loss or corruption. Once it completes all essential operations, the system powers off.

When you issue the reboot command, the system undergoes a similar sequence of events as during shutdown. The crucial difference is that after halting processes and unmounting file systems, it initiates a hardware reset, effectively rebooting the system, which reinitializes hardware components and reloads the operating system kernel to its initial state.

Behind the scenes, these commands trigger a series of low-level operations orchestrated by the kernel and system management processes. The shutdown and reboot commands communicate with system services, notify users of impending shutdown or reboot, and handle any necessary cleanup tasks. The commands interact with system daemons responsible for managing hardware, file systems, and user sessions, ensuring a smooth transition between operational states while preserving data integrity and system stability. Overall, these commands play a crucial role in maintaining the health and functionality of Linux systems. This Powering Down and Rebooting Your Linux System guide will explain what commands you could use to perform such power actions in your Linux server.

Rebooting Your Linux Device

Rebooting your device instantly can be done via the command line interface (or in the Customer Portal) using the command reboot.

Reboot Command Which Reboots the Service Instantly
Reboot Command Which Restarts the Server Instantly

To schedule a reboot in your server, use the shutdown command in the following manner sudo shutdown -r +5 which will restart the server after a 5 minutes delay. To deactivate the scheduled reboot, you can use shutdown -c right after.

Using the shutdown Command to Reboot the Server with a 5 Minutes Delay
Using the shutdown Command to Restart the Server with a 5 Minutes Delay

Powering Down Your Linux Device 

Powering down your device instantly can be done via the command line interface (or in the Customer Portal) using the command shutdown, this command will shut the device down after 1 minutes of executing. 

Shutting Down the Server Using the shutdown Command
Shutdown Command to Power Down the Server

To schedule a shutdown in your server, use the shutdown command in the following manner sudo shutdown +5 which will power down the server after a 5 minutes delay. To deactivate the scheduled reboot, you can use shutdown -c right after.

Shutting Down the Server Using the shutdown Command with a 5 Minutes Delay
Powering Down the Server With a 5 Minutes Delay

 

The post Powering Down and Rebooting Your Linux System appeared first on Hivelocity Hosting.

]]>
Ownership and Permissions in Linux https://www.hivelocity.net/kb/ownership-and-permissions-in-linux/ Tue, 27 Feb 2024 14:37:04 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=31429 Ownership and Permissions in Linux Overview Ownership and permissions in Linux are a concept that determines who can access and modify files and directories. Every file and directory have an owner and a group, which are usually the user who created them and the user’s current group. The owner and group of a file or …

Ownership and Permissions in Linux Read More »

The post Ownership and Permissions in Linux appeared first on Hivelocity Hosting.

]]>
Ownership and Permissions in Linux Overview

Ownership and permissions in Linux are a concept that determines who can access and modify files and directories. Every file and directory have an owner and a group, which are usually the user who created them and the user’s current group. The owner and group of a file or directory can be changed using the chown command. Permissions can be read, write, or execute, and can be changed using the chmod command. Ownership and permissions are important for security and multi-user environments in Linux as Linux also uses permissions to control the access rights of the owner, group, and others. 

File and Ownership Permissions Structure

In Linux, understanding file ownership and permissions is crucial for effective system management and security.

Every file and directory in Linux have three kinds of owners:

  • User: The creator of the file becomes its owner. You can change the ownership later.
  • Group: Users are part of specific groups. Managing users in a multi-user environment involves creating separate groups (e.g., dev team, QA team, sysadmin team). Group membership simplifies permission management.
  • Other: This group includes all users on the system, even if you’re the sole user. Everyone with access to the system belongs to this group.

Each file and directory have three permissions for all three owner types:

  • Files
    • Read (r): Allows viewing or copying file contents.
    • Write (w): Permits modifying file content.
    • Execute (x): Enables running executable files (scripts or programs).
  • Directories
    • Read: Lists files and copies them from the directory.
    • Write: Adds or deletes files (requires execute permission).
    • Execute: Allows entering the directory.

File Permissions have two modes. An absolute mode and a symbolic mode. The modes detail the type of entries required for permissions to take effect.

  • Symbolic Mode 
    • Symbolic mode allows you to modify permissions based on their current state. You use symbols like +, -, and = to add, subtract, or set permissions.
      • + Adds permissions.
      • Removes permissions.
      • = Sets permissions explicitly
  • Absolute Mode
    • In absolute mode, you explicitly specify the permissions using numeric values (octal notation). These values represent the combination of read, write, and execute permissions for the owner, group, and others.
      • The numeric values are as follows:
        • 0: No permissions (—)
        • 1: Execute only (–x)
        • 2: Write only (-w-)
        • 3: Write and execute (-wx)
        • 4: Read only (r–)
        • 5: Read and execute (r-x)
        • 6: Read and write (rw-)
        • 7: Read, write, and execute (rwx)

Viewing File and Directory Permissions

Viewing file and directory ownership and permissions in Linux can be done with each via the command line interface of your Linux server.

The first one is using the ls command with the -l flag, as such ls -l. This command would allow a user to view a list of files within the directory they are in or in another (Using ls -l /path/to/directory) to view the permissions for each file. 

ls -l Command Displaying Files and Directories Within a Directory Along with Their Permissions
ls -l Command Displaying Files and Directories Within a Directory Along with Their Permissions

The second method is using the stat command to view a more in-depth scope of the file or directory involved.

stat Command Displaying an In-Depth View of File or Directory Permissions
stat Command Displaying an In-Depth View of File or Directory Permissions

Modifying File and Directory Permissions

Follow the steps below to proceed with file and directory permissions modification. For this example, we will use the absolute and symbolic modes with the file test_file.txt and the command chmod.

In this example we are modifying a file using the symbolic method by first viewing the file permissions using stat test_file.txt and modifying the permissions using chmod +x test_file.txt. Note that without specifying the user, group, other assignment, then the +x would apply all of them as seen below. 

To add permissions specifically to one of the owners, you can use chmod u+x test_file.txt which will add the +x to the user owner.

Using Symbolic Mode to Modify File Permissions
Using Symbolic Mode to Modify File Permissions

In this example we are modifying a file using the absolute method by first viewing the file permissions using stat test_file.txt and modifying the permissions using chmod 744 test_file.txt. Note that after the change has been done, the permissions changed from 644 to 744 or also known as rw-r–r– to rwxr–r–.

Using Absolute Mode to Modify File Permissions
Using Absolute Mode to Modify File Permissions

Thank you for reading and I hope that you enjoyed this Ownership and Permissions in Linux guide. For more guides, please check out our Knowledge Base which is updated weekly!

The post Ownership and Permissions in Linux appeared first on Hivelocity Hosting.

]]>
Skeleton Directories in Linux https://www.hivelocity.net/kb/skeleton-directories-in-linux/ Fri, 23 Feb 2024 21:25:30 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=31422 Skeleton directories in a Linux OS serves as the foundation for a new user’s home directory when created using the useradd command. It automatically copies files and directories to the user’s home directory. These files establish initial settings and environment, including the bash profile, aliases, and bookmarks. In this article, Skeleton Directories in Linux, we …

Skeleton Directories in Linux Read More »

The post Skeleton Directories in Linux appeared first on Hivelocity Hosting.

]]>
Skeleton directories in a Linux OS serves as the foundation for a new user’s home directory when created using the useradd command. It automatically copies files and directories to the user’s home directory. These files establish initial settings and environment, including the bash profile, aliases, and bookmarks.

In this article, Skeleton Directories in Linux, we will review each of the parameters and directories involved with the skeleton directory. 

Skeleton Directory Overview in A Linux System

The skeleton directory (/etc/skel) provides the backbone or skeleton of what any new account /home/<username> directory would look like. For example, if there are 3 directories in /etc/skel, then those directories would populate upon each and every new account that is being created.

Skeleton Directory and the Creation of Directories Within

  1. As shown above, we are viewing the directory with ls /etc/skel which shows no directories within.
  2. Create the required directories with the mkdir command, “Documents”, “Videos”, and “Downloads”.
  3. Use the ls command to verify that the newly created directories are present.
  4. When creating a new user, such as ‘pascal’ using the command useradd pascal, the user’s home directory will be located at /home/pascal/.
  5. View the home directory of the new user using ls /home/pascal in which the new directories will appear.
Viewing the New Directories Created in the /etc/skel Directory and How They Populate for New User Accounts
Viewing the New Directories Created in the /etc/skel Directory and How They Populate for New User Accounts

As seen in this article, skeleton directories are a useful tool for organizing the structure and layout of a project or user. Skeleton directories can help developers and collaborators to understand the purpose and function of each component, as well as to avoid duplication and confusion. Skeleton directories can also facilitate the automation and testing of the project, by making it easier to locate and execute the relevant scripts and commands.

The post Skeleton Directories in Linux appeared first on Hivelocity Hosting.

]]>
Bash Scripts in Linux https://www.hivelocity.net/kb/bash-scripts-in-linux/ Fri, 23 Feb 2024 21:25:09 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=31447 Bash, short for Bourne-Again Shell, is a powerful command-line interface (CLI) program that allows users to interact with their systems and execute bash scripts in Linux. Bash provides a way to execute commands, automate tasks, and create custom workflows using bash scripts. Here are the key points about Bash scripting. A Bash script is a …

Bash Scripts in Linux Read More »

The post Bash Scripts in Linux appeared first on Hivelocity Hosting.

]]>
Bash, short for Bourne-Again Shell, is a powerful command-line interface (CLI) program that allows users to interact with their systems and execute bash scripts in Linux. Bash provides a way to execute commands, automate tasks, and create custom workflows using bash scripts. Here are the key points about Bash scripting.

  • A Bash script is a file containing a sequence of commands written in the Bash language.
  • These commands are executed by the Bash interpreter line by line.
  • Bash scripts save time by automating repetitive tasks. Instead of typing the same commands repeatedly, you can run a script.
  • You can tailor scripts to your needs, creating personalized solutions.
  • Set up scripts to run at specific times (e.g., daily backups) by scheduling them using cron jobs. 

Creating and Executing Your First Bash Script

Let’s create a simple “Hello, World!” script in your server.

  1. Create a file named hello_world.sh using your editor of choice.
  2. Add the shebang line: #!/bin/bash.
    1. #!/bin/bash specifies that the Bash shell should interpret the script.
  3. Write the command: echo “Hivelocity!”.

    Creation of a Bash Script  in Linux Using the nano Text Editor
    Creation of a Bash Script in Linux Using the nano Text Editor
  4. Save the file.
  5. Make it executable using chmod +x /hello_world.sh.
  6. Run it by using either ./hello_world.sh or bash /hello_world.sh. (Bash at the start will run the script using the bash interpreter and should not be used if running a script in a language other than bash). 
Running a Bash Script  in Linux Using the bash Command
Running a Bash Script in Linux Using the bash Command

Bash Script Variables

Variables in Bash scripts are named symbols that represent either strings or numeric values. They allow you to store and reference data within your scripts. To create a variable, provide a name and a value for it. Variable names should be descriptive and cannot start with a number or contain spaces. They can start with an underscore and can have alphanumeric characters. It is also good practice to type variables with uppercase characters.

For example, take this bash script below.

Bash Script Variable Example
Bash Script Variable Example

Executing the script will provide the echo output of the variables that were set in the beginning of the script.

Bash Script Execution Displaying Output of Variables
Bash Script Execution Displaying Output of Variables

Other Shebang (#!) Examples

Shebang (#!) specifics the interpreter used for the script you’ve created and can be used for other languages other than bash.

  • #!/bin/bash: Specifies the Bash interpreter.
  • #!/usr/bin/env python: Uses the Python interpreter found in the user’s $PATH.
  • #!/usr/bin/perl: Executes the script using the Perl binary.

Common Operations for Bash Scripts in Linux

  1. Sleep command using “sleep 3” to pause an execution for a specified time in seconds. 
  2. Reading input from a user.
    read -p “Enter your name:” USERNAME
    echo “Hello, $USERNAME!”
  3. Loops to execute commands repeatedly 
    for i in {1..5}; do
    echo “Iteration $i”
    done

  4. Conditional Statements to make decisions based on conditions

    age=25
    if [ “$age” -ge 18 ]; then
    echo “You are an adult.”
    else
    echo “You are a minor.”
    fi

  5. Functions to define reusable code blocks
    greet() {
    echo “Hello from a function!”
    }
    greet

  6. File operations to create directories, read files, and delete files
    mkdir my_directory
    cat myfile.txt
    rm unwanted_file.txt

  7. Math operations to perform calculation
    result=$((5 + 3))
    echo “5 + 3 = $result”

  8. Checking file existence to verify if a file does exist

    if [ -f myfile.txt ]; then
    echo “File exists.”
    else
    echo “File does not exist.”
    fi

Scheduling your Script via a Cron Job

Adding a script to a cron job allows you to schedule it to run automatically at specified intervals.

  1. For demonstration purposes, let’s assume our script prints the system date and time and appends it to a log file.
    #!/bin/bash
    echo “$(date +’%Y-%m-%d %T’) – Hello, cron!” >> /home/user/log.txt

    Make sure the script is executable with chmod +x my_script.sh.

  2. Add the script to the user’s crontab by opening the crontab editor using crontab -e
  3. Append the following line to schedule the script to run every day at 3:00 AM using 

    0 3 * * * /path/to/my_script.sh

  4. Save and close the editor followed by ensuring that the script can be executed properly with chmod +x /path/to/my_script.sh.

For a useful tool on how to handle the time format of a cron job, check out the useful tool here – https://crontab-generator.org/

The post Bash Scripts in Linux appeared first on Hivelocity Hosting.

]]>
Handling Directories in Linux https://www.hivelocity.net/kb/handling-directories-in-linux/ Tue, 09 Jan 2024 22:55:22 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=29213 Directories in Linux are folders that contain files and other directories. They are organized in a hierarchical structure, starting from the root directory (/) that contains all other directories and files. In this tutorial, we will cover handling directories in Linux and explain how to create, rename, delete, and move through directories. — — Handling …

Handling Directories in Linux Read More »

The post Handling Directories in Linux appeared first on Hivelocity Hosting.

]]>
Directories in Linux are folders that contain files and other directories. They are organized in a hierarchical structure, starting from the root directory (/) that contains all other directories and files. In this tutorial, we will cover handling directories in Linux and explain how to create, rename, delete, and move through directories.

Handling directories in Linux – Absolute and Relative Paths

When traversing directories in Linux, there are two ways to type a file or directory path, an absolute path and relative path.

An absolute path is the specific location irrespective of the current working directory or combined paths and are written with reference to the root directory, starting with a forward slash /. Example of using absolute path, “cd /usr/bin

handling directories in Linux - Absolute path

A relative path is the path relative to the current working directory using period and double periods, indicating current and parent directories. Example of using a relative path when the current working directory is /usr/, “cd bin

relative path - directories in Linux

Both types will take you to the same place but take different steps and criterias to do so, when you handling directories in Linux.

How to Create a Directory 

To create a directory, we will use the mkdir command to do so. Follow the steps below to proceed. 

1. To create a directory in Linux, you can use the mkdir command followed by the name of the directory, as shown below.

The command will create a directory in the root directory (/) called “Net_Growth_21”.

mkdir /Net_Growth_21 which will create a directory in / with that name.

creating directory in linux

2. Creating a directory in a different directory, the full path can be given with the command.

mkdir /guide/Net_Growth_21 which will create the directory in a directory, /guide/, as shown below.

creating directory/guide

How to Navigate and List Directories in Linux

To navigate through directories, we will be using the following commands, pwd, ls, and cd.

1. The pwd command will print the working directory which you are currently working in.

Command to print working directory in Linux

2. The ls command will list all items in the directory you are currently working in.

List the items in directory

Another good option with ls is ls -lh which will present the items size and in a list form.

Present items in list form

3. The cd command is used to move through directories.

    1. Using cd . will navigate to the current directory as the period (.) is used to represent the current directory.
    2. Using cd .. will navigate one directory above the current directory.
    3. move through directoriesUsing cd ~ will take you to the home directory of the currently logged user. Two examples are listed below for root and psuissa users.


How to Move a Directory in Linux

If you’re trying to move a directory in Linux from one location to another, just follow these 4 steps:

1. To move a directory in Linux, you can use the mv command followed by the source and destination directories, as shown below.

mv [source directory] [destination directory]

 

2. So, if you wanted to move /directory1 into a second directory name /directory2, you would use the following command:

mv /directory1 /directory2

How to move a directories in Linux

Note: If no “/directory2” exists, /directory1 will be renamed as “/directory2”, essentially “moving” it into a newly created directory, otherwise, all content from /directory1 will move to /directory2.

 

3. This can also be done for multiple files and directories at once. Let’s say you have 3 files (File1, File2, and File3), and you’d like to move all them into /Directory1. Simply list out all your sources before your destination, and Linux will automatically move all these files at once.

mv file1.txt file2.txt file3.txt /home/directory1

How to move a directories in Linux

4. Keep in mind that in order to move files and directories, a user must have permissions allowing them to modify both the source and destination directories. Otherwise, an error will occur and permission will be denied.

 

How to Copy a Directory in Linux

If you’re trying to make a copy of an existing directory, just follow these 4 steps:

1. To copy a directory or file in linux, just use the copy command followed by the Source (the directory you’re copying), and the Destination (the place you’re copying it to):

cp -R [Source] [Destination]

 

2. to make a copy of /directory1 and place it inside of /directory2, you would use the command:

cp -R /directory1 /directory2

How to copy a directory in Linux

*Note: If no “/directory2” exists, a new directory will be created, with that name, and containing the contents of /Directory1.

 

3. Like moving files, it is possible to copy multiple files into a single directory by listing out multiple filenames for sources, followed by a single destination. For example:

cp -R file1.txt file2.txt file3.txt /directory1

Which would copy file1, file2, and file3 into /directory1.

How to copy a directory in Linux

4. Additionally, if you wanted to copy the entire contents of /Directory1 into /Directory2 (duplicating the files inside the folder but not the folder itself), you can do so by adding ” /* ” after the source directory. For example:

cp – R /directory1/* /directory2

This would create copies of all the files located in /directory1, placing duplicates of its content into /directory2, but not duplicating the actual directory itself.

How to copy a directory in Linux

How to Rename a Directory in Linux

If you need to rename an existing directory in Linux to something new, just follow these 2 steps:

 

1. Interestingly, due to the way Linux’s file structures work, moving a file and renaming a file are actually the same action. This is because when you’re “moving” a file in Linux, you’re really “renaming” its file path: giving it a new name but also a new location in your system’s structure.

mv [Source Directory] [Destination Directory]

So, to rename /directory1 to /directory_new, you would use the command:

mv /directory1 /directory_new

If “/directory_new” already exists, then this command will move the contents of /directory1 to /directory_new. However, if “/directory_new” does NOT already exist, this command will rename /directory1 to /directory_new.

Renaming a directory in linux

The post Handling Directories in Linux appeared first on Hivelocity Hosting.

]]>
Understanding Linux Shells https://www.hivelocity.net/kb/understanding-linux-shells/ Tue, 14 Nov 2023 18:32:43 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=29232 Introduction Linux shells are an essential part of the Linux operating system. They are command-line interpreters that allow users to interact with the operating system in many ways such as interpreting a user’s command and script files along with telling the OS what to do with them. There are many different types of shells available …

Understanding Linux Shells Read More »

The post Understanding Linux Shells appeared first on Hivelocity Hosting.

]]>
Introduction

Linux shells are an essential part of the Linux operating system. They are command-line interpreters that allow users to interact with the operating system in many ways such as interpreting a user’s command and script files along with telling the OS what to do with them. There are many different types of shells available for Linux, but some of the most popular ones include bash, zsh, and ksh.

 

Some of the characteristics of the Linux shell include:

  • Background processing: Sets up lengthy tasks to run in the background.
  • Command aliasing: Gives an alias name to a command or phrase.
  • Command history: Records the commands you enter in a history.
  • Input and output redirection: Redirects input and output to and from files.
  • Shell variable substitution: Stores data in user-defined variables.
  • Shell commands: cd, ls, echo, pwd, touch etc.
  • Functions
  • Control flow: if…then…else, case and shell loops etc.

Bourne Shell (sh)

Bourne shell is a command-line interpreter for Unix-like operating systems. It was developed by Stephen Bourne at Bell Labs in the 1970s and became the standard shell for Unix Version 7. Bourne shell supports variables, control structures, built-in commands, and basic scripting features. It is also the ancestor of many other shells, such as bash, ksh, and zsh. 

Bourne Again Shell (bash)

Bash is a command-line interpreter that allows users to interact with the operating system using text commands. Bash stands for Bourne-Again SHell, a pun on the name of the original Unix shell, the Bourne shell. Bash is compatible with the syntax and features of the Bourne shell, but also adds many enhancements. 

 

Some of the advantages of using bash are:

 

  • Bash is widely available and installed by default on most Linux and macOS systems.
  • Bash supports scripting which allows users to write programs that automate tasks and run them in bash.
  • Bash offers many built-in commands and utilities that perform common operations such as file manipulation, text processing, arithmetic, and networking.
  • Bash provides users the ability to customize their environment using variables, aliases, functions, and options.
  • Bash also supports features that make the command-line more user-friendly, such as command completion, history, editing, and redirection.

Z Shell (zsh)

Zsh is a powerful and versatile shell that offers many advantages over the traditional bash. Zsh has features such as auto-completion, spelling correction, globbing, history manipulation, and command-line editing. Zsh can also be customized with themes, plugins, and options to suit different preferences and workflows. The shell is compatible with most Unix-like operating systems and can run scripts written for bash or other shells while also being used by developers, system administrators, and power users.

 

Some of the features of Z Shell are:

 

  • Programmable command-line completion
  • Extended file globbing
  • Improved variable/array handling
  • Spelling correction and approximate completion

KornShell (ksh)

KornShell is a Unix shell that was developed by David Korn at Bell Labs in the early 1980s. It is compatible with the Bourne shell, but also provides many features from the C shell and other advanced shells. KornShell can be used as an interactive command-line interpreter or as a scripting language. 

 

Some of the features of KornShell are:

 

  • Command-line editing and history
  • Aliases and functions
  • Arrays and associative arrays
  • Arithmetic and string operations
  • Pattern matching and file name generation

How to Determine Which Shell is Being Used?

In your Linux server, within the current command-line interface, type the command below to view which Linux shell you are using.

 

echo $SHELL

The post Understanding Linux Shells appeared first on Hivelocity Hosting.

]]>
Echo and its Function in Linux https://www.hivelocity.net/kb/echo-and-its-function-in-linux/ Tue, 14 Nov 2023 18:24:28 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=29235 What is the Echo Command? The echo command in Linux is a built-in command that allows users to display lines of text or strings that are passed as arguments. It is commonly used in shell scripts and batch files to output status text to the screen or a file.    The echo command has various …

Echo and its Function in Linux Read More »

The post Echo and its Function in Linux appeared first on Hivelocity Hosting.

]]>
What is the Echo Command?

The echo command in Linux is a built-in command that allows users to display lines of text or strings that are passed as arguments. It is commonly used in shell scripts and batch files to output status text to the screen or a file. 

 

The echo command has various options that can change the format and behavior of the output, such as enabling the interpretation of escape characters, omitting the newline after the output, or changing the color of the text. The echo command can also use variables and commands as arguments, which makes it more versatile and dynamic. 

 

The echo command can also write to files and directories by using redirection operators, such as > or >>. The echo command is one of the most basic and essential commands in Linux, and it can be used for various purposes, such as debugging, testing, or creating text files.

Using Echo and Redirection Operators 

Redirection operators are symbols that allow you to change the source or destination of data in Linux commands. There are two types of redirection operators: input and output. 

 

  • Input redirection < takes data from a file or another command and feeds it to the standard input of a command. 
  • Output redirection > takes data from the standard output of a command and writes it to a file or another command.
  • There are also variations of output redirection, such as appending >> which adds data to the end of an existing file, and error redirection 2> which redirects the standard error of a command to a file or another command. 

 

Redirection operators are useful for manipulating data and controlling the flow of information in Linux, with examples shown below.

Output Redirection Example 1

In the example below, I’ve used the output redirection while appending the text as I did not wish to overwrite all of the file content.

 

The text file below had 3 lines and with the command echo “This is the fourth line” >> example.txt I was able to add text to the end of the file.

Output Redirection Example 2

What would happen if I were to use > ?

As shown above, all the file’s content will be removed and overwritten by the single line used with the echo command.

 

The post Echo and its Function in Linux appeared first on Hivelocity Hosting.

]]>
Linux Storage Analysis https://www.hivelocity.net/kb/linux-storage-analysis/ Mon, 28 Nov 2022 18:13:35 +0000 https://www.hivelocity.net/?post_type=hv_knowledgebase&p=22636 Traversing storage drives in Linux can be intimidating task at first. In this article, we’ll cover some basic and advanced commands along with various third party tools you can use to help gather information regarding your system’s current status. These commands should cover all basic needs that you might require in order to evaluate the …

Linux Storage Analysis Read More »

The post Linux Storage Analysis appeared first on Hivelocity Hosting.

]]>
Traversing storage drives in Linux can be intimidating task at first. In this article, we’ll cover some basic and advanced commands along with various third party tools you can use to help gather information regarding your system’s current status. These commands should cover all basic needs that you might require in order to evaluate the storage conditions of your Linux system and get a better understanding of your device.

Basic Commands to Evaluate Storage Conditions

The following commands will cover basic information regarding storage devices and their current usage conditions.

  • The following command will list drives in the system that are available along with their set mounting directories:

    lsblk

  • The following command will let you view the current disk usage by the filesystem along with the drive’s total size, amount used, usage %, and mounted directory for each:

    df -h

  • The following command will let you view the size of a particular directory (in this example the /backup directory):

    du -sh /backup

Advanced Commands to Evaluate Storage Condition

The following commands will help you take a deeper look into retrieving information regarding specific file and directory sizes. These are useful for determining which particular files or directories are taking the largest amount of space and will give you a good starting point in your system analysis.

  • The following command inspects the largest files and directories in a given directory:

    du -ahx / | sort -rh | head -15

    *Note: To modify the specific directory, enter it after the “-ahx” option. For example, du -ahx /home | sort -rh | head -15, will retrieve information from the /home directory.

    To evaluate and retrieve a specific number of files, modify the numeric value after the “head” string. For example, du -ahx /backup | sort -rh | head -60 , will retrieve 60 of the largest files and directories within /backup directory.

  • The following command can be used to retrieve a list of every file that is larger than 500MB in the directory of choice [*Note: the entire command is one line]:

    find / -type f -size +500M ! -path ‘*proc*’ ! -path ‘/home/virtfs*’ -exec ls -lh {} \;|awk ‘{ print “\033[32m”$NF “: \033[31m”$5″\033[0m” }’

    *Note: Directory can be modified here by changing it after the “find” syntax, for example, find /home2, will search within the /home2 directory.

    File size can be changed as well to suit your need by changing the value of “500M” to any value you’d like.

  • The following command can be used to retrieve a list of files that have recently changed [*Note: the entire command is one line]:

    find . -type f -exec stat -c ‘%Y %n’ {} \; | sort -nr | awk -v var=”20″ ‘NR==1,NR==var {print $0}’ | while read t f; do d=$(date -d @$t “+%b %d %T %Y”); echo “$d — $f”; done

Various Third-Party Packages to Visualize the Filesystem

The following are a couple of packages which can assist in your storage analysis by creating a visual representation of your filesystem, allowing you to traverse it via a user interface.

NCurses Disk Usage

This particular package, NCurses Disk Usage (or ncdu in your package manager), can be used if available within your package manager to help visualize and perform simple commands with files in your system. The keyboard arrows in ncdu can be used along with typing “?” for further assistance on which keys perform which functions.

Screenshot of the NCurses Disk Usage (ncdu) interface

Midnight Commander

Another useful command-line tool is Midnight Commander (or mc in your package manager), which allows you to view file sizes and modification time, along with having split screen for file transfers.

Screenshot of the Midnight Commander (MC) interface.

-written by Pascal Suissa

The post Linux Storage Analysis appeared first on Hivelocity Hosting.

]]>