Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.

Slides:



Advertisements
Similar presentations
By: Tony Andrews.  Linux directory ordering system  Navigating and creating directories ◦ Listing directories and files ◦ Creating directories ◦ Changing.
Advertisements

Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Working with Files How to create, view, copy, rename and print files.
©Colin Jamison 2004 Introduction to Linux Colin Jamison.
Lab6 CPCS361 I.Mona Alshehri. Working with Files and Directories Creating files Create a file with the cat command type the command cat > name_of_file.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
Chapter 5 Accessing Files and Directories. How Directories Get Created OS installation: usr, dev, etc, export, kernel and others places to store installation.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Linux Installation and Administration Lesson 2 Tutor: George Papamarkos.
Learning basic Unix command IT 325 operating system.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Unix Basics Chapter 4.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Third Edition
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Chapter Two Exploring the UNIX File System and File Security.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
Chapter 1 : The Linux System Part 2 Lecture 2 11/14/
Unix Commands PowerPoint Presentation developed for LS 560 Information Technology online class - University of Alabama by Debey Sklenar TENacious Cohort.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
Linux+ Guide to Linux Certification, Third Edition
Introduction to Programming Using C An Introduction to Operating Systems.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
Linux Stuff Last Update Copyright 2014 Kenneth M. Chipps Ph.D. 1.
Learning basic Unix command It 325 operating system.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
CMSC 104, Version 8/061L03OperatingSystems.ppt Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Chapter 11 Command-Line Master Class
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
CSE 374 Programming Concepts & Tools
Introduction Paul Flynn
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Presentation transcript:

Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux and Unix Programming tools for more information

MAN Pages man - format and display the on-line manual pages manpath - determine user's search path for man pages SYNOPSIS man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M pathlist] [-P pager] [-S section_list] [section] name... DESCRIPTION man formats and displays the on-line manual pages. If you specify section, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification, so that you can do man./foo.5 or even man /cd/foo/bar.1.gz. See below for a description of where man looks for the manual page files.

Man man Man –k command Info command Example, man ls gives you: NAME ls, dir, vdir - list contents of directories SYNOPSIS ls [-abcdefgiklmnopqrstuxABCFGLNQRSUX178] [-w cols] [-T cols] [-I pattern] [--all] [--escape] [-- directory] DESCRIPTION This manual page documents the GNU version of ls, with color extensions. dir and vdir are versions of ls with different default output formats. These programs list each given file or directory name.

-a — all. Lists all the files in the directory, including the hidden files (.filename). The.. and. at the top of your list refer to the parent directory and the current directory, respectively. -l — long. Lists details about contents, including permissions (modes), owner, group, size, creation date, whether the file is a link to somewhere else on the system and where its link points. -F — file type. Adds a symbol to the end of each listing. These symbols include / to indicate a to indicate a symbolic link to another file; and * to indicate an executable file. -r — reverse. Lists the contents of the directory from back to front. -R — recursive. This option lists the contents of all directories below the current directory recursively. -S — size. Sorts files by their sizes.

Notes: Commands in linux have OPTIONS and ARGUEMNTS Coomands may have more than one options, Example ls –al or ls –l -a Press the [space-bar] if you want to see another page, type [q] if you want to quit reading to search through science.txt for the word 'science', type Search in MAN pages: type a forward slash [/] followed by the word to search /science As you can see, it finds and highlights the keyword. Type [n] to search for the next occurrence of the word

Understanding pathnames The path either Relative or Absoulte Absolute paths begin always in “/” Absolute paths tells Linux to start at the top of the directory tree (/) and change to certain directroy. A path is absolute if the first character is a /. Otherwise, it is a relative path. Using absolute paths allows you to change to a directory from the / directory, which requires you to know and type the complete path. Using relative paths allows you to change to a directory relative to the directory you are currently in, which can be convenient if you are changing to a subdirectory within your current directory.

The following directory tree illustrates how cd operates with different paths. / /directory1 /directory1/directory2 /directory1/directory2/directory3 If you are currently in directory3 and you want to switch to directory1, you need to move up in the directory tree. Executing the command cd directory1 while you are in directory3, will present you with an error message explaining that there is no such directory. This is because there is no directory1 below directory3. To move up to directory1, type: cd /directory1

The command cd.. tells your system to go up to the directory immediately above the one in which you are currently working. To go up two directories, use the cd../.. command. ~ (your home directory) Home directories can also be referred to by the tilde ~ character. It can be used to specify paths starting at your home directory. So typing % ls ~/unixstuff will list the contents of your unixstuff directory, no matter where you currently are in the file system. What do you think % ls ~ would list? What do you think % ls ~/.. would list?

