How to Connect Git to Github?

In this article we will see the process to connect git to GitHub.

How to Connect Git to Github?

Github is a very popular version control system. We can use it to store our local git commits and access them anywhere with an internet connection.

To push a repo to github

  • Visit github.com
  • Login with your credentials
  • Click the new repository button which will bring you to a page like this

How to Connect Git to Github_Pic1

  • After filling in the required fields create the repository
  • Now click “Push an existing repository”
  • In the git terminal on your machine
    $ git remote add origin https://github.com/username/new_repo

$ git remote add origin https://github.com/username/new_repo

  • Enter your password then set the branch to main
    $ git branch -M main

● Enter your password then set the branch to main $ git branch -M main

  • Push the branch

        $ git push -u origin master

How to connect git to Github

  • After successful pushing, we will have

Git Discarding Local Changes & Skipping the Staging Area

In this article we will see how to discard local changes and how to skip the staging area.

Git Discarding Local Changes & Skipping the Staging Area

We will learn 2 things in this article

  1. Discard local changes
  2. Skip staging area

So let’s see one by one.

Discard Local Changes:

Some time we might need to discard the changes and go back to the previous version of the code. To do that we will create a new file and commit.

$ cat>file_name 

Use the above command to create a file and add some text to it. After we are done, use ctrl+S to save it.

Git Discarding Local Changes & Skipping the Staging Area_One

Content in the file. (Opened new_file.txt)

Git Discarding Local Changes & Skipping the Staging Area_Two

Now commit the changes using

 $ git commit -am

Git Discarding Local Changes & Skipping the Staging Area_Three

Let’s remove and add some other lines to the txt file.

Git Discarding Local Changes & Skipping the Staging Area_Four

Now we can see the changes using

$ git status -s

We can see that there are some changes made to the file we created.

Now we want to restore this file to its previous version(where it was empty). To do so we need to use the command

$ git restore file_name
Git Discarding Local Changes & Skipping the Staging Area_Five

This should restore our file back. Now when we check the status again

$ git status -s

To confirm let’s see the text file contentsGit Discarding Local Changes & Skipping the Staging Area_Six

Skip staging area:

Staging area is the place where all modified files are shown. That is why it is not advisable to skip the staging area but if you are sure that there are no unnecessary files you can skip them.

Normally we would add the files to the staging area using

$ git add

Git Discarding Local Changes & Skipping the Staging Area_Seven

And then we commit the changes using

$ git commitGit Discarding Local Changes & Skipping the Staging Area_EightHowever to skip the staging area we can do it by directly committing

Use the command

$ git commit -a

This will push all the files

To add the message use the command

$ git commit -am “message” Git Discarding Local Changes & Skipping the Staging Area_Nine

How to Create a Git Repo?

In this article we are going to see how we can create a git repo.

How to Create a Git Repo?

There can be two cases while creating a git repo.

  1. Creating a new repo from scratch
  2. Creating a repo from an existing directory

To create a new repo from scratch follow the below steps-

  • Create a new directory from the menu or by using the command.
    $ mkdir dir_name

This will create a directory in the working folder with the name specified.

How to Create Git Repo_Pic1

  • Navigate into the new directory using the command
    $ cd dir_name

How to Create Git Repo_Pic2.png

  • Now to create a repo use the command
    $ git init

How to Create Git Repo_Pic3.png

This will create a git repo in that directory. From there you can add files to the git repo.

  • After adding your files commit by the command
     $ git commit

How to Create Git Repo_Pic4

Now, to create a repo for a pre-existing project,

  • Navigate into the directory using cd command
  • Now to create the repo use the command
    $ git init
  • Add the files to the repo using
    $ git add
  • Commit the changes using
    $ git commit

Power supply not recognized by M-series router

Some power supplies for M7i and M10i might contain an incorrectly programmed I2C ID.
As a result the following errors appear in the show chassis alarms output:

  user@M10i-re0> show chassis alarms 
  2 alarms currently active
  Alarm time               Class  Description
  2006-11-29 16:21:22 GMT  Major  PEM 0 Unrecognized for the platform
  2006-11-29 16:21:22 GMT  Major  PEM 1 Unrecognized for the platform

A fix is provided in JUNOS  8.1R2, 8.2R1 and higher JUNOS releases.

