0% found this document useful (0 votes)
6 views

Introduction to Linux

This document is an introductory course on Linux designed for beginners, covering fundamental concepts, common commands, and the structure of the Linux operating system. It includes sections on Linux history, architecture, file systems, and essential commands for file management and system navigation. Additional resources for learning Linux and instructions for downloading a Linux environment are also provided.

Uploaded by

dpsguard-buy8922
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Introduction to Linux

This document is an introductory course on Linux designed for beginners, covering fundamental concepts, common commands, and the structure of the Linux operating system. It includes sections on Linux history, architecture, file systems, and essential commands for file management and system navigation. Additional resources for learning Linux and instructions for downloading a Linux environment are also provided.

Uploaded by

dpsguard-buy8922
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

v

Introduction to Linux

Overview
Intended Audience

This course is designed for students who have little


or no experience with Linux.

By the end of this introductory course, students


will:
 Understand the fundamentals of Linux
 Log in to and operate a Linux operating system

cumulusnetworks.com
Course Agenda

 Section 1: What is Linux?


 Section 2: Common Commands
 Section 3: Users & Groups
 Section 4: Processes & Services
 Section 5: Basic Networking
 Section 6: Editing Tools

cumulusnetworks.com
Learning More About Linux

Additional tutorials and help with Linux can be


found from these sources:
Resource Link
Linux.org http://www.linux.org/categories/linux-tutorials.52/

Linux.com http://www.linux.com/learn/tutorials

Linux Foundation http://training.linuxfoundation.org/free-linux-training/linux-training-videos

nixCraft http://www.cyberciti.biz/faq/

cumulusnetworks.com
Downloading a Linux Environment

 http://www.cumulusnetworks.com/cumulus-vx/download
cumulusnetworks.com
Thank You!

© 2015 Cumulus Networks. CUMULUS, the Cumulus Logo, CUMULUS NETWORKS, and the Rocket Turtle Logo (the “Marks”) are trademarks and service marks of Cumulus
Networks, Inc. in the U.S. and other countries. You are not permitted to use the Marks without the prior written consent of Cumulus Networks. The registered trademark Linux® is
used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. All other marks are used under fair use or license from
their respective owners.

cumulusnetworks.com
v

Introduction to Linux

Section 1: What is Linux?


History of Linux

Linux was developed in 1991 by a Finnish student


named Linus Torvalds
“Linux” is actually just the kernel itself
Combined with the GNU project, which lacked a kernel,
to produce a complete and free (open source)
operating system
Linux and the GNU project together is commonly
referred to as “GNU/Linux”

cumulusnetworks.com
Linux Distributions

 Because GNU/Linux is open


source, various distributions
(“distros”) have been created
from that source code over the
years

 All of these feature the Linux


kernel

 The User Space in each of these


distros is often quite different,
depending on the needs and
wants of the group creating them

cumulusnetworks.com
Linux Kernel

The kernel is the core of the


Linux operating system
 Translates requests from user
commands and applications Linux
into hardware calls Kernel

 Additional capabilities can be


enabled with additional code
such as drivers and libraries CPU Disk NIC

cumulusnetworks.com
Linux Architecture

Applications run in two distinct areas of system


memory: kernel space and user space

3rd Party

SPACE
Librarie

USER
OS Customer /
s Tools Application
s

System
KERNEL
SPACE

Kernel Drivers Call


Handler

Hardware

cumulusnetworks.com
Hierarchical File System

The file system tree begins with the Root Directory


(“/”) and contains many sub-directories

bin boot home etc root dev usr opt var

cumulus rocket bin sbin

cumulusnetworks.com
Directory Roles

Different file systems hold specific data

user files
log files
/

etc home root usr var

cumulus rocket bin sbin

user commands
configuration files
administrator commands
cumulusnetworks.com
Files in Linux

Everything is a file in a /
Directory

Linux system
Directory: list of other files home dev
Regular file: user or system
disk
data cumulus partition

text file sda4

myfile.txt

cumulusnetworks.com
Path Names

home
Absolute Path: Relative Path:
/home/cumulus/myfile.txt cumulus myfile.txt

Only valid if the user is in


the /home/cumulus
directory
myfile.txt

cumulusnetworks.com
Linux Shells

The shell is a command line interpreter that


