QUICK START BASIC LINUX AND G++ COMMANDS. Prepared By: Pn. Azura Bt Ishak



Similar documents
Lab 1 Beginning C Program

CS 103 Lab Linux and Virtual Machines

Linux Overview. Local facilities. Linux commands. The vi (gvim) editor

Command Line Crash Course For Unix

Tutorial Guide to the IS Unix Service

1 Basic commands. 2 Terminology. CS61B, Fall 2009 Simple UNIX Commands P. N. Hilfinger

Lab 1: Introduction to C, ASCII ART and the Linux Command Line Environment

Running your first Linux Program

Linux Labs: mini survival guide

Introduction to the UNIX Operating System and Open Windows Desktop Environment

Chapter 1: Getting Started

Unix Guide. Logo Reproduction. School of Computing & Information Systems. Colours red and black on white backgroun

Setting up Radmind For an OSX Public Lab

Tutorial 0A Programming on the command line

Creating a Simple Visual C++ Program

ICS 351: Today's plan

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

Lab 1: Introduction to the network lab

CPE111 COMPUTER EXPLORATION

New Lab Intro to KDE Terminal Konsole

Lab 5 Managing Access to Shared Folders

Working with H-drive, I-drive, and DropBox Files Online

Introduction to Mac OS X

CSIL MiniCourses. Introduction To Unix (I) John Lekberg Sean Hogan Cannon Matthews Graham Smith. Updated on:

Extreme computing lab exercises Session one

Basic Hadoop Programming Skills

Using SVN to Manage Source RTL

Command-Line Operations : The Shell. Don't fear the command line...

Unix the Bare Minimum

Open Source Computational Fluid Dynamics

Command Line - Part 1

SQL Server 2005: Report Builder

How To Archive s On Groupwise On A Pc Or Mac Or Mac (For Mac) On A Mac Or Ipad (For Pc Or Ipa) On An Ipa Or Mac) (For Ipa).Com (For Pb

INASP: Effective Network Management Workshops

PuTTY/Cygwin Tutorial. By Ben Meister Written for CS 23, Winter 2007

Using SVN to Manage Source RTL

User Manual for Data Backups

Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002)

Getting Started with Citrix Remote Connectivity Service

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Recommended File System Ownership and Privileges

Code::Blocks Student Manual

Getting Started with the Cadence Software

Birmingham Environment for Academic Research. Introduction to Linux Quick Reference Guide. Research Computing Team V1.0

Introduction to Eclipse

NSave Table of Contents

Introduction to Linux operating system. module Basic Bioinformatics PBF

Kernel. What is an Operating System? Systems Software and Application Software. The core of an OS is called kernel, which. Module 9: Operating Systems

Group Mail Lists. Group Mailing Lists. Populating a Global Mail Lists 4. The Problem 6. The Solution 8. Scheduling Regular Updates 17

Installing and Using No Machine to connect to the Redhawk Cluster. Mac version

Using Karel with Eclipse

INSTALLING MALTED 3.0 IN LINUX MALTED: INSTALLING THE SYSTEM IN LINUX. Installing Malted 3.0 in LINUX

University of Toronto

Unix Primer - Basic Commands In the Unix Shell

Subversion Integration for Visual Studio

USB HSPA Modem. User Manual

If you are planning to work from home or your laptop, there are several things you need to have access to:

1 Introduction. 2 Project Browser. 3 FlowStone Editor

5 Minute Lessons. epub with Pages

Levels 1, 2 & 3 Family Edition. How to Download the Core Software from the Website

Operating Systems. Study this screen display and answer these questions.

What is File Management. Methods for Categorizing Data. Viewing Data on a Computer

Using a login script for deployment of Kaspersky Network Agent to Mac OS X clients

Introduction to Operating Systems

An Introduction to Using the Command Line Interface (CLI) to Work with Files and Directories

Creating a Java application using Perfect Developer and the Java Develo...

