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.

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Working with Files How to create, view, copy, rename and print files.
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.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
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.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
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”
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.
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Working with Files Chapter 5. Display a Calendar Display a calendar for a specific month – cal Display a calendar for a specific year – cal 2000.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Unix Basics Chapter 4.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
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.
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.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
1May 16, 2005 Week 2 Lab Agenda Command Line FTP Commands Review More UNIX commands to learn File name expansion - * Introduction of vi.
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.
Linux Commands C151 Multi-User Operating Systems.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
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).
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.
1 CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
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.
Assignprelim.1 Assignment Preliminaries © 2012 B. Wilkinson/Clayton Ferner. Modification date: Jan 16a, 2014.
UNIX Basics Matt Hayward October 18, 2016 LS560 – Information Technology for information professionals.
GRID COMPUTING.
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.
Tutorial of Unix Command & shell scriptS 5027
slides created by Marty Stepp, modified by Josh Goodwin
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Andy Wang Object Oriented Programming in C++ COP 3330
Lecture 2 Working with Files and Directories
Some Linux Commands.
C151 Multi-User Operating Systems
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Assignment Preliminaries
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Unix : Introduction and Commands
Operating Systems and Using Linux
slides created by Marty Stepp, modified by Jessica Miller
Tutorial of Unix Command & shell scriptS 5027
Andy Wang Object Oriented Programming in C++ COP 3330
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Tutorial Unix Command & Makefile CIS 5027
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
slides created by Marty Stepp, modified by Jessica Miller
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
LPI Linux Certification
Presentation transcript:

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.

Format of UNIX Commands UNIX commands can be very simple one word commands, or they can take a number of additional arguments (parameters) as part of the command. In general, a UNIX command has the following form: UNIX commands can be very simple one word commands, or they can take a number of additional arguments (parameters) as part of the command. In general, a UNIX command has the following form: command options(s) filename(s) The command is the name of the utility or program that we are going to execute. The command is the name of the utility or program that we are going to execute. The options modify the way the command works. It is typical for these options to have be a hyphen followed by a single character, such as -a. It is also a common convention under Linux to have options that are in the form of 2 hyphens followed by a word or hyphenated words, such as --color or -- pretty-print. The options modify the way the command works. It is typical for these options to have be a hyphen followed by a single character, such as -a. It is also a common convention under Linux to have options that are in the form of 2 hyphens followed by a word or hyphenated words, such as --color or -- pretty-print. The filename is the last argument for a lot of UNIX commands. It is simply the file or files that you want the command to work on. Not all commands work on files, such as ssh, which takes the name of a host as its argument. The filename is the last argument for a lot of UNIX commands. It is simply the file or files that you want the command to work on. Not all commands work on files, such as ssh, which takes the name of a host as its argument.

Common UNIX Conventions In UNIX, the command is almost always entered in all lowercase characters. In UNIX, the command is almost always entered in all lowercase characters. Typically any options come before filenames. Typically any options come before filenames. Many times, individual options may need a word after them to designate some additional meaning to the command. Many times, individual options may need a word after them to designate some additional meaning to the command.

Familiar Commands: scp (Secure CoPy) The scp command is a way to copy files back and forth between multiple computers. The scp command is a way to copy files back and forth between multiple computers. Formats for this command: Formats for this command: scp path/local_name scp path/local_name scp path/local_name scp path/local_name Demo with renaming and copying files. Demo with renaming and copying files.

Familiar Commands: ssh (Secure SHell) The ssh command is a way to securely connect to a remote computer. The ssh command is a way to securely connect to a remote computer. Formats for this command: Formats for this command: ssh hostname ssh hostname ssh ssh ssh hostname -l username ssh hostname -l username If you do not specify the username, it will assume that you want to connect with the same username that you have on this local computer. If you do not specify the username, it will assume that you want to connect with the same username that you have on this local computer. Since you have a single username for all computers on the OIT network, you don’t need to explicitly enter a username. Since you have a single username for all computers on the OIT network, you don’t need to explicitly enter a username. But you can give a username, and will need to if your local username is different that your GL username. This might be the case if you are logging on from home and set up your username to be different from what it is on GL. But you can give a username, and will need to if your local username is different that your GL username. This might be the case if you are logging on from home and set up your username to be different from what it is on GL. Demo with connecting with different usernames. Demo with connecting with different usernames.

Familiar Commands: ssh (Secure SHell) You can save a couple of keystrokes if you are on one of the Linux PCs in the labs: You can save a couple of keystrokes if you are on one of the Linux PCs in the labs: You really only need to specify enough of a hostname as you may need. You really only need to specify enough of a hostname as you may need. Linux will automatically attempt to fill out the hostname with “umbc.edu” for you. Linux will automatically attempt to fill out the hostname with “umbc.edu” for you. So if you want to log onto the lightest loaded linux server on gl, you only need to issue the following command... So if you want to log onto the lightest loaded linux server on gl, you only need to issue the following command... ssh linux.gl Or, if you don't care the flavor of UNIX, you can simply type... Or, if you don't care the flavor of UNIX, you can simply type... ssh gl

Familiar Commands: passwd (change PASSWorD) The passwd command changes your UNIX password. The passwd command changes your UNIX password. This command is an example of a “no argument” command. Thus, the format of this command is just the command name itself. This command is an example of a “no argument” command. Thus, the format of this command is just the command name itself.passwd passwd is an interactive command, as once we have typed it, we need to interact with it. passwd is an interactive command, as once we have typed it, we need to interact with it.