provides a user interface for a GNU/Linux operating
system
cumulus@leaf1$ echo $SHELL
/bin/bash
cumulus@leaf1$ echo $BASH_VERSION
4.2.37(1)-release
cumulus@leaf1$ cat helloworld.sh
#!/bin/bash
echo Hello World
cumulus@leaf1$ bash helloworld.sh
Hello World

cumulusnetworks.com
Thank You!

© 2015 Cumulus Networks. CUMULUS, the Cumulus Logo, CUMULUS NETWORKS, and the Rocket Turtle Logo (the “Marks”) are trademarks and service marks of Cumulus
Networks, Inc. in the U.S. and other countries. You are not permitted to use the Marks without the prior written consent of Cumulus Networks. The registered trademark Linux® is
used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. All other marks are used under fair use or license from
their respective owners.

cumulusnetworks.com
v

Introduction to Linux

Section 2: Common Commands


File Naming Conventions

Linux is case sensitive for both commands and file


names

Special characters may have functionality in the


shell
cumulus@leaf1$ ls
helloworld.sh
cumulus@leaf1$ cat helloworld.sh
#!/bin/bash
echo Hello World
cumulus@leaf1$ cat helloworld.SH
cat:helloworld.SH: No such file or directory

cumulusnetworks.com
Displaying the Current Directory

The pwd command is used to output the path of


the current working directory

cumulus@leaf1$ pwd
/home/cumulus

cumulusnetworks.com
Changing Directories

The cd command is used to change the current


working directory

cumulus@leaf1$ pwd
/home/cumulus
cumulus@leaf1$ cd /etc
cumulus@leaf1$ pwd
/etc
cumulus@leaf1$ cd
cumulus@leaf1$ pwd
/home/cumulus

cumulusnetworks.com
Listing Files in a Directory

The ls command is used to list the contents of a


directory
cumulus@leaf1$ ls
testdir testfile1.txt testfile2.txt
cumulus@leaf1$ ls -lhR
.:
total 12K
drwxr-xr-x 2 cumulus cumulus 4.0K Sep 14 03:05 testdir/
-rw-r--r-- 1 cumulus cumulus 7 Sep 14 03:05 testfile1.txt
-rw-r--r-- 1 cumulus cumulus 125 Sep 14 03:05 testfile2.txt

./testdir:
total 4.0K
-rw-r--r-- 1 cumulus cumulus 20 Sep 14 03:05 testfile3.txt

cumulusnetworks.com
Viewing Hierarchical Directories

The tree command cumulus@leaf1$ cd /etc/cumulus/


cumulus@leaf1$ tree

shows the contents |-- acl


| |-- acl.conf

of the current |
|
|-- policy.conf
`-- policy.d

directory in a visual |
|
|-- 00control_plane.rules
`-- 99control_plane_catch_all.rules

hierarchy |-- datapath


| |-- README
| `-- traffic.conf
|-- etc.replace
| |-- lsb-release
| `-- os-release
|-- init
| |-- accton_as4600_54t
...

cumulusnetworks.com
Using Special Characters

*: a wildcard which denotes zero or more characters


cumulus@leaf1$ ls testfile*
testfileA testfileB testfileC

“, ‘, and \: characters which remove (“escape”) the


special meaning of other characters
cumulus@leaf1$ ls "testfile*"
ls: cannot access testfile*: No such file or directory
cumulus@leaf1$ ls testfile\*
ls: cannot access testfile*: No such file or directory
cumulus@leaf1$ ls 'testfile*'
ls: cannot access testfile*: No such file or directory

cumulusnetworks.com
Creating a Directory

 The mkdir command is used to create a new directory


 The –p option makes sub-directories automatically
cumulus@leaf1$ mkdir levelone
cumulus@leaf1$ mkdir levelone/leveltwo
cumulus@leaf1$ mkdir -p levelone/leveltwo/levelthree/levelfour
cumulus@leaf1$ cd levelone/leveltwo/levelthree/levelfour/
cumulus@leaf1$ pwd
/home/cumulus/levelone/leveltwo/levelthree/levelfour
Made automatically using the –p option

 The rmdir command deletes directories


 Only empty directories can be removed
 The –p options removes parent directories
cumulusnetworks.com
Copying Files

The cp command is used to copy a file


 Use the –r option to copy a directory, including its
contents

cumulus@leaf1$ cp directoryA/testing123.txt directoryB/