A Crash Course on UNIX

Visual Studio 2008 Express Editions

You must have at least Editor access to your own mail database to run archiving.

Graphical Environment Tool for Development versus Non Graphical Development Tool

Model 288B Charge Plate Graphing Software Operators Guide

CMSC 216 UNIX tutorial Fall 2010

Installing and Running MOVES on Linux

1. Downloading. 2. Installation and License Acquiring. Xilinx ISE Webpack + Project Setup Instructions

The Einstein Depot server

Contents. Using Web Access Managing Shared Folders Managing Account Settings Index... 39

Installing Proview on an Windows XP machine

Apache Configuration

Hadoop Basics with InfoSphere BigInsights

Paperless Meeting Software Installation Instructions

USEFUL UNIX COMMANDS

How to install Radiance on your computer via a virtual machine

einstruction CPS (Clicker) Instructions

Jolly Server Getting Started Guide

SSH and Basic Commands

WinSCP PuTTY as an alternative to F-Secure July 11, 2006

Adobe Marketing Cloud Using FTP and sftp with the Adobe Marketing Cloud

NAS 109 Using NAS with Linux

JORAM 3.7 Administration & Monitoring Tool

Beyond Windows: Using the Linux Servers and the Grid

Installing Virtual Coordinator (VC) in Linux Systems that use RPM (Red Hat, Fedora, CentOS) Document # 15807A1-103 Date: Aug 06, 2012

Getting Started with VMware Fusion. VMware Fusion for Mac OS X

TestManager Administration Guide

Installing Sun's VirtualBox on Windows XP and setting up an Ubuntu VM

Stored Documents and the FileCabinet

STATISTICA VERSION 10 STATISTICA ENTERPRISE SERVER INSTALLATION INSTRUCTIONS

**If the box does not automatically pop up, see the next page.

Transcription:

QUICK START BASIC LINUX AND G++ COMMANDS Prepared By: Pn. Azura Bt Ishak FTSM UKM BANGI 2009

Content 1.0 About UBUNTU 1 2.0 Terminal 1 3.0 Basic Linux Commands 3 4.0 G++ Commands 23

1.0 ABOUT UBUNTU Ubuntu is a community developed, Linux-based operating system that is perfect for laptops, desktops and servers. It contains all the applications you need - a web browser, presentation, document and spreadsheet software, instant messaging and much more. (referred in http://www.ubuntu.com/) 2.0 TERMINAL Linux commands will be written through UBUNTU's inside the terminal. Step 1: Click Terminal Icon such as below. Click this Terminal icon Figure 1: User Interface of UBUNTU Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 1

Step 2: The window of terminal will display such as the figure 2 below. Figure 2: Terminal window Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 2

3.0 BASIC LINUX COMMANDS 1) pwd to find the name of working directory. The example below (/home/pelajar) shows that you're in pelajar directory which it is located inside the home directory Check or view the current directory Figure 3: pwd command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 3

2) ls to list the files and directories You can see the list of files and directories inside pelajar directory or folder. The files must be followed by the format (eg. book.make, lab.cpp), meanwhile any directory or folder didn't have any format (eg. Desktop, Documents). List and check any files or other directories in the current directory Figure 4: ls command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 4

The same thing you can view directories and files in graphic based if you click places menu and click icon Home Folder such as below. You can see the directories seem like in the booklet based meanwhile files seem like a single paper. This graphical based is more easier compare to command based BUT since this lesson is about commands, so we'll focus on that particular topic. Places Menu List and check any files or other directories in the current directory using file browser Figure 5: File browser in UBUNTU Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 5

3) mkdir to create a directory (mkdir Directory) Step1: Let's try creating your own directory. In the following example, the name of directory is mylab. You have to make sure the name of directory doesn t have any format such as try.cpp, pwd.png or others. And please AVOID any spacing of the directory name such as my Lab. If you still want to separate two wording together, you may put underscore such as my_lab. Creating a new directory Figure 6: mkdir command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 6

