Linux Terminal Check stdin, stdout and stderr

When we want to check whether current terminal is attached to stdin, stdout and stderr streams or not, we can use the below codes. I tried with piping, and redirection so both works well.

As seen in below 6 usages, stdin is not listed in output of commands except first one. Because stdin is used by piping or redirection.

$  ([ -t 0 ] && echo stdin; [ -t 1 ] && echo stdout; [ -t 2 ] && echo stderr; echo hello)

$ echo hello | ([ -t 0 ] && echo stdin; [ -t 1 ] && echo stdout; [ -t 2 ] && echo stderr; cat)

$ ([ -t 0 ] && echo stdin; [ -t 1 ] && echo stdout; [ -t 2 ] && echo stderr; cat) <<<"hello"

Continue reading

Linux Bash: Language Basics

I will not write all story here but people were using Teleprinter (Teletypewriter, Teletype, TTY) from 1830s and 1840s. As seen in the following pictures, it was an electromechanical device used for communicating text over telegraph lines etc. There wasn't any monitor, output was written in a paper. Some models were creating punched tape for data storage (either from typed input or from data received from a remote source) and read back such tape for local printing or transmission.

Nowadays, we use computers with monitor and operating system but Linux still uses TTY concept under the hood 🙂

You can find some diagrams below relation with Terminal Emulator and TTY

Teletypewriter(Teletype, Teleprinter or TTY)
A restored 1930s Teletype is now a Linux TTY
A Teletype Model 32 ASR used for Telex service
Video terminals like the DEC VT-100 (1978) made teletypes obsolete as computer I/O devices
Terminal Emulator (Pseudo type writer or PTY)
Each Terminal Emulator window attached to separate TTY as shown in the above screenshot.
Continue reading

GitHub clone all repositories

After you join an organization, you will need to clone all git repositories in your machine probably. 🙂

So first follow this post to create a ssh key in your machine and put in github then you can clone all repositories for any user.

if you have any authentication issue, then create an access token from github, copy and paste instead of {acceess-token} in the following code.

curl -u {access-token}:x-oauth-basic -s | grep ssh_url | awk -F '"' '{print $4}' | xargs -n 1 -P 4 git clone

In order to learn github API endpoint urls, use the following code.


To learn more details about official GitHub REST API v3, use the following link.

Bash Shortcuts

CTRL + AMove to the start of the line.
CTRL + EMove to the end of the line.
CTRL + BMove back one character.
CTRL + FMove forward one character.
CTRL + DDelete one character after cursor.
CTRL + HDelete one character after cursor.
CTRL + UDelete from the cursor to the beginning of the line.
CTRL + KDelete from the cursor to the end of the line.
CTRL + WDelete from the cursor to the start of the word.
!!Execute last command in history.
!nExecute nth command in history.
!$Last argument of last command.
!^First argument of last command.