Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Open Source Articles
Page 109 of 123
List the Size of Each File and Directory and Sort by Size in Linux
Listing and sorting files and directories by size is essential for system administration, disk space management, and file organization. Linux provides multiple command-line tools and GUI methods to accomplish this task efficiently. This guide covers various approaches to list files and directories sorted by their size. Command Line Methods Using the ls Command The ls command is the most common tool for listing directory contents. By default, it sorts entries alphabetically, but you can modify this behavior with specific options. Basic listing with detailed information: ls -la This displays all files (including ...
Read MoreGet the Full Path of a File in Linux
Every file and folder in Linux has a path that directs the user to it. This path is required for programs and scripts to locate and access files. There are various ways to locate the path to a file or folder if you need to. We can get a full file path with different commands on a Linux machine. In this tutorial, we'll show you how to obtain a file's complete path in Linux using multiple command-line methods. Understanding File Paths in Linux In Linux, there are two different kinds of paths: absolute and relative. A forward ...
Read MoreHow to display the current working directory in the Linux system?
To print the current working directory, we use the pwd command in the Linux system. pwd (print working directory) − The pwd command is used to display the name of the current working directory in the Linux system using the terminal. This is a shell builtin command that is available in most Unix shells such as Bourne shell, ash, bash, ksh, and zsh. Syntax The general syntax of the pwd command is as follows − pwd [-LP] A brief description of options available in the pwd command. Option Description ...
Read MoreHow to change the file owner and group in Linux?
To change the file owner and group, we use the chown command in the Linux operating system. Linux is a multiuser operating system where every file and directory belongs to an owner and group. The chown command allows administrators to transfer ownership and group membership of files and directories. Syntax The general syntax of the chown command is as follows − chown [OPTION]... [OWNER][:[GROUP]] FILE... chown [OPTION]... --reference=RFILE FILE... Common Options Option Description -c, --changes Gives a diagnosis for all files that actually changed ...
Read MoreHow to create a symbolic link to a directory in Ubuntu?
Symbolic links (symlinks) in Linux are advanced shortcuts that point to another file or directory on your system. A symbolic link appears to be the same as the original file or directory it references, even though it's simply a pointer. This powerful feature allows you to create references to files and directories located elsewhere in the filesystem. What are Symbolic Links? Symbolic links are essentially file system objects that contain a path to another file or directory. When you access a symbolic link, the operating system automatically redirects you to the target location. This is particularly useful for ...
Read MoreExclude Multiple Patterns With Grep on Linux
Grep is a powerful command-line utility on Linux that allows users to search for patterns in text files. It is widely used for tasks such as searching log files for specific strings, filtering configuration files, or extracting information from large datasets. One of the useful features of grep is the ability to exclude multiple patterns from the search results, which helps filter out irrelevant or unwanted lines. Excluding a Single Pattern with Grep The easiest way to exclude a pattern from a grep search is to use the -v option (invert match). This option tells grep to display ...
Read MoreRun a Script on Startup in Linux
There are several ways to run a script on startup in Linux, depending on your specific distribution and the type of script you are trying to run. Each method has its own advantages and is suitable for different use cases. Methods Overview Method Best For Linux Systems User Level systemd System services, daemons Modern distributions System-wide cron (@reboot) Simple scripts, scheduled tasks All distributions User or system rc.local Quick system scripts Traditional systems System-wide init.d Legacy system services Older distributions System-wide .bashrc/.bash_profile User-specific ...
Read MoreHow to Change the Default Home Directory of a User on Linux?
When you create a user on a Linux system, that user is given a default home directory. This home directory is a personal space where the user can store their files and settings. Sometimes it may be necessary to change a user's default home directory on a Linux system. This could be because you want to provide a different location for the user's files or because you want to change the user's name and update the home directory accordingly. Prerequisites Before you get started, there are some prerequisites you should be aware of − You must ...
Read MoreCount lines in a file using Linux bash
Counting lines in a file is a fundamental task in Linux system administration and text processing. Whether you're analyzing log files, processing data, or managing configuration files, knowing how to quickly determine the number of lines helps with file size estimation and data analysis. Linux provides several built-in commands to accomplish this task efficiently. Sample File Setup For demonstration, we'll use a text file called programming.txt containing popular programming languages: $ cat programming.txt JavaScript Java C Python C# PHP C++ Go R Ruby This file contains 10 lines. Let's explore different methods to count ...
Read MoreLinux tar Command
The tar command in Linux is one of the most essential commands for file management and archiving. Short for Tape Archive, it creates and extracts archive files — compressed files containing one or more files bundled together for easier storage, backup, and portability. This guide demonstrates how to create, list, extract, and modify tar archives with practical examples. Syntax The basic syntax of the tar command is − tar [options] [archive-file] [files or directories] Common Options Option Description -cCreate a new archive -xExtract files from archive -fSpecify ...
Read More