Making Directory and Files  mkdir Dirname  touch filename Copying Files cp (copy) cp file1 file2 is the command which makes a copy of file1 in the current working directory and calls it file2 What we are going to do now, is to take a file stored in an open access area of the file system, and use the cp command to copy it to your unixstuff directory. First, cd to your unixstuff directory. % cd ~/unixstuff Then at the UNIX prompt, type, % cp /vol/examples/tutorial/science.txt. (Note: Don't forget the dot (.) at the end. Remember, in UNIX, the dot means the current directory.) The above command means copy the file science.txt to the current directory, keeping the name the same.

Moving files mv (move) mv file1 file2 moves (or renames) file1 to file2 To move a file from one place to another, use the mv command. This has the effect of moving rather than copying the file, so you end up with only one file rather than two. It can also be used to rename a file, by moving the file to the same directory, but giving it a different name. We are now going to move the file science.bak to your backup directory. First, change directories to your unixstuff directory (can you remember how?). Then, inside the unixstuff directory, type % mv science.bak backups/. Type ls and ls backups to see if it has worked

Moving files mv (move) mv file1 file2 moves (or renames) file1 to file2 To move a file from one place to another, use the mv command. This has the effect of moving rather than copying the file, so you end up with only one file rather than two. It can also be used to rename a file, by moving the file to the same directory, but giving it a different name. We are now going to move the file science.bak to your backup directory. First, change directories to your unixstuff directory (can you remember how?). Then, inside the unixstuff directory, type % mv science.bak backups/. Type ls and ls backups to see if it has worked. Exercise: Rename a file using mv?

Removing files and directories rm (remove), rmdir (remove directory) To delete (remove) a file, use the rm command. As an example, we are going to create a copy of the science.txt file then delete it. Inside your unixstuff directory, type % cp science.txt tempfile.txt % ls (to check if it has created the file) % rm tempfile.txt % ls (to check if it has deleted the file) You can use the rmdir command to remove a directory (make sure it is empty first). Try to remove the backups directory. You will not be able to since UNIX will not let you remove a non-empty directory.

Displaying the contents of a file on the screen clear (clear screen) Before you start the next section, you may like to clear the terminal window of the previous commands so the output of the following commands can be clearly understood. At the prompt, type % clear This will clear all text and leave you with the % prompt at the top of the window. cat (concatenate) The command cat can be used to display the contents of a file on the screen. Type: % cat /etc/passwd As you can see, the file is longer than than the size of the window, so it scrolls past making it unreadable.

More The command more writes the contents of a file onto the screen a page at a time. Type % more /etc/passwd Press the [space-bar] if you want to see another page, type [q] if you want to quit reading. As you can see, less is used in preference to cat for long files.

head The head command writes the first ten lines of a file to the screen. First clear the screen then type % head /etc/passwd Then type % head -5 /etc/passwd What difference did the -5 do to the head command?

tail The tail command writes the last ten lines of a file to the screen. Clear the screen and type % tail /etc/passwd

grep is one of many standard UNIX utilities. It searches files for specified words or patterns. First clear the screen, then type % grep root /etc/passwd As you can see, grep has printed out each line containg the word science. Or has it???? Try typing

Processes and Jobs A process is an executing program identified by a unique PID (process identifier). To see information about your processes, with their associated PID and status, type % ps A process may be in the foreground, in the background, or be suspended. In general the shell does not return the UNIX prompt until the current process has finished executing.

Some processes take a long time to run and hold up the terminal. Backgrounding a long process has the effect that the UNIX prompt is returned immediately, and other tasks can be carried out while the original process continues executing Man ps for more options ps –aux

Running background processes To background a process, type an & at the end of the command line. For example, the command sleep waits a given number of seconds before continuing. Type % sleep 10 This will wait 10 seconds before returning the command prompt %. Until the command prompt is returned, you can do nothing except wait. To run sleep in the background, type % sleep 10 & [1] 6259

The first line in the above example is typed in by the user; the next line, indicating job number and PID, is returned by the machine. The user is be notified of a job number (numbered from 1) enclosed in square brackets, together with a PID and is notified when a background process is finished. Backgrounding is useful for jobs which will take a long time to complete. Backgrounding a current foreground process At the prompt, type % sleep 100 You can suspend the process running in the foreground by holding down the [control] key and typing [z] (written as ^Z) Then to put it in the background, type % bg

Listing suspended and background processes When a process is running, backgrounded or suspended, it will be entered onto a list along with a job number. To examine this list, type % jobs An example of a job list could be [1] Suspended sleep 100 [2] Running netscape [3] Running nedit

To restart (foreground) a suspended processes, type % fg %jobnumber For example, to restart sleep 100, type % fg %1 Typing fg with no job number foregrounds the last suspended process.