Using Linux Commands 2 Lab#5. Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z.

Slides:



Advertisements
Similar presentations
Using Linux Commands Lab 4 1. Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching.
Advertisements

Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
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
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
CS 497C – Introduction to UNIX Lecture 4: Understanding the UNIX Command Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
Using Linux Commands 2 Lab#5
Shell Script Examples.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
EMT 2390L Lecture 2 Dr. Reyes. Outline What is the Shell Basic commands Linux Filesystem System commands.
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.
Introduction to Shell Script Programming
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Unix Basics Chapter 4.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 8 Shell.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
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.
Workbook 6 – Part 2 The Bash Shell
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Chapter 4 LINUX Shells. Table 4.1 Shell Locations and Program Names.
Lab 3 + Using the Terminal 1. "Under Linux there are GUIs (graphical user interfaces). where you can point and click and drag, and hopefully get work.
Customizing the Shell Environment. UNIX Shells Two characteristics of shells –Interactive: prompts ($) and waits for your response/requests –Noninteractive:
Chapter Six Introduction to Shell Script Programming.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
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.
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
Compunet Corporation Introduction to Unix (CA263) Your Environment By Tariq Ibn Aziz Dammam Community College.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
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+ Guide to Linux Certification, Second Edition
Linux Administration Working with the BASH Shell.
Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up.
1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full.
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.
Prepared by: Eng. Maryam Adel Abdel-Hady
System Programming and administration CS 308
Using Linux Commands Lab 3.
Using the Terminal Lab 3+.
John Carelli, Instructor Kutztown University
(Chapter 2) John Carelli, Instructor Kutztown University
CSCI The UNIX System Shell Startup and Variables
UNIX Reference Sheets CSE 2031 Fall 2010.
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Module 6 Working with Files and Directories
Introduction to Bash Programming, part 3
Presentation transcript:

Using Linux Commands 2 Lab#5

Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z ). Options -r Reverse normal order(reverse alphabetical Z-A 9-0). -n Sort in numeric order(Sorts by the beginning of the number at the beginning of the line.)(A-Z 0-9) -nr Sort in reverse numeric order(9-0 Z-A) Note that this command does not sort the actual file, it just displays the sorted output on your terminal. 2

Sequential commands To run a sequence of commands type several commands on the same command line and separating them with semicolons(;) $ mkdir ng ; cd ng ; touch tom 6

date commands Change or set current date and time. Syntax date [date or time string ] Examples Show current date & time Set date to 2001-Mar-15 Set date as well as time $ date $date --date=“ ” 7 $date --date=“ :59 AM”

Locating commands Commands resides in directories. The path consists of a list of directories that are checked sequentially for the commands you enter.(When you type a command to run, the system looks for it in the directories specified by PATH in the order specified) To display all command’s paths To display the command’s locations -a ( if the command reside in several location ) Directory ContentDirectory Contains common Linux user commands such as ls, sort/bin Contains a variety of other user and administrative commands./usr Contains administrative commands./sbin $ echo $PATH /usr/local/bin:/bin:/usr/bin:usr/X11R6/bin:/home/chris/bin 9 $ type command Graphical commands (that are used with GUIs) The last directory shown is the bin directory in the user's home directory.

If you know the directory that contains the command you want to run, one way to run it is to type the full path to that command. For example, you run the date command from the /bin directory by typing: $ /bin/date Of course, this can be inconvenient, especially if the command resides in a directory with a long name. The better way is to have commands stored in well-known directories, and then add those directories to your shell's PATH environment variable. The path consists of a list of directories that are checked sequentially for the commands you enter. To see your current path, type the following: $ echo $PATH/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/ho me/chris/bin The results show the default path for a regular Linux user. Directories in the path list are separated by colons. Most user commands that come with Linux are stored in the /bin, /usr/bin, or /usr/local/bin directories. Graphical commands (that are used with GUIs) are contained in /usr/bin/X11 and /usr/X11R6/bin directories. The last directory shown is the bin directory in the user's home directory.

Common shell environment variables $HOME: $HOME: your home directory $PATH: $PATH: list of directories used to find commands. $BASH: $BASH:Contains the full path name of the bash command. $PS1: $PS1: Sets the value of your shell prompt. $MAIL: $MAIL: This is the location of your mailbox file. $PWD: $PWD: This is the directory that is assigned as your current directory. $OLDPWD: $OLDPWD: The directory that was the working directory before you changed to the current working directory. $RANDOM: $RANDOM: Accessing this variable causes a random number to be generated. $UID: $UID: The user ID number assigned to your user name. 12

Rerunning commands: command line completion $ echo $PA $ ls ~/uben $ ty 14 Some of the values you can type partially :  Environment variables text begin with $  User name text begin with ~  Commands, aliases, or function text begin with regular char.

Rerunning commands: command line recall  Type a command line  shell’s history list  history file To view history list: Run command number (!command number) Run previous command $ history $ history 8 $ !22 15 $ !! The last 8 commands, including history 8 If the command # 22 is pwd  pwd will be run

Setting your prompt: $ export PS1=“[\t \w] \$” [20:26:32 /var/spool] $ 18 Prompt consists of a set of characters that appear each time the shell is ready to accept a command. \[ precedes a sequence of nonprinting characters. \] Follows a sequence of nonprinting characters. \t prints the current time in hours, minutes, and seconds. \w display the full path to the current working directory. \$ shows the user prompt ($).

Adding Alias makes it possible to launch any command or group of commands by entering a pre-set string of characters. it allows a user to create simple names or abbreviations (even consisting of just a single character) for commands regardless of how complex the original commands are and then use them in the same way that ordinary commands are used. $ alias p=‘pw d; ls -al’ $ alias rm =‘rm –i’ $ unalias p $ alias del=‘rm –I’ $ alias copy=‘cp’ $ alias rename=‘mv’ $ alias md=‘mkdir’ 20 -i  interactive. With this option, rm prompts for confirmation before removing any files. Use the command unalias to remove alias

The order in which the shell checks for commands 1- Aliases— Names set by the alias command that represent a particular command and a set of options. (Type alias to see what aliases are set.) 2- Shell reserved word — Words that are reserved by the shell for special use. Many of these are words that you would use in programming- type functions, such as do, while, case, and else. 3- Function — A set of commands that are executed together within the current shell. 4- Built-in commands — A command that is built into the shell. 5- File system commands — This is a command that is stored in and executed from the computer's file system. (These are the commands that are indicated by the value of the PATH variable.)