Below there is an example with a step by step procedure:

  • Check which power supplies are not recognized properly:
    root@Junos-re0> show chassis alarms
    2 alarms currently active
    Alarm time               Class  Description
    2006-11-29 16:21:22 GMT  Major  PEM 0 Unrecognized for the platform
    2006-11-29 16:21:22 GMT  Major  PEM 1 Unrecognized for the platform
  • Go to the shell and and use command su to change to super-user:
    root@Junos-re0> start shell
    % su
    Password:
    root@Junos-re0%
  • Use the smbc command to read out the currently (incorrectly) programmed I2C ID for PSU in slot 0:
    root@Junos-re0% smbc -g 2 -o 5 0x56 1
    Read from bus address 0x56 returns:
    0x06
  • Re-program the I2C ID for the same PSU:
    root@Junos-re0% smbc -w -g 2 -o 5 0x56 0x0E
  • Verify if the the I2C IC has been programmed correctly
    root@Junos-re0% smbc -g 2 -o 5 0x56 1
    Read from bus address 0x56 returns:
    0x0e
  • Repeat the same steps for PSU in slot 1
    root@Junos-re0% smbc -g 3 -o 5 0x56 1
    Read from bus address 0x56 returns:
    0x06
    root@Junos-re0% smbc -w -g 3 -o 5 0x56 0x0E
    root@Junos-re0% smbc -g 3 -o 5 0x56 1
    Read from bus address 0x56 returns:
    0x0e
  • Go back to the shell

root@Junos-re0% exit

Chassisd has to be restarted in order to have the alarms cleared.  Note: This is traffic affecting! :

root@Junos-re0> restart chassis-control
Chassis control process started, pid 3553
Verify that no PSU related alarms are active:

root@Junos-re0> show chassis alarms
No alarms currently active

linkFlapErrDisabled error on cisco Nexus5500 Chassis

linkFlapErrDisabled error on cisco Nexus5500 Chassis

We observed linkFlapErrDisabled error on interface ethernet 2/7 on cisco Nexus5548 Chassis. We observed link flap on this interface 1week(s) 1day(s) ago.

Nexus5500# sh interface ethernet 2/7
Ethernet2/7 is down (linkFlapErrDisabled)
Dedicated Interface
Hardware: 1000/10000 Ethernet, address: 002a.6a18.ff86 (bia 002a.6a18.ff86)
MTU 1500 bytes, BW 10000000 Kbit, DLY 10 usec
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA
Port mode is trunk
auto-duplex, 10 Gb/s, media type is 10G
Beacon is turned off
Input flow-control is on, output flow-control is on
Rate mode is dedicated
Switchport monitor is off
EtherType is 0x8100
Last link flapped 1week(s) 1day(s)
Last clearing of "show interface" counters never
32 interface resets
30 seconds input rate 0 bits/sec, 0 packets/sec
30 seconds output rate 0 bits/sec, 0 packets/sec
Load-Interval #2: 5 minute (300 seconds)

We did a shut and unshut on this port and we see interface 2/7 up.

Nexus5500# conf t
Enter configuration commands, one per line. End with CNTL/Z.
Nexus5500(config)# int ethernet 2/7
Nexus5500(config-if)# shu
Nexus5500(config-if)# no shut
Nexus5500(config-if)# end
Nexus5500# sh interface ethernet 2/7
Ethernet2/7 is up
Dedicated Interface
Hardware: 1000/10000 Ethernet, address: 002a.6a18.ff86 (bia 002a.6a18.ff86)
MTU 1500 bytes, BW 10000000 Kbit, DLY 10 usec
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA
Port mode is trunk
full-duplex, 10 Gb/s, media type is 10G
Beacon is turned off
Input flow-control is on, output flow-control is on
Rate mode is dedicated
Switchport monitor is off
EtherType is 0x8100
Last link flapped 00:00:04
Last clearing of "show interface" counters never
33 interface resets
30 seconds input rate 0 bits/sec, 0 packets/sec
30 seconds output rate 0 bits/sec, 0 packets/sec
Load-Interval #2: 5 minute (300 seconds)

Bash Concatenate Strings

Concatenation is one of the most popular and used string operations. String concatenation is just a decorative programming word for joining strings collectively by adding one string to another string’s end.

In this article, we will show how to concatenate strings in bash.

Concatenating Strings

The easiest way to concatenate two or more string variables is to write them one after another:

VAR1= "Hi,"
VAR2=" Lucky"
VAR3="$VAR1 $VAR2"
echo "$VAR3."

The last line will echo the concatenated string:

Output:
Hi, Lucky

With the help of a literal string, you can concatenate one or more variable:

VAR1= "Hey,"
VAR2= "${VAR1}World."
echo "$VAR2."
Output:
Hello, World

The example over variable VAR1 is enveloped in curly braces to guard the variable name against surrounding characters. When another valid variable-name character reflects the variable, you must have it in curly braces ${VAR1}.