cumulus@leaf1$ ls directoryB
testing123.txt
cumulus@leaf1$ cp -r directoryB/ directoryC
cumulus@leaf1$ ls
directoryA/ directoryB/ directoryC/
cumulus@leaf1$ ls directoryC
testing123.txt

cumulusnetworks.com
Moving Files

The mv command is used to move or rename a file


or directory
cumulus@leaf1$ ls directoryA
test.txt
cumulus@leaf1$ ls directoryB
cumulus@leaf1$ mv directoryA/test.txt directoryB/
cumulus@leaf1$ ls directoryB
test.txt
cumulus@leaf1$ cd directoryB
cumulus@leaf1$ mv test.txt testing.txt
cumulus@leaf1$ ls
testing.txt
cumulus@leaf1$ mv testing.txt ../directoryA/testing123.txt
cumulus@leaf1$ cd ../directoryA/
cumulus@leaf1$ ls
testing123.txt
cumulusnetworks.com
Deleting Files

The rm command is used to delete a file or directory


 Use the –r option to remove directories and their contents
recursively

cumulus@leaf1$ ls
intro2linux/ levelone/ testdir/ testfile.txt
cumulus@leaf1$ rm testfile.txt
cumulus@leaf1$ ls
intro2linux/ levelone/ testdir/
cumulus@leaf1$ rm -r levelone/
cumulus@leaf1$ ls
intro2linux/ testdir/

cumulusnetworks.com
Displaying the Contents of a File

The cat command is used to display the contents


of a file
cumulus@leaf1$ cat testfile.txt
This is the text in the testfile.txt file!

Output is displayed to standard output, which


defaults to the screen in Linux

cumulusnetworks.com
Displaying the Contents of a Large File

The less command is used output the contents


of a file one screen at a time
cumulus@leaf1$ less /etc/network/interfaces

When used with the pipe character (|), more can


page output from any command
cumulus@leaf1$ ls –lR /etc | less

cumulusnetworks.com
Reading the Top of a File

The head command is used to display the first few


lines of a file
 Displays first 10 lines by default
 Use the –n option to specify how many lines to show
cumulus@leaf1$ head -n 2 /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5), ifup(8)
cumulus@leaf1$

cumulusnetworks.com
Reading the End of a File

The tail command is used to display the last few


lines of a file
 Use the –F option to watch a file being updated in real-time

cumulus@leaf1$ tail -F /var/log/messages


Sep 14 14:33:17 leaf1 : /usr/sbin/smond : : Temp2(MPC8541(CPU) Sensor): state
changed from LOW to OK
Sep 14 16:13:30 leaf1 : /usr/sbin/smond : : Temp2(MPC8541(CPU) Sensor): state
changed from OK to LOW
Sep 14 16:13:42 leaf1 : /usr/sbin/smond : : Temp2(MPC8541(CPU) Sensor): state
changed from LOW to OK

cumulusnetworks.com
Searching for Strings in a File

The grep command searches a file for specified


arguments
cumulus@leaf1$ cat colors.txt
red
blue
purple
cumulus@leaf1$ grep purple colors.txt
purple

grep can be used with the | character to search


standard output for patterns
cumulus@leaf1$ ls -l /etc | grep ssh
drwxr-xr-x 1 root root 4096 Sep 11 07:22 ssh/

cumulusnetworks.com
Accessing a Remote System

ssh (SSH Client) allows users to log into or run a


command on a remote systm
 Based on the Secure Shell (SSH) protocol

remote user name remote host

cumulus@leaf1$ ssh cumulus@leaf2

cumulus@leaf1$ ssh cumulus@leaf2 “ls /home/cumulus/”

cumulusnetworks.com
Transfering Files to Another System

Secure copy (SCP) allows you to transfer files


between hosts
 Based on the Secure Shell (SSH) protocol

remote user name remote host

cumulus@leaf1$ scp testfile1.txt cumulus@leaf2:/home/cumulus/


Password:
testfile1.txt remote directory
100% 258 0.3KB/s 00:00

cumulusnetworks.com
Man Pages

Linux systems have a


built in reference
manual, known as
“man pages”
 The man page to the
right is the result of
entering man man

cumulusnetworks.com
Thank You!

