Home » Linux

Delete Files Older Than X Days/Hours in Bash [Examples]

Bash Deleting Files Older Than X

This article will show you how to delete files older than a given number of days (or hours/minutes) manually or automatically via a Bash script. Examples included. Removing files older than a certain number of days (or minutes, or hours) makes use of two Linux commands – rm and find. Deleting Files with rm First up, the rm command. The rm command is used to remove files and directories in Linux. Here’s a whole article about how it’s used: rm Command in Linux [With Examples] Passing a Filtered List of Files to rm The next … Read more

Home » Linux

Bash Aliases – What They Are and How To Use Them

Bash Aliases

If you live in the Linux Shell/Terminal, aliases are a massive timesaver. Here’s how to create your own Bash aliases, with examples. What is an Alias in Bash/Linux Shell? An alias is a shortcut to a longer command. It’s similar to a keyboard shortcut – like the CTRL + C key combination is a shortcut to the copy command in many graphical operating systems (saving the time in dragging your mouse across the screen and clicking multiple menus to reach the command), aliases are shortcuts to longer terminal commands (saving time typing out the full … Read more

Home » Linux

Remove/Delete Files/Directories in Linux with rm

Linux rm Remove File Directory

This article will outline how to delete files and directories in Linux with the rm command and give example usage. The rm Command in Linux Files and directories can be deleted from the shell/command line in Linux using the rm command. rm Command Syntax rm OPTIONS FILES Note that: OPTIONS is a list of options from the below table FILES is a list of files or directories (if the -r option is specified) to be removed Multiple files or directories can be specified, separated by spaces Options Here are the most commonly used options for … Read more

Home » Linux

Move Files With the mv Command in Linux, With Examples

Linux Move File mv

This article will walk you through moving files in Linux with the mv command, with examples and tips on moving files safely. mv Syntax Moving files is done using the mv command, which has the following syntax mv OPTIONS SOURCE DESTINATION Note that: OPTIONS is a list of options from the below table SOURCE is the path to the file you wish to move DESTINATION is the path to the destination you want to move the file 2 This can include a new file name or simply be the path to a … Read more

Home » Linux

Unix vs Linux – What’s the Difference?

Unix vs Linux

Here’s a quick summary of Unix and Linux and what makes them different, and ways you can try them out. Different products, similar uses What is Unix? Unix was developed in the 1970s by Bell Labs as an Operating System for developers. Over time features such as multitasking and support for multiple users were added, turning it into a versatile operating system popular with universities. The modular development of Unix lead to the Unix Philosophy – an emphasis on modular, reusable code and handling files as … Read more

Home » Linux

Exiting Bash Scripts with the exit Command, With Examples

Bash Exit Script

Bash/Shell scripts usually run sequentially until all of the code in the file has been executed. The exit command will exit the script before this based on conditions of your choosing. exit Command Syntax Here’s the syntax for the exit command, which can be used in Bash/Shell scripts: exit STATUS Note that: STATUS is an optional parameter that sets the exit status of the script The exit status tells other programs whether the script executed successfully or not It will default to either 0 or the exit status of the last command executed by … Read more

Home » Linux

Array Variables in Bash, How to Use, With Examples

Bash Array

We’ve covered using variables in Bash previously – this article will explain Bash array variables and provide some example usage. What is an Array An array is a type of variable that can hold multiple values. It’s a list of values you can loop through and perform operations on each individual value. For example, you might want to perform an action on a list of files. By storing that list as an array, you can loop through the file names in it and perform the action on each … Read more

Home » Linux

What is $@ (Command Line Arguments) In Bash/Linux?

Bash $@

This article will explain what the $@ is in Bash and Bash/Shell scripting and how and why you might use it. The $@ variable is a special variable in Bash which holds the value of all of the command line arguments/parameters passed to the script. Command Line Arguments/Parameters in Bash Using command-line arguments/parameters in shell scripts is an important and useful feature, so we have a full article on it: This article follows on from our article on Command Line Arguments in Shell/Bash Scripts $@ Contains All Parameters/Arguments Passed to … Read more

Home » Linux

Find Large Files in Ubuntu/Linux (du/ncdu), With Examples

Ubuntu Linux Find Large Files

Running out of disk space? Here’s how to find large files in Ubuntu (and other Linux distributions) without any fuss using the du and ncdu commands. The du Command The du (Disk Usage) command does what it says it does – tells you about the disk usage of files in a given directory. du Command Syntax du OPTIONS PATH Note that: – OPTIONS is an optional space-separated list of options from the du command manual – OPTIONS will allow you to specify things like maximum and minimum file sizes to include, what unit to measure file sizes … Read more

Home » Linux

Restarting the Network in Ubuntu [Instructions/Example]

Restart Network Ubuntu

If you’ve recently updated your network configuration or just can’t get things to connect, you may need to restart the networking services on your Ubuntu System to get things back up and running. Restarting the network is particularly useful if you’re recently updated your WiFi network details or changed your IP address or hostname. These examples will work for Ubuntu and should work for Ubuntu-based distributions like Pop!_OS and Linux Mint. Restarting the Network Service from the Linux Terminal/Command Line This is probably the solution you’re looking for … Read more