Familiar Commands: quota (account QUOTA) The quota command shows you how much storage space you have left in your account. The quota command shows you how much storage space you have left in your account. When we use this command, we have to specify the -v option to get the information for our account. When we use this command, we have to specify the -v option to get the information for our account. The format of this command is: The format of this command is: quota -v

Familiar Commands: oitcleaner (account cleaning tool) The oitcleaner account cleaning tool was developed by the UMBC OIT department. The oitcleaner account cleaning tool was developed by the UMBC OIT department. This command is specific to the UMBC GL systems. This command is specific to the UMBC GL systems. This command takes no options and no filenames, so its format is: This command takes no options and no filenames, so its format is:oitcleaner

Man Pages The man command allows you to access the MANual pages for a UNIX command. The man command allows you to access the MANual pages for a UNIX command. To get additional help on any of the commands listed below, you can always type man name_of_command at the command prompt. To get additional help on any of the commands listed below, you can always type man name_of_command at the command prompt. Examples: Examples: man ssh man ssh man passwd man passwd

Commands ls : lists the contents of a directory ls : lists the contents of a directory l : long directory listing l : long directory listing a : lists all files, including files which are normally hidden a : lists all files, including files which are normally hidden F : distinguishes between directories and regular files F : distinguishes between directories and regular files h : ? Look it up using man h : ? Look it up using man pwd : prints the current working directory pwd : prints the current working directory cd : changes directories cd : changes directories The difference between relative and absolute paths. The difference between relative and absolute paths. Special characters.,.., and ~. Special characters.,.., and ~. mkdir : creates a directory mkdir : creates a directory rmdir : removes a directory (assuming it is empty) rmdir : removes a directory (assuming it is empty) If you get an error that the directory isn’t empty even though it looks empty, check for hidden files. If you get an error that the directory isn’t empty even though it looks empty, check for hidden files.

Commands touch : creates an empty file with the specified name, or if the file already exists it modifies the timestamp. touch : creates an empty file with the specified name, or if the file already exists it modifies the timestamp. rm : removes a file. rm : removes a file. f : force deletion f : force deletion r : recursive deletion r : recursive deletion mv - moves a file, or renames a file mv - moves a file, or renames a file f : forces overwrite, if the destination file exists f : forces overwrite, if the destination file exists cp - copies a file, leaving the original intact cp - copies a file, leaving the original intact f : forces overwrite, if the destination file exists f : forces overwrite, if the destination file exists r : recursive copying of directories r : recursive copying of directories

Commands cat : shows the contents of a file, all at once cat : shows the contents of a file, all at once more : shows the contents of a file, screen by screen more : shows the contents of a file, screen by screen less : also shows the contents of a file, screen by screen less : also shows the contents of a file, screen by screen head : used to show so many lines form the top of a file head : used to show so many lines form the top of a file tail : used to show so many lines form the bottom of a file tail : used to show so many lines form the bottom of a file

Commands lpr : prints a file lpr : prints a file alias : creates an alias for a command. alias : creates an alias for a command. Aliases can be placed in your.cshrc login script. Aliases can be placed in your.cshrc login script. Example: alias rm ‘rm –i’. Example: alias rm ‘rm –i’. date : shows the date and time on the current system date : shows the date and time on the current system who : used to print out a list of users on the current system who : used to print out a list of users on the current system hostname : prints the hostname of the current computer hostname : prints the hostname of the current computer whoami : prints your current username whoami : prints your current username

The UNIX Pipe (|) The pipe (|) creates a channel from one command to another. Think of the pipe as a way of connecting the output from one command to the input of another command. The pipe (|) creates a channel from one command to another. Think of the pipe as a way of connecting the output from one command to the input of another command. The pipe can be used to link commands together to perform more complex tasks that would otherwise take multiple steps (and possibly writing information to disk). The pipe can be used to link commands together to perform more complex tasks that would otherwise take multiple steps (and possibly writing information to disk). Examples: Examples: Count the number of users logged onto the current system. Count the number of users logged onto the current system. The who command will give us line by line output of all the current users. The who command will give us line by line output of all the current users. We could then use the wc -l to count the number of lines... We could then use the wc -l to count the number of lines... who | wc –l who | wc –l Display long listings in a scrollable page. Display long listings in a scrollable page. The lpq command will give us a list of the waiting print jobs. The lpq command will give us a list of the waiting print jobs. lpq | less lpq | less

Commands ps : lists the processes running on the machine. ps : lists the processes running on the machine. ps -u username lists only your processes. ps -u username lists only your processes. ps -a : lists all processes running on the machine. ps -a : lists all processes running on the machine. The PID column of the listing, provides the information required by the kill command. The PID column of the listing, provides the information required by the kill command. kill : terminates a process kill : terminates a process kill process_id : sends a terminate signal to the process specified by the process_id (PID). kill process_id : sends a terminate signal to the process specified by the process_id (PID). In cases where the terminate signal does not work, the command "kill -9 process_id" sends a kill signal to the process. In cases where the terminate signal does not work, the command "kill -9 process_id" sends a kill signal to the process. nice : runs a process with a lower priority. nice : runs a process with a lower priority.