Step 2: Now, let s check either the directory of mylab is already inside pelajar directory by typing ls command. In the following figure 7, you can see that mylab directory is already there. It means your directory has been successful built. Check directory of mylab mylab directory Figure 7: Checking the directory using ls command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 7

4) cd to change your working directory (cd Directory) Step 1: If you want to store any files or directories in your own directory, you should open first the directory. It seems like if you want to put something in the drawer, for sure you should open first the drawer, the you can put anything inside the drawer. In the figure 8 below, we try to open the directory of mylab by using command cd. If you want to open the previous directory, you can just typing cd command without following by the name of directory. Open mylab directory Figure 8: cd command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 8

Step 2: Now, let s check either this directory have any files or other directories by using command ls. Logically, since this is a new directory, so for sure it is empty right??? You can see there is nothing display such as the figure 9 below. Open mylab directory. Check the files or other directories inside mylab directory. No list files and directories proof that the directory of mylab is empty. Figure 9: Checking the contents of the directory using ls command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 9

5) gedit text editor (gedit File.cpp) Step1: Open any text editor such as gedit followed by the file name of try.cpp which the format of *.cpp is a C++ format file. You can also use pico text editor. In this example, we will use gedit text editor because its more colorful text based compare to pico. Open mylab directory. Open gedit text editor followed with the file name of try.cpp Figure 10: gedit command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 10

Step2: Gedit text editor will display such as the figure 11 below. You can type any text including C++ programming in this gedit text editor. Figure 11: gedit text editor Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 11

Step 3: Now, let s try typing any simple coding of C++ such as below. Click save once you finish typing the coding and close the file for the moment. Figure 12: Simple C++ programming in gedit text editor Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 12

Step 4: Go back to the terminal, and check the file of try.cpp by using command ls. You can see the file will display in the terminal such as figure 13. Open mylab directory Check the files or other directories inside mylab directory. Open gedit text editor Check the file of try.cpp Figure 13: Checking the file in the directory using ls command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 13

6) cat to view a file's content thorough the terminal (cat File.cpp) You can see the file's content will display directly through the terminal without opening the file using gedit text editor. But you may NOT edit the contents at all. The cat command just want to help user to identify, recheck or reconfirm the contents faster and easier of the specific file. Display the content inside the file through the terminal Figure 14: cat command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 14

7) (a) cp to copy file (cp currentfile.cpp newfile.cpp) You may copy from the current file try.cpp to a new file name try2.cpp. Then, let s check the file of try2.cpp whether it's already existed or not by using ls command. Copy try.cpp to a new file name try2.cpp Check the new file name of try2.cpp Figure 15: cp command (copy file) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 15

(b) cp to copy file into directory (cp File.cpp Directory) You may copy file of try.cpp and put inside the specific directory mylab2. You should create first a new directory of mylab2 using the previous command mkdir. Open the new directory of mylab2 by using cd command and type ls command to check whether the file of try.cpp is already existed or not. Create new directory of mylab2 Copy try.cpp into mylab2 Open mylab2 Check the file of try.cpp in mylab2 directory Figure 16: cp command (copy file into directory) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 16

(c) cp to copy directory (cp -R currentdirectory newdirectory) You can copy from the current directory mylab2 to a new directory mylab3. If you're in mylab2 directory, make sure go back to the previous directory of pelajar by using cd command without following any directory name. Then open back mylab directory by typing cd mylab. Check the current file name of try.cpp Copy mylab2 to a new directory of mylab3 Check the directory of mylab3 Figure 17: cp command (copy directory) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 17

8) (a) mv to rename file (mv currentfile.cpp newfile.cpp) You can move or rename any current file name to a new file name. In this example, try to rename try.cpp to a new file name of test.cpp. Check the current file name of try.cpp Change the name file of try.cpp to test.cpp Check the new file name of test.cpp Figure 18: mv command (rename file) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 18

