Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files...

31
Appendix A Introducti on to Using Linux

Transcript of Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files...

Page 1: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Appendix AIntroduction to

Using Linux

Page 2: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Objectives• Linux introduction• Commands-Line Interface• Files and Directories• Basic Commands

• The password Command• The man Command• The ls Command• The cp Command• The mv Command• The rm Command• The cd Command• The mkdir Command• I/O Redirection and Pipe Operators

• Shell Variables• Text Editing• File Access Permissions• Script Files• Searching Data in Files• Evaluating Expressions• Connecting to a Remote Linux Server, cs3

Dr. Garrido and el al Textbook©2012 Jones & Bartlett Learning, LLC

www.jblearning.com

Page 3: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Connecting to a Remote Linux Server, cs3

• Please refer to Appendix A in the Course Textbook or follow the steps from the link below.

• Download SSH Secure Shell Client • Go to http://uits.kennesaw.edu/students • Go to Software Downloads• After downloading, execute the install program SSH Secure Shell Client (icon will be on your desk top)

Click on the SSH Secure Shell Client

Page 4: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Download SSH Secure Shell Client

• Download the SSH (Secure Shell File Transfer (SFTP)); – from KSU UITS / Software Downloads.

http://uits.kennesaw.edu/students (SSH consist of SSH Secure Shell Client and SSH File Transfer),

• Note: for this course, you need to use SSH Secure Shell Client to login to CS3 server.

• Default: SSH Secure Shell Client icon

will be install on your desktop Windows.

Page 5: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Login to Linux cs3 server

• Click on Profiles folder on the tool bar

• Select Add Profiles • Give a name: cs3• Edit Profiles cs3• Host name:

cs3.kennesaw.edu• User name: • your KSU netid• Ok• Go to Profiles • Select cs3• Enter Password:• Temp password: new123• Login to cs3 server, then• Change password: $passwd

Page 6: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

The CS3 Server

• A Computer Science Department server• All assignments are to be developed on the

CS3 server• Access to CS3 is via a command-level interface

using a ‘terminal’ utility, such as SSH on Windows

Page 7: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Connecting to CS3 Server

• Make sure you are connected to Internet• Start SSH (Secure Shell Client) to connect to a

remote Unix server• Type cs3.kennesaw.edu• Logon to Linux on the CS3 server• Start using the appropriate Linux shell

Page 8: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Window for SSH Shell Client

Page 9: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Logged in to cs3 Linux server

Page 10: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Running Simulation Models on CS3

Use the 'mkdir' command to make a new directory under the current directory, then change to the new directory with the 'cd' command.

$ mkdir myos

$ cd myos•Copy two files from the /home/jgarrido/psim3 directory to your working directory:

– the corresponding simulation model (batch.cpp) – the psim3c script file

$ cp /home/jgarrido/psim3/batch.cpp myos

$ cp /home/jgarrido/psim3/psim3c myos

Page 11: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Steps to Run a Simulation Model on cs3 (Cont.)

• Change to the new directory: $ cd myos• Compile and link the simulation model:

$ ./psim3c batch.cpp

• Run the model (output on the screen): $ ./batch.cpp //FN.ccp

$ ls –lt //to see which file is ready to be exeucted. The list //should show files and executed file (in different color), that the one you need to Run

$./psim3 // follow the file name

$ a.out

• Run the model, redirect the output to a file$ ./a.out |tee res1.txt

• View the output file$ more res1.txt

Page 12: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Steps to Run a Simulation Model on cs3 (Cont.)

• Run the program again to change one or more parameters in the model

• Compile and link again (if necessary)• Run the program again• Get the results in another file• After the third simulation run, exit Unix.• Use SSH File Transfer from your PC to get the

output files

Page 13: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

‘ls’ Command

• List files and subdirectories in current directory or specified directory

$ ls• The long listing is produced with the -l option:

$ ls -l

$ ls -lt | more

Page 14: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

To edit a text file

• To edit a text file (C++ source file), use the “nano” editor. For example, to edit “batch.cpp” type the following command:

• $nano batch.cpp

Page 15: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

‘man’ Command

• To get a short online manual or documentation on the specified command

$ man ls (help with ‘ls’)$ man cd (help with ‘cd’)

The space key shows the next page

Page 16: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Make and Change Directory

• To make a new directory under your current directory:

$ mkdir mydir• To change to a directory:

$ cd mydir (change to mydir)or

$ cd myos (change to myos)

Page 17: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Directories

• The system root directory is denoted as a slash (/)

• An absolute path denotes the position of a file in the file structure