© 2015 Cumulus Networks. CUMULUS, the Cumulus Logo, CUMULUS NETWORKS, and the Rocket Turtle Logo (the “Marks”) are trademarks and service marks of Cumulus
Networks, Inc. in the U.S. and other countries. You are not permitted to use the Marks without the prior written consent of Cumulus Networks. The registered trademark Linux® is
used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. All other marks are used under fair use or license from
their respective owners.

cumulusnetworks.com
v

Introduction to Linux

Section 3: Users and Groups


The Linux Administrative Account - root

The top-level administrator in a Linux system is the


root account
 Also referred to as the root user or superuser
 Should be rarely used, as it has no security restrictions
on it
 The root user can do anything on the system
 May be disabled for security purposes

cumulusnetworks.com
Users

There are two types of users on a Linux system:


 System accounts – used for administrative purposes
 User accounts – allow users and administrators access to
the system
cumulus@leaf1:~$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash System
daemon:x:1:1:daemon:/usr/sbin:/bin/sh accounts
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
...
ntp:x:104:107::/home/ntp:/bin/false
User
snmp:x:105:108::/var/lib/snmp:/bin/false
cumulus:x:1000:1000::/home/cumulus:/bin/bash account

user name home default


user ID group ID directory shell
cumulusnetworks.com
Groups

Groups allow permissions to be assigned to


multiple users simultaneously
cumulus@leaf1:~$ cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
...
sudo:x:27:cumulus,rocket
...

Group name Group members

password Group ID (GID)


cumulusnetworks.com
What is sudo?

sudo allows a user to execute commands as


another user (typically root)

useradd –m rocket

sudo useradd –m rocket ✔

cumulusnetworks.com
Controlling sudo Access

By default, adding a user to the sudo group gives


privileged command access.
cumulus@leaf1:~$ cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
...
sudo:x:27:cumulus,rocket
...

cumulusnetworks.com
Changing Your Password

Use the passwd command to change your password


 Requires your previous password for security
 Can be used by the root user to change any password
without the previous password
cumulus@leaf1$ passwd
Changing password for cumulus.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
cumulus@leaf1$ sudo passwd rocket
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
cumulus@leaf1$
cumulusnetworks.com
File Permissions

Permissions control what actions a user can take


on a file

Permissions can be viewed with the ls –l


command
cumulus@leaf1$ ls -l
size
total 4.0K
-rw-r--r-- 1 cumulus cumulus 5 Sep 14 02:23 testfile.txt

User Group Last File name


Permissions (owner) modified
date

cumulusnetworks.com
Understanding Permissions

Permissions are based on three object types:


 User – the owner of the file
 Group – the set of associated users
 Other – anyone else

Group
File type
-rwxrwxrwx
User Other
cumulusnetworks.com
Understanding Permissions

Permissions allow three actions:


 Read – see the contents of the file
 Write– change the contents of the file
 Execute – run the file as an executable

-rwxrwxrwx
cumulusnetworks.com
Permissions Examples

Which users could take which actions on files with the


following permissions?

 A file marked as rwxrwxrwx belonging to user cumulus


and group users:

 A file marked as rw-r--r-- belonging to user cumulus


and group users:

 A file marked as rw-rw---- belonging to user cumulus


and group users:

cumulusnetworks.com
Changing File Permissions

File and directory permissions can be changed


using the chmod command
 Specify the type of permission to change
• u (user), g (group), o (other), a (all)
 Specify how to change the permission
• + (add), - (delete), = (set)
 Specify which permission to change
• r (read), w (write), x (execute)

cumulusnetworks.com
Example: Changing File Permissions

cumulus@leaf1$ ls –l
total 0
-rw-r--r-- 1 cumulus cumulus 0 Nov 5 12:48 file1.txt
cumulus@leaf1$ chmod g+x,o= file1.txt
cumulus@leaf1$ ls -l
total 0
-rw-r-x--- 1 cumulus cumulus 0 Nov 5 12:48 file1.txt
cumulus@leaf1$ chmod g-x file1.txt
cumulus@leaf1$ ls -l
total 0
-rw-r----- 1 cumulus cumulus 0 Nov 5 12:48 file1.txt
cumulus@leaf1$ chmod a=rw file1.txt
cumulus@leaf1$ ls -l
total 0
-rw-rw-rw- 1 cumulus cumulus 0 Nov 5 12:48 file1.txt

