Showing posts with label Linux Tools. Show all posts
Showing posts with label Linux Tools. Show all posts

Install docker on Linux (Ubunutu 20 LTS)

Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host. Containers are lightweight because they don’t need the extra load of a hypervisor, but run directly within the host machine’s kernel.

Docker installation steps :

  • First update the system
sudo apt update  
  • Install prerequisite packages which let apt use packages over HTTPS
sudo apt install apt-transport-https \
    ca-certificates curl \
    software-properties-common  
  • Add official GPG keys
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
    sudo apt-key add -  
  • Add the docker repository
sudo add-apt-repository \
    "deb [arch=amd64] \
    https://download.docker.com/linux/ubuntu focal stable"  
  • Update newly added repository
sudo apt update  
  • Now installing docker engine
sudo apt-get install docker-ce docker-ce-cli containerd.io
  • Add the docker daemon to run on startup
sudo systemctl status docker  

The output will look like this


  • Testing the docker engine
sudo docker run hello-world

Output :

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:e7c70bb24b462baa86c102610182e3efcb12a04854e8c582838d92970a09f323
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

Runnning the docker command without sudo :

  • First Add your username into the docker group
sudo usermod -aG docker ${USER}
  • Now to apply the changes login to the user and confirm that user will be added to the docker group by
su - ${USER}
id -nG

Thats it, now Log-out and re-login then run below command

docker run hello-world
Read more »

Install GO in UNIX/LINUX Environment

Go is a statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Follow the below steps to install it on you Linux/Unix Box :

  1. Download it from https://golang.org/dl/
$ curl -sSL https://golang.org/dl/goX.XX.X.linux-amd64.tar.gz -o goX.XX.X.linux-amd64.tar.gz

replace the X.XX.X with current version.

  1. Extract the downloaded file to /usr/local
$ sudo tar -C /usr/local -xzf goX.XX.X.linux-amd64.tar.gz
  1. Add the path /usr/local/go/bin to the environment variable, and for that just add the below lines to your .bashrc file, which is located on your home directory ~/.bashrc. Add below lines
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

and now you are good to GO {he he !!}. Test the setup with go version

$ go version  
go version go1.15.3 linux/amd64

thats it.


Read more »

vim plugins installation and some basic .vimrc configuration

Installing plugin manager Pathogen

Run below commands:
 $ mkdir -p ~/.vim/autoload ~/.vim/bundle
 $ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
Add below lines to ~/.vimrc file :
 execute pathogen#infect()
 syntax on
 filetype plugin indent on
Installing NERDTREE plugin:

Commands :
 $ cd ~/.vim/bundle
 $ git clone https://github.com/scrooloose/nerdtree.git
Add below lines to ~/.vimrc file :
 map <F2> :NERDTree<CR>
 autocmd StdinReadPre * let s:std_in=1
 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
To open the NERDTREE pane press F2.

Using language Templates in vim :

Create templates folder on ~/.vim folder
 $ mkdir ~/.vim/templates
 $ cd ~/.vim/templates
Now create template files on ~/.vim/templates/ directory. Some examples of template files are as follows :
Read more »

How to Copy/Sync Files and Directories with Rsync in Linux : A Beginners Guide to Rsync

Rsync is a very flexible network-enabled syncing tool. It is a powerful tool that facilitates the transfer and synchronization of data between both local and remote systems. Rsync stands for "remote sync". It uses an algorithm that minimizes the amount of data copied by only moving the portions of files that have changed.
Read more »

Rar for Beginners : How to use Rar utility to Compress Files in Linux/Unix Based Systems

Rar is a command line tool to compress files and directories. It is the Linux port of the command line version of WinRAR. RAR is a proprietary archive file format that supports data compression, error recovery and file spanning. It was developed by a Russian software engineer, Eugene Roshal  and the RAR software is licensed by win.rar GmbH. The name RAR stands for Roshal Archive. The filename extensions used by RAR is .rar.
Read more »

Tar Archiver for Beginners : How to use tar to Archive Files/Directories in Linux/Unix Based Systems

Tar is a command line tool for Archiving files and directories. It is a widely used command line tool to create backup archives (collection of files and directories). Tar stands for Tape Archive, and sometimes referred to as tarball. The tar archive have as extension of '.Tar'.
Read more »

xz for Beginners : How to use xz to Compress Files in Linux/Unix Based Systems

xz is a general purpose data compression tool which uses LZMA/LZMA2 compression algorithms to compress files. This algorithm has a greater compression ratio than gzip and bzip2, which makes it a great format when we need to store data on limited disk space. But it takes significantly longer to do the compression. For instance, with the heavy compression flags on a fairly large file, gzip may require around half a minute, bzip2 might be somewhere around a minute, and xz may take around four or five minutes, but the decompression time is relatively good. It creates smaller files. This compression tool was first released in 2009, and the compressed file xz has extension of '.xz'.
Read more »

Bzip2 for Beginners : How to use Bzip2 to Compress Files in Linux/Unix Based Systems

Bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm to compress files. The data format BZIP2 was created for the compression of single or concatenated files. Structure and usage of BZIP2 are similar to the older GZIP format. BZIP2 was developed as alternative to GZIP and offers improved compression.
Read more »

Gzip for Beginners : How to use Gzip to Compress Files in Linux/Unix Based Systems

Gzip (GNU Zip) is a command line tool used to compress and/or expand files. It comes with most of the Linux/Unix based Operating Systems. Gzip is a free software replacement for the compress program used in early Unix systems, intended for use by the GNU Project. gzip was created by Jean-Loup Gailly and Mark Adler. The compression method used by "gzip" is known as Lempel-Ziv (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times. If, in case if the compressed file name is too long for its file system, gzip truncates it.
Read more »

Wget for Beginners : How to use wget in Linux/Unix Based Systems

Wget is a command-line downloader for Linux and UNIX environments. It is very powerful and versatile tool used for retrieves content from web servers and websites. Wget is freely available package and license is under GNU GPL License. With wget we can download files or even entire website. It supports the download protocols (HTTP, HTTPS, FTP and, FTPS).  It helps users to download huge chunks of data, multiple files and to do recursive downloads. Main feature of Wget of it’s robustness, and it also works well in slow or unstable network connections. Some of the features of wget are resuming of downloads, bandwidth control, authentication handling etc.
Read more »