Skip to main content


Showing posts with the label Linux basic device utility tools

Use tar command to backup in Linux

tar or tape archive is a basic tool that every Linux user should know.

Its syntax is quite different from the traditional copy or move command.

Since tar works from a 'current working directory' perspective.

Traditional syntax for copy or move is source then the destination.

In tar, the syntax is the filename or the path where the backup will be save and the source or the folder to be backed up or archived.

Typing: man tar (at the terminal shows the following)

tar -cf archive.tar foo bar
# Create archive.tar from files foo and bar.

Basically, it's like the destination where the file will be saved and the source or the files that will be archived.

Here's a simple bash script that will append the time and date the tar file was executed to the filename of the tar file.

If the bash script is automated via cron, the filename of the tar file will include the date and time the cron executes the script.

#script begins

NOW=$(date +%Y%m%d%H%M)
echo $NOW
tar -Pczvf   /mnt/o…

Bash check if folder exists

Simple bash script for beginners trying to get their hands wet on bash scripting.
The code below will ask for input and the input should be a string or a folder name.
The script will just do a basic ls and if the folder name is found it will show “The folder is found” or else the next echo statement is displayed.
Instead of simply displaying an echo command a function or another script can be called to execute a process further.
#!/bin/bash # This script will ask for a string or folder name and check whether it is present or not
echo "Enter folder name, followed by [ENTER]:"
read folder_name
ls | grep ^$folder_name && echo "The folder is found" || echo "The folder cannot be found" #Script ends
It’s a one liner evaluation, some sort an if then else in other programming languages, the && statement is executed if the evaluation is true, and if the evaluation is false the || is executed.
The read folder_name line, is the statement that will hold the inp…

Linux basic device utility tools

Knowing the devices in your computer is quite important in order to check what devices are installed or running in the computer
Getting to use Linux or starting to use it may seem daunting for others.
But Linux is awesome aside that its free and open source, in order to get used to it then you have to use it.
How to check installed USB drives or external USB devices in Linux?
How to check what graphic chipset or video chipset your computer is using in Linux?
How to check the audio chipset in your Linux system?
All these questions will pop-up once you start using Linux.
Or how would to check whether the inserted USB thumbdrive or an external USB drive is detected or not.
Well, some Linux distro provides a GUI interface to do it.
But the very basic way to check is to open via the Terminal window.
Or basically the command line in Linux.
ls - or list directory contents is the most basic way to learn on command line
ls will list the files and directories
To issue the commands below, open …