cumulusnetworks.com
Changing File Ownership

The user and group cumulus@leaf1$ ls -l


total 0
ownership of files and -rwx---rw- 1 cumulus cumulus 0 Sep 21 03:20
testfile.txt
directories can be cumulus@leaf1$ sudo chown rocket testfile.txt
modified using the cumulus@leaf1$ ls -l
total 0
chown and chgrp -rwx---rw- 1 rocket cumulus 0 Sep 21 03:20
testfile.txt
commands. cumulus@leaf1$ sudo chgrp users testfile.txt
cumulus@leaf1$ ls -l
 The –R option can be total 0
used to change -rwx---rw- 1 rocket users 0 Sep 21 03:20
ownership recursively testfile.txt

 Requires superuser
privileges
cumulusnetworks.com
Thank You!

© 2015 Cumulus Networks. CUMULUS, the Cumulus Logo, CUMULUS NETWORKS, and the Rocket Turtle Logo (the “Marks”) are trademarks and service marks of Cumulus
Networks, Inc. in the U.S. and other countries. You are not permitted to use the Marks without the prior written consent of Cumulus Networks. The registered trademark Linux® is
used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. All other marks are used under fair use or license from
their respective owners.

cumulusnetworks.com
v

Introduction to Linux

Section 4: Processes and Services


Viewing Processes – ps

The ps command is used to view a list of processes


running on the Linux system
cumulus@leaf1$ ps -ef cumulus
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 22:12 ? 00:00:00 init [3]
root 2 0 0 22:12 ? 00:00:00 [kthreadd]
root 3 2 0 22:12 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 22:12 ? 00:00:00 [kworker/u:0]
root 6 2 0 22:12 ? 00:00:00 [migration/0]
...
root 1961 1 0 22:14 ? 00:00:00 /sbin/mstpd -v2
ntp 2003 1 0 22:14 ? 00:00:00 /usr/sbin/ntpd -p
/var/run/ntpd.pid -g -U0 -c /var/lib/ntp/ntp.conf.dhcp -u 104:107
root 2089 1 0 22:14 ? 00:00:00 /usr/bin/python
/usr/lib/python2.7/dist-packages/clcmd_server.py
cumulus 3873 2957 0 23:04 pts/0 00:00:00 ps -ef
cumulusnetworks.com
Modifying ps

Many options exist for the ps command --


some examples include:
Option Behavior
-f Shows the output in full
format
-e Shows all processes

-u <UID> Shows processes for a


specific user
-p <PID> Shows processes for a
specific process ID (PID)
-C <process_name> Shows processes of a
specific name

cumulusnetworks.com
Managing Services

Services are maintained by daemons, background


processes which maintain the service’s functions

Services can be controlled using the service


command:
service <service name> [ start | stop |
restart]

cumulusnetworks.com
Example: Managing Services

cumulus@leaf1$ ps -C lldpd
PID TTY TIME CMD
2277 ? 00:00:00 lldpd
2299 ? 00:00:01 lldpd
cumulus@leaf1$ sudo service lldpd stop
cumulus@leaf1$ ps -C lldpd
PID TTY TIME CMD
cumulus@leaf1$ sudo service lldpd start
cumulus@leaf1$ ps -C lldpd
PID TTY TIME CMD
24166 ? 00:00:00 lldpd
24184 ? 00:00:00 lldpd

cumulusnetworks.com
Controlling the System

The Linux system can be shut down or restarted


using the shutdown command
 Default behavior is to shutdown the system
 Use the –r option to reboot
 Use a time delay to run the command later
cumulus@leaf1$ sudo shutdown now
Broadcast message from root@leaf1 (pts/0) (Sun Sep 21 18:49:48 2014):

The system is going down for reboot NOW!


cumulus@leaf1$ Connection to leaf1 closed by remote host.
Connection to leaf1 closed.

cumulusnetworks.com
Thank You!

© 2015 Cumulus Networks. CUMULUS, the Cumulus Logo, CUMULUS NETWORKS, and the Rocket Turtle Logo (the “Marks”) are trademarks and service marks of Cumulus
Networks, Inc. in the U.S. and other countries. You are not permitted to use the Marks without the prior written consent of Cumulus Networks. The registered trademark Linux® is
used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. All other marks are used under fair use or license from
their respective owners.

cumulusnetworks.com
v