/home/jgarrido/psim3/batch.cpp

• The current working directory is denoted as dot (.), The parent of the current directory as dotdot (..)

Page 18: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Show Current Working

• To display the current working directory:$ pwd

• To return to your home directory:$ cd

Page 19: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

The ‘script’ Command

• Open a new record session (log session) to a text file:$ script mysession.txt

• To terminate the session, type the ‘exit’ command

Page 20: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Introduction to Linux

• Linux is a multiuser, multitasking operating system that is a variant of Unix and preforms many of the same functions.

• Linux is to purchase a Linux distribution, an organized bundle that includes the kernel (core of the operating system) and a large set of utility programs with installation utility.

Dr. Garrido and el al Textbook©2012 Jones & Bartlett Learning, LLC

www.jblearning.com

Page 21: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Introduction to Linux

• A user interacts with Linux using one of several available interface that are grouped into two categories– A text-based command line interface– A graphical user interface (GUI)

• Linux has several graphical user interface available, such as GNU Network Object Model Environment (GNOME) and the K Desktop Environment (KDE)

Dr. Garrido and el al Textbook©2012 Jones & Bartlett Learning, LLC

www.jblearning.com

Page 22: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

What is Linux?

Linux is, in simplest terms, an operating system. It is the software on a computer that enables applications

and the computer operator to access the devices on the computer to perform desired functions. Linux is very similar to other operating systems, such as Windows and OS X.

Linux operating system represented a $25 billion ecosystem in 2008. Since its inception in 1991 and in 2011 earn up to 49 billion.

Linux has grown to become a force in computing, powering everything from the New York Stock Exchange to mobile phones to supercomputers to consumer devices.

Page 23: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Linux Overview Linux is developed collaboratively, meaning no one

company is solely responsible for its development or ongoing support.

Companies participating in the Linux economy share research and development costs with their partners and competitors.

This spreading of development amongst individuals and companies has resulted in a large and efficient ecosystem and unheralded software innovation.

Over 1,000 developers, from at least 100 different companies, contribute to every kernel release.

In the past two years alone, over 3,200 developers from 200 companies have contributed to the kernel--which is just one small piece of a Linux distribution.

Page 24: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Where is Linux

Linux Uses in:Desktop, Laptops, Phones, small devices,

Mainframes, supercomputers Browser like Firefox, servers, Sony TV, Reader, Digital Recording devices.

Many of the popular Web 2.0 services on the Internet, such as Twitter, Linked In, YouTube, and Google all rely on Linux as their operating system. As new web services arrive in the future, Linux will increasingly be the platform that drives these new technologies.

Page 25: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.
Page 26: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Linux Began

On August 25, 1991, a Finn computer science student named Linus Torvalds made the following announcement to the Usenet group comp.os.minux

Torvalds built the core of the Linux operating system, known as the kernel.

A kernel alone does not make an operating system, but Stallman's GNU tools were from a project to create an operating system

Torvalds' matching of GNU tools with the Linux kernel marked the beginning of the Linux operating system as it is known today.

:

Page 27: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.
Page 28: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.
Page 29: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

The term runlevel refers to a mode of operation in one of the computer operating systems that implement Unix System V-style initialization.

Conventionally, seven (7) runlevels exist, numbered from zero to six; though up to ten, from zero to nine, may be used.

S is sometimes used as a synonym for one of the levels. Only one "runlevel" is executed on bootup - run levels are not executed sequentially, i.e. either runlevel 2 OR 3 OR 4 is executed, not 2 then 3 then 4.

"Runlevel" defines the state of the machine after boot. Different runlevels are typically assigned to:• single-user mode• multi-user mode without network services started• multi-user mode with network services started• system shutdown• system reboot

Run Levels Weblink

Page 30: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

KernelAll operating systems have kernels, built around

the architectural metaphor that there must be a central set of instructions to direct device hardware, surrounded by various modular layers of functionality. The Linux kernel is unique and flexible because it is also modular in nature.

Modularity is desirable because it allows developers to shed parts of the kernel they don't need to use. Typically a smaller kernel is a faster kernel, because it isn't running processes it does not need.

Page 31: Appendix A Introduction to Using Linux. Objectives Linux introduction Commands-Line Interface Files and Directories Basic Commands The password Command.

Linux Environments

The windows, menus, and dialog boxes most people think of as part of the operating system are actually separate layers, known as the windowing system and the desktop environment.

These layers provide the human-oriented graphical user interface (GUI) that enables users to easily work with applications in the operating system and third-party applications to be installed on the operating system.

There are tools and code libraries available that let application developers to more readily work with these environments