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
Linux find – ignore case in name
When using linux find, -iname can be used to match name pattern and ignore case (case insensitive). $ fine . -iname “pattern” Example Find all read more
find – exclude directory or file pattern
To exclude directory or file pattern when using find on command line one can use ! -name “pattern_to_exclude” Example To exclude a directory using its 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
wget handy commands
Here are some handy wget commands wget with username and password In case a url requires simple web auth, one can use the following wget read more
Linux Systemd/Systemctl quick start guide
Systemd is an init system used by new Linux distributions like Ubuntu 15 and Centos 7. It intends to replace Sysv init (Ubuntu, Centos, etc) read more
Linux iptables and ip6tables examples
Linux iptables is a user-space application program that allows a system administrator to configure the tables provided by the Linux kernel firewall (implemented as different read more
Rsync – exclude specific file extension
To exclude a specific file extension (say .class) we can use –exclude “*.class” (or –exclude=”*.class”). Note that it can be repeated multiple time. $ rsync read more
Git – show log of one user’s commits
git log –author=pattern can be used to show log of all users matching a specific pattern. $ git log –author=Ram $ git log –author=”R.*m” // read more
Remove passphrase from ssh private key
To remove passphrase from an existing key, we can use ssh-keygen with -p option. Here is an example which changes passphrase of private rsa key read more
How to check if an ssh key has passphrase
To check if an ssh key has passphrase, one can look for the presence of ENCRYPTED string in the private key. Here is an example 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 – find listening ports
Sometimes it is useful to find what ports a machine is listening to. Here are some use cases: Display listening ports $ netstat -l Display read more
Enable query log without restarting mysql on Linux
Steps to enable mysql query log on mysql server without restarting mysql process on Ubuntu and other Linux flavours. Set general_log_file on SQL prompt: SET read more
Linux du – find disk usage of directories or files
Linux du command can be used to find disk usage of files and directories. Here are some handy du commands on Ubuntu Linux (or any 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
Rsync – show progress and transfer rate
Rsync can be used to sync directories and files from one machine to another. Sometime we want to see the progress and transfer speed. For 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
Linux/Unix – How to go to previous directory
To go to previous working directory is Linux is a frequently occurring need. These are two ways to achieve it: Using dash (-) $ cd read more