Introduction to Linux

Section 5: Basic Networking


Configuring the Hostname

Changing the hostname in Linux is a three-step


process:
 Edit the /etc/hostname file
 Assign the new hostname to the 127.0.1.1
address in the /etc/hosts file
 Reboot the switch

cumulusnetworks.com
Formatting /etc/network/interfaces Entries

Bring up interface during boot up


or after sudo ifup -a Interface name

inet type: dhcp, loopback or static


auto <int_name>
iface <int_name> inet <type>
<option> <value>
<option> <value>
...

cumulusnetworks.com
Defining eth0 in /etc/network/interfaces

eth0 – default configuration


dhcp inet type
auto eth0
iface eth0 inet dhcp

cumulusnetworks.com
Defining eth0 in /etc/network/interfaces

eth0 – with IP address

auto eth0
iface eth0 inet static
address 192.168.0.11/24 IP address settings for interface,
only if using static
address 2001:db8::1/32
gateway 192.168.0.1 Install IPv4 and IPv6 default route
gateway 2001:db8::2

cumulusnetworks.com
Defining lo in /etc/network/interfaces

lo – loopback interface


Loopback inet type
auto lo
iface lo inet loopback
address 10.2.1.1/32
address 2001:da8::1/32

Optional IP address(es)

cumulusnetworks.com
Displaying Port State for all Interfaces and Specific Interfaces

cumulus@leaf1$ ip link show


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 08:9e:01:f8:90:7e brd ff:ff:ff:ff:ff:ff
3: swp1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 500
link/ether 08:9e:01:f8:90:80 brd ff:ff:ff:ff:ff:ff
4: swp2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 500
link/ether 08:9e:01:f8:90:80 brd ff:ff:ff:ff:ff:ff
...

cumulus@leaf1$ ip link show dev swp1


3: swp1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 500
link/ether 44:38:39:00:03:c1 brd ff:ff:ff:ff:ff:ff

cumulus@leaf1$ ip addr show dev swp1


3: swp1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 500
link/ether 44:38:39:00:03:c1 brd ff:ff:ff:ff:ff:ff
inet 192.0.2.1/30 scope global swp1
inet6 2001:DB8::1/126 scope global tentative

cumulusnetworks.com
Verifying IP Connectivity with ping

The -I option verifies connectivity through a


specific interface.
cumulus@leaf1:~$ ping -I 10.3.3.1 10.4.4.1
PING 10.4.4.1 (10.4.4.1) from 10.3.3.1 : 56(84) bytes of data.
64 bytes from 10.4.4.1: icmp_req=1 ttl=64 time=0.825 ms
64 bytes from 10.4.4.1: icmp_req=2 ttl=64 time=0.750 ms ...

cumulusnetworks.com
Verifying IP Connectivity with traceroute

traceroute follows a packet to a target to


help determine where the routing fails.
cumulus@leaf1:~$ traceroute www.google.com
traceroute to www.google.com (74.125.239.49), 30 hops max, 60 byte packets
1 fw.cumulusnetworks.com (192.168.1.1) 0.614 ms 0.863 ms 0.932 ms
2 router.hackerdojo.com (157.22.42.1) 15.459 ms 16.447 ms 16.818 ms
3 gw-cpe-hackerdojo.via.net (157.22.10.97) 18.470 ms 18.473 ms 18.897 ms
4 ge-1-5-v223.core1.uspao.via.net (157.22.10.81) 20.419 ms 20.422 ms 21.026 ms
5 core2-1-1-0.pao.net.google.com (198.32.176.31) 22.347 ms 22.584 ms 24.328 ms
6 216.239.49.250 (216.239.49.250) 24.371 ms 25.757 ms 25.987 ms
7 72.14.232.35 (72.14.232.35) 27.505 ms 22.925 ms 22.323 ms
8 nuq04s19-in-f17.1e100.net (74.125.239.49) 23.544 ms 21.851 ms 22.604 ms
...

cumulusnetworks.com
Verifying IP Routes with ip route

ip route show prints the current routing table.


ip route get prints the next hop for a route
cumulus@leaf1$ ip route show
default via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.11

cumulus@leaf1$ ip route get 192.168.0.1/24


192.168.0.1 dev eth0 src 192.168.0.11
cache ipid 0x7b98 rtt 8ms rttvar 12ms cwnd 10

