Create and Use Bash Aliases on Ubuntu 20.04 Linux System - Step by Step Process ?

This article covers the procedure of creating and using bash aliases. Running long and complex commands is usually tedious and time-consuming. Aliases provide much-needed relief by providing shortcuts to those complex commands.

These shortcuts can easily be called on the terminal and yield the same result as the complex command. 

This tutorial shows how to create and add aliases permanently to your bash shell on Linux and Unix-like systems.

To Create Bash Aliases

Creating aliases in bash is very straight forward. 

The syntax is as follows:

alias alias_name="command_to_run"

An alias declaration starts with the alias keyword followed by the alias name, an equal sign and the command you want to run when you type the alias. 

10 Useful Awk Command Examples in Linux

This article covers a few awk commands and scripts.

Awk is a scripting language used for manipulating data and generating reports.

The awk command programming language requires no compiling, and allows the user to use variables, numeric functions, string functions, and logical operators. 

AWK Syntax: 

$ awk options 'selection _criteria {action }' input-file > output-file

Functions of AWK:

1. AWK Operations: 

(a) Scans a file line by line 

(b) Splits each input line into fields 

(c) Compares input line/fields to pattern 

(d) Performs action(s) on matched lines 

2. Useful For: 

(a) Transform data files 

(b) Produce formatted reports 

3. Programming Constructs: 

(a) Format output lines 

(b) Arithmetic and string operations 

(c) Conditionals and loops 

Check Disk Usage Using Duf Command-line Utility on Linux

This article covers how To View Disk Usage With Duf On Linux And Unix.

Duf is a command line utility to find disk usage in Linux and Unix-like systems.
It displays the disk usage details in a nice tabular-column and user-friendly layout.
You can even get the disk usage output in JSON format as well.

Features of duf Utility:
1. Easy to use
2. Colorful display
3. Adjust height and width as per your terminal resize movement
4. Sorting data as per our need
5. Filters and groups
6. JSON outputs and more

On DEB-based systems such as Debian, Ubuntu, Linux Mint, download the .deb binary installation file from the releases page and install it using your system's package manager.

$ sudo apt install gdebi
$ sudo gdebi duf_0.3.1_linux_amd64.deb

On RPM-based systems such as RHEL, CentOS, Fedora, download the .rpm binary file and install it using command:

$ sudo rpm -Uvh 

To View Disk Usage With Duf On Linux And Unix:
All you have to do is just run the duf command without any options like below:

$ duf

Use CAT Command to Combine Text Files in Ubuntu 20.04 - Do it now ?

This article covers the detailed examples used for combining the text files in Ubuntu 20.04 system using the CAT command.
Users can easily use these methods to merge text from multiple files and sort it into another file.

They can also append text from one file to another file using the Ubuntu terminal.

Use of Head Command in Linux - With different examples ?

This article covers how to use head command with all required options. 

By using the tail command with a head command, you can also display the last lines of a file on the terminal.

The head command, as the name implies, print the top N number of data of the given input. 

By default, it prints the first 10 lines of the specified files. 

If more than one file name is provided then data from each file is preceded by its file name. 

Head command Syntax:

head [OPTION]... [FILE]...

Sort command in Ubuntu Linux with examples

This article covers the basic syntax and usage of the sort command in Ubuntu Linux. To view help and learn about more sort options, visit the sort man page  or type sort –help in Terminal.

sort is a simple and very useful command which will rearrange the lines in a text file so that they are sorted, numerically and alphabetically. 

By default, the rules for sorting are:

1. Lines starting with a number will appear before lines starting with a letter.

2. Lines starting with a letter that appears earlier in the alphabet will appear before lines starting with a letter that appears later in the alphabet.

3. Lines starting with a lowercase letter will appear before lines starting with the same letter in uppercase.

Password Protect a File Using Vim on Ubuntu - Step by Step process ?

This article covers how to password protect a file using Vim on Linux.  When password protecting a file, make sure you remember it, or else you will not be able to access your file.

You can also use a password management software if you find it difficult to remember passwords. Or visit our guide on how to install Teampass password manager on Ubuntu .

Always remember to appropriately secure text files that could contain secret info such as usernames and passwords, financial account info and so on, using strong encryption and a password.

To install VIM in Linux:

Vim is available in the repositories of most major distributions. 

So, use your distribution package manager to get installed.

For Debian based systems, use apt-get or apt package manager to install vim.

$ sudo apt-get install vim

For RHEL/CentOS based systems, use yum package manager to install vim.

$ sudo yum install vim-enhanced

For Fedora system, use dnf package manager to install vim.

$ sudo dnf install vim-enhanced

For openSUSE system, use zypper package manager to install pass.

$ sudo zypper in vim

For Arch Linux based systems, use pacman package manager to install vim.

$ sudo pacman -S vim

Create and Run a Perl Script in Linux Mint - How to perform this task ?

This article covers how to create and execute a Perl script in Linux Mint 20. Moreover, if Perl is not installed on your system already, then we have even shared with you the method of installing it on your system and also ensuring if its interpreter exists there or not.

Perl is a programming language that can be used to perform tasks that would be difficult or cumbersome on the command line. Perl is included by default with most GNU/Linux distributions. 

PERL- Practical Extraction and Reporting Language (not an official acronym), is a stable and cross-platform language and was created by Larry Wall. 

Perl is an open source, general-purpose, interpreted language. Programs written in Perl are called Perl scripts. 

Perl supports both Procedural language and Object Oriented language and has powerful built-in support for text processing and have a collection of third-party modules. Perl language is mainly used for Web Applications, System Administration, Batch Processing, Applications which involving text processing and most command line applications. 

