Introduction to Linux
Introduction to Linux
Introduction to Linux
Overview
Intended Audience
cumulusnetworks.com
Course Agenda
cumulusnetworks.com
Learning More About Linux
Linux.com http://www.linux.com/learn/tutorials
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
cumulusnetworks.com
Linux Distributions
cumulusnetworks.com
Linux Kernel
cumulusnetworks.com
Linux Architecture
3rd Party
SPACE
Librarie
USER
OS Customer /
s Tools Application
s
System
KERNEL
SPACE
Hardware
cumulusnetworks.com
Hierarchical File System
cumulusnetworks.com
Directory Roles
user files
log files
/
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
myfile.txt
cumulusnetworks.com
Path Names
home
Absolute Path: Relative Path:
/home/cumulus/myfile.txt cumulus myfile.txt
cumulusnetworks.com
Linux Shells
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
cumulusnetworks.com
Displaying the Current Directory
cumulus@leaf1$ pwd
/home/cumulus
cumulusnetworks.com
Changing Directories
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
./testdir:
total 4.0K
-rw-r--r-- 1 cumulus cumulus 20 Sep 14 03:05 testfile3.txt
cumulusnetworks.com
Viewing Hierarchical Directories
of the current |
|
|-- policy.conf
`-- policy.d
directory in a visual |
|
|-- 00control_plane.rules
`-- 99control_plane_catch_all.rules
cumulusnetworks.com
Using Special Characters
cumulusnetworks.com
Creating a Directory
cumulusnetworks.com
Moving Files
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
cumulusnetworks.com
Displaying the Contents of a Large File
cumulusnetworks.com
Reading the Top of a File
cumulusnetworks.com
Reading the End of a File
cumulusnetworks.com
Searching for Strings in a File
cumulusnetworks.com
Accessing a Remote System
cumulusnetworks.com
Transfering Files to Another System
cumulusnetworks.com
Man Pages
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
cumulusnetworks.com
Users
useradd –m rocket
✗
sudo useradd –m rocket ✔
cumulusnetworks.com
Controlling sudo Access
cumulusnetworks.com
Changing Your Password
cumulusnetworks.com
Understanding Permissions
Group
File type
-rwxrwxrwx
User Other
cumulusnetworks.com
Understanding Permissions
-rwxrwxrwx
cumulusnetworks.com
Permissions Examples
cumulusnetworks.com
Changing File Permissions
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
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
cumulusnetworks.com
Managing Services
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
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
cumulusnetworks.com
Formatting /etc/network/interfaces Entries
cumulusnetworks.com
Defining eth0 in /etc/network/interfaces
cumulusnetworks.com
Defining eth0 in /etc/network/interfaces
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
Optional IP address(es)
cumulusnetworks.com
Displaying Port State for all Interfaces and Specific Interfaces
cumulusnetworks.com
Verifying IP Connectivity with ping
cumulusnetworks.com
Verifying IP Connectivity with traceroute
cumulusnetworks.com
Verifying IP Routes with ip route
cumulusnetworks.com
Displaying the System ARP Cache
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
cumulusnetworks.com
The nano Help Screen
cumulusnetworks.com
Common nano Commands
Managing Files
Key Sequence Action
<ctrl>-o Save the current file
Note: <meta> is the <alt>, <meta>, or <esc> key, depending on the user’s keyboard mapping.
cumulusnetworks.com
The vi Text Editor
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
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