Devops tutorials and examples

Linux – number of cpus (lscpu)

Command lscpu to find number of cpus on linux $ lscpu lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 32 On-line read more

Display keys added to ssh-agent using ssh-add

To display keys added to ssh-agent using ssh-add, run the following commands. Lists fingerprints of all identities currently represented by the agent $ ssh-add -l read more

Linux – ssh agent forwarding when using bastion host

When using a bastion host (or Jumpbox) to connection to production server using ssh private keys, ssh agent forward can be used. The main advantage read more

Linux – how to create swap partition

Step to create swap partition on Ubuntu Linux. It should work on any other Linux also. Create storage file (say 4GB) using fallocate for swap read more

Linux – how to create a large file like 1GB

Sometimes we need a large file with any content on Linux. This may be needs for benchmarking and testing purpose. Here are some ways to read more

Linux/Unix – find inode number of a file

To find the inode number of a file on Linux/Unix the following approaches can be used. Find inode using ls $ ls -i file1.txt 412882 read more

Linux/Unix – truncate a large log file without deleting it

Sometimes we need to truncate (make it size 0) a large opened file by a running process (e.h. php error log, apache error logs, custom read more

Linux – command to check swap size

Swap space is the area on a hard disk which is part of the Virtual Memory. Swap space temporarily holds memory pages that are inactive. read more

How to setup password less git push for github

You can use user and password based authentication to push git changes to GitHub. But it is cumbersome to type user and password with every read more

Generate ssh public key from private key on command line

In case you have lost your ssh public key, you can re-generate it from the private key you have. Here is the command to generate read more

Curl – follow redirects

Curl is fairly handy command line utility to fetch a web page. It can also be used to automate various tasks in bash shell scripts. read more

How to check if a user has password on Linux

Any user created on Linux may or may not have a password. Linux stores passwords in encrypted format in /etc/shadow. Here is quick command line read more

Linux – providing sudo access to a users – some best practices

Giving sudo to a user is frequently occurring activity on Linux. Here are some scenarios and best practices for providing sudo to users on Linux. read more

Linux – how to run a command as different user

Often we need to run a command as different users. Some of these users may not even have a login shell (e.g. www-data on Ubuntu read more

Linux – how to add a user using useradd

Adding a new user on Linux can be easily done on command line using useradd. These are some scenarios and handy commands to add a read more

Linux how to modify a user using usermod

Modifying a user on Linux can be easily done on command line using usermod. These are some scenarios and handy commands to modify a user read more

Linux – how to enable password login on ssh server

By default password based on login may be disabled on you Linux Server. Even though it is better to use private and public key for read more