cumulus@leaf1$ ip route get 3.3.3.3


3.3.3.3 via 192.168.0.1 dev eth0 src 192.168.0.11
cache

cumulusnetworks.com
Displaying the System ARP Cache

The arp command manages the kernel’s IPv4


network neighbor cache.
 To display the ARP cache:
cumulus@leaf1:~$ arp -a
? (11.0.2.2) at 00:02:00:00:00:10 [ether] on swp3
? (11.0.3.2) at 00:02:00:00:00:01 [ether] on swp4
? (11.0.0.2) at 44:38:39:00:01:c1 [ether] on swp1

 To delete an ARP cache entry:


cumulus@leaf1:~$ arp -d 11.0.2.2
cumulus@leaf1:~$ arp -a
? (11.0.2.2) at <incomplete> on swp3
? (11.0.3.2) at 00:02:00:00:00:01 [ether] on swp4
? (11.0.0.2) at 44:38:39:00:01:c1 [ether] on swp1

cumulusnetworks.com
Thank You!

© 2015 Cumulus Networks. CUMULUS, the Cumulus Logo, CUMULUS NETWORKS, and the Rocket Turtle Logo (the “Marks”) are trademarks and service marks of Cumulus
Networks, Inc. in the U.S. and other countries. You are not permitted to use the Marks without the prior written consent of Cumulus Networks. The registered trademark Linux® is
used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. All other marks are used under fair use or license from
their respective owners.

cumulusnetworks.com
v

Introduction to Linux

Section 6: Editing Tools


The nano Text Editor

Nano is a text editor that


behaves like a GUI-based
text editor
 Commands are executed by
keyboard shortcuts
 Common commands are
listed at the bottom of the
screen for easy reference

cumulusnetworks.com
The nano Help Screen

Press <ctrl>-g to show all nano commands

cumulusnetworks.com
Common nano Commands

Managing Files
Key Sequence Action
<ctrl>-o Save the current file

<ctrl>-x Exit nano (will prompt if Managing Text


save is needed
Key Sequence Action
<meta>-<ctrl> Copy current line into
buffer
<ctrl>-k Cut current line into buffer

<ctrl>-u Paste from buffer

<ctrl>-w Search for a string or


regex
<ctrl>-\ Search and replace

Note: <meta> is the <alt>, <meta>, or <esc> key, depending on the user’s keyboard mapping.
cumulusnetworks.com
The vi Text Editor

vi is a text editor included with all Linux


distributions
When using vi, the editor is in one of three modes:
 Command mode: all keys on the keyboard map to editor
commands
 Insert mode: the keys on the keyboard work as expected,
allowing users to input text into the file; press the Esc key
to return to command mode
 Command line mode: this mode is entered from
command mode by using the colon (:), allowing
commands to be typed at the bottom of the screen

cumulusnetworks.com
vi Modes
command mode command mode

vi testfile.txt

<esc>
I :wq
insert mode command line mode

cumulusnetworks.com
Common vi Keystrokes

Cursor Movement
Key Sequence Action
<down arrow> or j Move cursor down

<up arrow> or k Move cursor up


Entering Insert Mode
<left arrow> or h Move cursor left
Key Sequence Action
<right arrow> or l Move cursor right i Insert text at cursor
location
a Append text after cursor
location
I Insert text at the
beginning of the line
A Append text to the end of
the line
<esc> Exit insert mode

cumulusnetworks.com
Common vi Keystrokes

Managing Text
Key Sequence Action
x Delete character

dd Delete row
Using Command Line Mode
yy Copy row
Key Sequence Action
4yy Copy 4 rows into buffer :wq Write file and exit
(number can be changed)
p Paste from buffer :q Exit without saving
r Replace character (type in
replacement after)
cw Change word (type in
replacement after)

cumulusnetworks.com
vi Tutorial

cumulusnetworks.com
Thank You!

© 2015 Cumulus Networks. CUMULUS, the Cumulus Logo, CUMULUS NETWORKS, and the Rocket Turtle Logo (the “Marks”) are trademarks and service marks of Cumulus
Networks, Inc. in the U.S. and other countries. You are not permitted to use the Marks without the prior written consent of Cumulus Networks. The registered trademark Linux® is
used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. All other marks are used under fair use or license from
their respective owners.

cumulusnetworks.com

You might also like