how to navigate directories in linux

cd command to change directory

One of the common task that you will perform when using the command line interface in Linux, is navigating directories. The Linux file system is hierarchical in nature and the top most directory is called the root and is denoted by the forward slash (/). The command used to change the current working directory is called cd (Change Directory). It…

how to merge two or more directories in linux

rsync examples in linux

Before we merge two or more directories, we need to define what we mean by “merge” in the context of directories. There can be a variety of requirements that could be named as merging of directories. Let’s assume that merging of (two or more) directories means “to create a new directory with files from all of the merged directories“. There…

bash: find last occurrence of a character in a string

linux count characters, words, lines

When writing shell scripts, you usually run into use cases where you want to manipulate text strings. Here we will see how you can find the last occurence of a single character in a string and then use that information to manipulate text or strings. For the purpose of this post, we will consider the character that we can to…

how to count the number of delimiters in a text file in linux

Find common lines in text files

It is easy enough to count lines in a text file, also it is easy enough to count characters with in a text file. So, counting delimiters in the text file should be just as simple. The delimiters are usually nothing but characters and counting those characters will give the count of delimiters in the file. For example, counting lines…

how to delete symbolic links in linux

Symbolic links and symlinks are one of the most popular features of posix based Linux systems. The symbolic links gives you the ability to duplicate files in the system with different names and location with out the need to create copies of the file. There are two different types of links that you can have in Linux: hard links and…

how to delete all empty directories in linux

Linux command line delete files

You might already know that in Linux a directory have to be empty before it can be deleted. Well…not quite true, you can force delete the directories. What if you want to remove only empty directories recursively from the folder structure? There are a couple of different ways to do this. We will see some of the options from the…

linux: how to replace text in file from command line

vi editor and search expressions

Linux has several different utilities that can perform string or text manipulation. Depending on your environment and the tools that are available, you should be able to easily parse, find and replace any string in a text file. Almost every single text editor comes with a find and replace feature with a UI, so we are going to only explore…

how to enable and disable ssh in linux

linux config file for sshd

ssh or secure shell is a network protocol that allows you to perform various network services remotely and securely over an unsecured network. There are several different operations that can be performed using the ssh protocol. The most common are probably logging in or connecting to a remote machine and transferring files over the network to a remote machine. In…

how to use secure copy (scp) to copy files in linux

linux cp command to copy folders

If you work with computers of any kind, sooner or later you will want to copy files between folders. Often times you want to copy files between machines or computers over a network as well. Secure Copy or scp allows you to copy files between hosts on a network. The files are copied over ssh or secure shell which allows…

how to delete lines in vi or vim editor in linux

vi editor and search expressions

If you use vi or vim editor to edit text files, then you should be aware of the different text manipulation commands that exist in the editor. One of the common actions you will perform is the deletion of a single line or the deletion of multiple lines of text from with in the editor. Let’s see the various ways…

how to use the tail command to view files in linux

linux tail command

There are several different ways to view text files in Linux. You can use a text editor such as vi or gedit. You can also use an utility like more or less that will print out the complete content of the file. tail is yet another utility that will allow you to view the contents of a file. However, there…

11 simple rsync examples that you can use to be more productive

rsync examples in linux

If you have been working with Linux for any amount of time, you must be familiar with the rsync command utility. rsync is a very powerful tool that allows you to synchronize files between two locations, even remote locations over the network. It is a very powerful file transfer tool with definite advantages over any other copy programs. The generic…