To run a Perl script in Unix:

1. Find the interpreter/executors path. In this case its /usr/bin/perl or /usr/bin/env perl.

2. Add it to the first line of the file as #!/usr/bin/perl .

3. Give execute permission to the file chmod +x example.pl.

Features of Perl language:

1. Perl takes the best features from other languages, such as C, awk, sed, sh, and BASIC, among others.

2. Perls database integration interface DBI supports third-party databases including Oracle, Sybase, Postgres, MySQL, and others.

3. Perl works with HTML, XML, and other mark-up languages.

4. Perl supports Unicode.

5. Perl supports both procedural and object-oriented programming.

6. Perl interfaces with external C/C++ libraries through XS or SWIG.

7. Perl is extensible.

8. The Perl interpreter can be embedded into other systems.

To install Perl in Linux:

1. Before proceeding with the installation of Perl in your Linux system, please have a check Perl is installed or not on your Linux system by running the below command:

# perl -v

2. Download the zipped source code available for Unix/Linux by running the below command:

# wget https://www.cpan.org/src/5.0/perl-5.28.1.tar.gz

3. After download the zip file runs the below commands to extract and install Perl:

# tar -xzf perl-5.28.1.tar.gz

# cd perl-5.28.1

# ./Configure -de


# make test

# make install

How to write your Perl script in Linux?

You can write your Perl script in a text file and the text file should have the extension '.pl'. 

To run your Perl script run the below command.

#perl filename

Eg: #perl hello.pl

Unzip Files in Linux - How to perform it ?

This article covers how to use the unzip command on the CentOS 8 Linux system.

Also, you will learn various uses of the unzip command through which you can list ZIP archive content and extract files. You can utilize the unzip command according to your needs.

How to Create a ZIP File with the zip Command ?

To create a ZIP file, you need to tell zip the name of the archive file and which files to include in it. 

You don't need to add the ".zip" extension to the archive name, but it does no harm if you do.

To create a file called source_code.zip containing all the C source code files and header files in the current directory, you would use this command:

$ zip source_code *.c *.h

How to Unzip a ZIP File With the unzip Command ?

To extract the files from a ZIP file, use the unzip command, and provide the name of the ZIP file. 

Note that you do need to provide the ".zip" extension.

$ unzip source_code.zip

To Unzip on the Linux command line:

The simplest option that will extract the contents to current directory:

$ unzip backup.zip

To change the target directory for extracted material, use -d option followed by the desired directory:

$ unzip backup.zip -d ./restore-directory

To preview contents of zip file:

$ unzip -l backup.zip

If you don't want to unzip the whole file, then add the specific files to extract at the end:

$ unzip backup.zip file1 subdirectory/file2

The inverse of the above command. Unzip every file EXCEPT the ones specified after the -x modifier:

$ unzip backup.zip -x file1 subdirectory/file2

Unzipping a password protected file:

$ unzip -p mypassword backup.zip

Different Methods to Find Your Private IP Address in Linux Mint 20 ?

This article covers different methods to quickly find the IP address of your #Linux Mint system. 

The simplest way to check the ip address of linux Mint, when using the bash shell is typing the command ifconfig. 

On typing the ifconfig you will not only be provided with the ip address, but also the mac address, subnet mask and other information. 

The following commands will get you the private IP address of your interfaces:

1. ifconfig -a.

2. ip addr (ip a).

3. hostname -I | awk '{print $1}'.

4. ip route get 1.2.

5. nmcli -p device show.

What is the #ipconfig command for Linux?

ifconfig(interface configuration) command is used to configure the kernel-resident network interfaces. It is used at the boot time to set up the interfaces as necessary. 

After that, it is usually used when needed during debugging or when you need system tuning.

Methods to Log Out of Linux Mint 20 ?

This article will guide you on methods to logout from the Linux #Mint. Based on your convenience, you can use either the keyboard shortcut or the system menu to logout from your session. When you use a terminal or if you log in to an #Ubuntu system via #SSH, you open a shell session. If you want to logout from your session, you simply exit the #shell. This is why the exit command is equivalent to log out command in Linux.

To switch users in #Linux:

The su command lets you switch the current user to any other user. 

If you need to run a command as a different (non-root) user, use the –l [username] option to specify the user account. 

Additionally, su can also be used to change to a different shell interpreter on a go.

How to create and run a Perl script in Debian 10 ?

This article will guide you on steps to create your first #Perl #script and execute it in Debian 10. Here you will learn the basic method of creating and running a simple Perl script. Once you manage to learn this, you can use Perl scripting for lots of other programmatically complex problems.

To run a Perl script:

1. Write and Run Your First Script. All you need to write Perl #programs is a text editor.

2. Write Your Script. Create a new text file and type the following exactly as shown: #!usr/bin/perl.

3. Run Your Script. Back at the command prompt, change to the directory where you saved the Perl script.

Steps to save a file in Linux command line

This article will guide you on how to use the #cat #command to display or create a new file on #Linux. To save a file, you must first be in Command mode. Press Esc to enter Command mode, and then type :wq to write and quit the file. The other, quicker option is to use the keyboard shortcut ZZ to write and quit.

How to Install sudo on OpenSUSE to execute commands as root ?

This article will guide you on how to use the root user on #OpenSUSE Linux and the sudo command.To use sudo, you need to install and configure sudo on the OpenSUSE #Linux server. The #sudo command allows you to run #programs with the security privileges of another user (by default, as the #superuser). Using the #sudoers file, system administrators can give certain users or groups access to some or all commands without those users having to know the root password.

How to use and run bash aliases over ssh based session

This article will guide you on how to run commands and bash shell aliases on a remote machine using the ssh command.