(b) mv to move files into the directory (mv File.cpp Directory) You can move more than one file into the specific directory. In this example, let s move two files test.cpp and try2.cpp into the directory of mylab3. Check test.cpp & try.cpp are outside mylab3 Move test.cpp & try.cpp into mylab3 Open mylab3 Check test.cpp & try.cpp are inside mylab3 Figure 19: mv command (move file into directory) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 19

(c)mv to move directory into another directory (mv Directory1 Directory2) You also can move the directory into any specific directory. In this example, let s try to move mylab3 directory into the mylab2 directory. current directories; mylab2 & mylab3 Move mylab3 into mylab2 Open mylab2 Check mylab3 is inside mylab2 Figure 20: mv command (move directory into another directory) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 20

9) (a) rm to delete files (rm File.cpp) You can delete more than one file using rm command. In this example, let s try to delete both of the files try.cpp and test.cpp in mylab3 directory. Open mylab3 Delete try.cpp & test.cpp Check try.cpp and test.cpp have been deleted or not. Figure 21: rm command (delete file) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 21

10) (b) rm to delete directories (rm -r Directory) You also can delete more than one directories using rm -r command. In the example below, let s try to delete mylab3 directory which it inside mylab2 directory. You can also delete more than one directory together. Open mylab2 Check mylab3 inside mylab2 Delete mylab3 Check mylab3 has been deleted or not Figure 22: rm command (delete directory) Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 22

3.0 G++ COMMANDS : COMPILING AND EXECUTING FILE OF C++ PROGRAMMING 1) g++ to compile C++ programming file (g++ File.cpp) Step1: If the program has any syntax error, you have to identify the error. In the example below, the program have error in line 6 which the expected symbol of ; was missing. compile error Figure 23: g++ command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 23

Step 2: Open the file back in gedit text editor and make some correction on that particular error. Save the file and compile again using g++ command in the terminal. add symbol ; Figure 24: Edit the C++ programming in gedit text editor Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 24

2)./a.out to execute file of C++ programming If your coding don't have any syntax error, you should execute the file using./a.out command. Thus, it will display the output of your program such as the figure 25 below. compile output execute Figure 25:./a.out command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 25

3) make -f to compile several source files of C++ programming (make -f makefile) Step1: If you want to compile more than one source file of C++ programming, make f command is the better solution. In this example, let s create 3 files in the same directory; main.cpp, statement.cpp and statement.h such as in figure 26-28. header file Figure 26: main.cpp contains main() and this file depends on statement.h Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 26

header file Figure 27: statement.cpp implementation for class and this file depends on statement.h Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 27

Figure 28: statement.h header file for class Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 28

Step2: Before compiling, you have to create the file of makefile using gedit text editor such as below. In this example, the name file of makefile is lab. A makefile is basically a script that guides the make utility to choose the appropriate program files that are to be compiled and linked together. (referred: http://searchenterpriselinux.techtarget.com/sdefinition/0,,sid39_gci283986,00.html). To avoid any errors in makefile, please use Tab key to space the compiling command such as in the figure 29. Make sure all the files including makefile must be put into the same directory or folder. Use Tab key Use Tab key Use Tab key Use Tab key Figure 29: makefile script Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 29

Step 3: Open the terminal, and start compiling (make f makefile) Compiling makefile No syntax errors Figure 30: make f command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 30

Step 4: Type ls command and you will see the 2 objects files (main.o and statement.o) and 1 execute file (try) will be automatic generated for you. Object file Execute file Object file Figure 31: Checking the objects and execute files using ls command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 31

Step 5: Finally, execute the file. (./executefile) In the figure 32, the execute file name is try. So, the command should be./try. You will see the output of Welcome to UKM will be display through the terminal. Execute file Output Execute command Figure 32: Execute command Quick Start Basic Linux and G++Commands Prepared by Pn. Azura Ishak Page 32