Time a Command in Linux
Getting familiar with timing commands in linux is a good idea. This is a good way to time long operations in a bash script or from the terminal. You can time most commands and any bash script. My favorite use case is for timing source code compilation from build scripts.
Tags: tutorials, linux, command lineRedirect and Append to a File in Linux
On every linux system you can redirect and append to the end of a file.
Linux has “stdout” which stands for “standard output”. Whenever you run a command in your terminal, the result is displayed in the stdout. You can redirect and append stdout to the end of a file.
Tags: tutorials, linux, command lineBash Exit Status
Regardless of whether a bash command ends successfully or not, it returns an exit status. Aside from letting you know that the command succeeded or failed, you can use the exit status code in bash scripts to determine what action to take with a conditional statement.
Tags: tutorials, linux, command lineRename Files & Folders Linux Command Line
Lets take a look at how to rename files and folders in linux from the command line.
Sure you can use your GUI and be done with it, but learning to do it from the command line can be quite useful. There’s also the added benefit of being able to use these commands in bash scripts.
Tags: tutorials, linux, command lineRemove Unused Kernels Ubuntu 18.04
A question often asked… How do I remove old unused kernels from ubuntu 18.04?
Each time you receive a kernel update in your ubuntu 18.04 system updates, you end up with the old kernels remaining in your system. This can be useful in the event that the new kernel causes issues, you can always boot the old kernels. In time, old unused kernels can accumulate taking up unnecessary space on your drive.
Tags: tutorials, linux, command lineBash Arrays
Bash arrays are quite powerful and robust, but not often used in the command line. They are variables which contain multiple values often referred to as items or elements. Arrays do not have a maximum limit for items they can contain nor do the values need to be assigned or indexed contiguously.
Tags: tutorials, linux, command lineCheck If Directory Exists In Linux With Bash
It’s useful to know how to check if a directory exists in linux from a bash script. A directory is a folder within a path in your linux system where all sorts of files and directories are stored. Your Music folder is a directory to store music files and your Downloads folder is a directory where all sorts files are downloaded from the web. You get the idea.
Tags: tutorials, linux, command lineColors In Bash Scripts
Using colors in bash scripts can be very useful. If you’ve written your bash script with menus and prompts, it’s a good idea to use ansi color codes to make your outputs more readable to the user. In this tutorial I’ll cover some ways that you can use colors in your bash scripts for a more GUI like experience.
Tags: tutorials, linux, command lineCreate a Menu in a Bash Script
Creating a menu in a bash script can be quite useful and at times necessary. A bash menu can allow you to provide options for user input. Upon user selection of an option in your menu, you can run a command or sequence of commands and display outputs.
Tags: tutorials, linux, command lineWrite Bash Functions
Writing bash functions is a great way to make your scripts modular. If you find you’ll be needing to repeat sets of commands or code logic, it’s a good idea to use functions to avoid redundancy in your script. Bash functions also help keep your code neat and easier to maintain.
Tags: tutorials, linux, command line