The Linux nano editor

There is a massive world of editors to use in Linux, many of which need to be used in a desktop environment. However there are also a lot of editors that are used in a bash command shell. There is of course vim which is one well know such editor, however if you are new to editing text in a bash shell it might be best to start with the Linux nano command line based text editor. Also I still like nano over others when it comes to a command line interface style text editor, so it is something that is not just for beginners.

There is just the very basics of how to get started with nano, that is just opening up a file, or creating a file with it. However there is also using it as a way to end up with some text that is the result of another command via piping, and other little things about nano that might justify writing a quick post on the editor. So in this post I will be going over every little detail that I think is worth mentioning when it comes to using nano as a test editor, and also some related topics that might also be worth mentioning here.

Read More

Linux df command examples

The Linux df command is what I generally use to find out how much space is available in a file system in the bash command line. By default with no arguments it will give the amount of space available on all mounted file systems. It can also be given a mount point, or a path of a file, however it will still only give data for the file system as a whole. So then this brings up some questions when it comes to knowing how much space something takes up also when it comes to files and folders as the Linux df command alone is not enough.

So this will be a quick post not just on the Linux df command, but also some related topics when it comes to knowing not just how much space is available on a file system, but also to know how much space certain files and folders take up from a bash command line environment.

Read More

Functions in Linux Bash Scripts

When working out a bash script there are some times situations in which I find myself repeating the same bash code over and over again in a script. So there should be a way to define a block of bash script code as part of a function that will take one or more arguments, and then just call that function over and over again rather than repeating the whole block of code.

So in this post I will be going over some of the basics of functions when writing bash scripts.

Read More

The Linux Cut command for cutting a string in bash

The Linux cut command is the standard tool for cutting a string into one or more sub strings. The first and for most way of using cut as I see it at least is by field and delimiter, that is using a delimiter like a line break or a space as a way to split a string into fields, and then using a field index to get the sub string value that I want.

There are a few other options with The Linux cut command, but I will just be sticking to a few basic examples that actually come into play when writing bash scripts. So in this post I will not be going over every little detail about the Linux cut command, when it comes to that there is always the man page on Linux cut, as well as many other blog posts on Linux cut that go over all the features and options. Here in this post I will just be going over the options that I am using thus far, and give some actually use case examples for the Linux Cut command. I will also be touching base one many other Linux commands and features such as echo, piping, basic bash files, and the basename command to just name a few things.

Read More

Change Bash prompt in Raspberry PI OS and most Linux Systems

One of the many little things that I like to change when working with a clean image of Raspberry PI OS is the bash prompt format. The file of interest is the .bashrc file that should be found in the root folder of the home folder of the current user to which I would like to change the bash prompt for. There are several options when it comes to how to go about coming up with a format when it comes to having the current user, full path of the current working path, and so forth. That is of course one of the reasons why I would like to change it actually.

By default when I start a new lxterminal session I get a bash prompt that will contain the current full path of the current working directory. Maybe this is called for when it comes to people that are new to Linux and bash, but I have been at this for a while, and long story short I know about the pwd command. So there is at least one little change that I would like to make this is to just have the current base name of the current working directory in the prompt.

In any case this post will be a quick overview of how to go about changing what the prompt is for a bash shell session my changing the value of the PS1 variable, and also how to make that change stick by editing the ~/.bashrc file. In this post I am using Raspberry PI OS, but the process should be similar in just about all Linux systems that use bash.

Read More