To circumvent any word splitting or globbing issues, you should regularly try to use double quotes nearby the variable name if you want to suppress variable addition and special treatment of the backslash character rather than dual-use single quotes.

Bash does not separate variables by “type”; variables are used as integer or string depending on contexts. You can also combine variables that contain only digits.

VAR1 = "Hey, "
VAR2 = 2
VAR3 = " Lucky"
VAR4 = "$VAR1$VAR2$VAR3"
echo "$VAR4"
Output:
Hey, 2 Lucky

Concatenating Strings with the += operator

The other way of concatenating strings in bash is by combining variables or literal strings to a variable using the += Operator:

VAR1="Hey, "
VAR1+=" Lucky"
echo "$VAR1."
Output:
Hey, Lucky

The following sample is using the += operator to concatenate strings in bash for loop :

languages. sh
VAR= ""
for ELEMENT in 'Oxygen' 'Helium' 'Lime' 'Belly'; do
VAR+="${ELEMENT} "
done
echo "$VAR."
Output:
Oxygen Helium Lime Belly

Conclusion
Concatenating string variables is one of the most significant operations in Bash scripting. After reading this article, you should have a good knowledge of how to concatenate strings in bash. If you have any queries related to bash connect with us now.

show system snapshot media internal – To know Junos installed in both partitions of Ex

root> show system snapshot media internal 
fpc0:
--------------------------------------------------------------------------
Information for snapshot on       internal (/dev/da0s1a) (primary)
Creation date: Feb 11 23:59:41 2013
JUNOS version on snapshot:
  jbase  : ex-12.3R1.7
  jcrypto-ex: 12.3R1.7
  jdocs-ex: 12.3R1.7
  jroute-ex: 12.3R1.7
  jswitch-ex: 12.3R1.7
  jweb-ex: 12.3R1.7
Information for snapshot on       internal (/dev/da0s2a) (backup)
Creation date: Feb 6 08:38:13 2013
JUNOS version on snapshot:
  jbase  : 11.3R4.2
  jcrypto-ex: 11.3R4.2
  jdocs-ex: 11.3R4.2
  jroute-ex: 11.3R4.2
  jswitch-ex: 11.3R4.2
  jweb-ex: 11.3R4.2

{master:0}
root>

 

show system storage partitions – Show active partitions information for the boot media in juniper ex

root> show system storage partitions 
fpc0:
--------------------------------------------------------------------------
Boot Media: internal (da0)
Active Partition: da0s1a         <<<< Ex is currently booted from slice da0s1a partition
Backup Partition: da0s2a
Currently booted from: active (da0s1a)

Partitions information:
  Partition  Size   Mountpoint
  s1a        183M   /         
  s2a        184M   altroot   
  s3d        369M   /var/tmp  
  s3e        123M   /var      
  s4d        62M    /config   

{master:0}
root>

system services

root@Ex# set ?
Possible completions:
+ apply-groups         Groups from which to inherit configuration data
+ apply-groups-except  Don’t inherit configuration data from these groups
> dhcp                 Configure DHCP server
> finger               Allow finger requests from remote systems
> ftp                  Allow FTP file transfers
> netconf              Allow NETCONF connections
> outbound-ssh         Initiate outbound SSH connection
> service-deployment   Configuration for Service Deployment (SDXD) management application
> ssh                  Allow ssh access
> subscriber-management  Subscriber management configuration
> telnet               Allow telnet login
> tftp-server          Allow TFTP file transfers in default routing instance
> web-management       Web management configuration
> xnm-clear-text       Allow clear text-based JUNOScript connections
> xnm-ssl              Allow SSL-based JUNOScript connections
[edit system services]
root@Ex# set

Issues with logging into EX Virtual Chassis via SSH and HTTP

What needs to be checked if we encounter issues with SSH and HTTP in Juniper Ex?

SSH:

If you encounter issues with users not able to log into the switch using SSH, check the following:

  •     SSH is properly configured. root@EX# set system services ssh
  •     No firewall filters for TCP blocking SSH.  root@EX3# show firewall
  •     Make sure the directory /var/empty exists.

SSH access in juniper ex

If the directory is not present, create it as shown below:

%cd /var
%mkdir empty

HTTP/HTTPS:

If you are not able to log in to the switch using HTTP/HTTPS, check the following.

  •     HTTP is properly configured under web management.

root@SW1# set system services web-management http

  •     No firewall filters blocking http traffic.
  •     Clear the cache in the browser

The directory structure for HTTP is as below:

/packages/mnt/jweb-ex-9.5R2.7/jail/var/etc