Some Linux (Unix) Commands that might help you in ENSC351

Similar documents
Introduction to the Linux Command Line

CS Fundamentals of Programming II Fall Very Basic UNIX

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Working with Basic Linux. Daniel Balagué

Using the Zoo Workstations

CISC 220 fall 2011, set 1: Linux basics

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

CSE115 Lab exercises for week 1 of recitations Spring 2011

A Brief Introduction to Unix

UNIX Tutorial One

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

Exploring UNIX: Session 3

mkdir Phys338 s2017 Draw the tree of the directories and files for this step and all the following cd Phys338 s2017

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Introduction to remote command line Linux. Research Computing Team University of Birmingham

15-122: Principles of Imperative Computation

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Linux Exercise. pwd answer: We call this directory (into which you get when you log in) your home directory.

1 Getting Started with Linux.

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

5/8/2012. Creating and Changing Directories Chapter 7

Linux at the Command Line Don Johnson of BU IS&T

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Linux File System and Basic Commands

Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Linux

Introduction to Unix CHAPTER 6. File Systems. Permissions

Physics REU Unix Tutorial

UNIX File Hierarchy: Structure and Commands

Traditional Access Permissions

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Lab #12: Shell Scripting

Using WestGrid from the desktop Oct on Access Grid

Basic Survival UNIX.

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Introduction to Linux for BlueBEAR. January

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

commandname flags arguments

Introduction to Linux

Scripting Languages Course 1. Diana Trandabăț

Getting your department account

Linux Command Line Primer. By: Scott Marshall

You should see something like this, called the prompt :

CS4023 Week04 Lab Exercise

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Overview of the UNIX File System

When you first log in, you will be placed in your home directory. To see what this directory is named, type:

Lab 3a Using the vi editor

Principles of Bioinformatics. BIO540/STA569/CSI660 Fall 2010

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Unit 10. Linux Operating System

Introduction: What is Unix?

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

Lab 1 Introduction to UNIX and C

Unix Basics. Systems Programming Concepts

Lab Assignment #1. University of Pittsburgh Department of Electrical and Computer Engineering

Linux/Cygwin Practice Computer Architecture

A Brief Introduction to the Linux Shell for Data Science

AMS 200: Working on Linux/Unix Machines

Session 1: Accessing MUGrid and Command Line Basics

Lecture 01 - Working with Linux Servers and Git

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Introduction to Unix: Fundamental Commands

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

User Guide Version 2.0

CS CS Tutorial 2 2 Winter 2018

Outline. Structure of a UNIX command

Overview of the UNIX File System. Navigating and Viewing Directories

Mills HPC Tutorial Series. Linux Basics I

You will automatically be in your user (home) directory when you login.

Introduction. SSH Secure Shell Client 1

Introduction to the UNIX command line

INSE Lab 1 Introduction to UNIX Fall 2017

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

UTA Tech Orientation Spring 2019

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Operating Systems, Unix Files and Commands SEEM

CSCI 2132 Software Development. Lecture 4: Files and Directories

The Command Line. Matthew Bender. September 10, CMSC Command Line Workshop. Matthew Bender (2015) The Command Line September 10, / 25

Essential Linux Shell Commands

Linux Command Line Interface. December 27, 2017

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

Files

The Directory Structure

STAT 625: Statistical Case Studies

Intermediate Programming, Spring Misha Kazhdan

Introduction. Overview of 201 Lab and Linux Tutorials. Stef Nychka. September 10, Department of Computing Science University of Alberta

CSC209. Software Tools and Systems Programming.

9 and 11-Jan CSCI 4152/6509 Natural Language Processing Lab 1: FCS Computing Environment, SVN Tutorial. FCS Computing Environment, SVN Tutorial

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Software Installation - Accessing Linux and Checking your Environmental Variables

Transcription:

Some Linux (Unix) Commands that might help you in ENSC351 First, like Windows, Linux and Unix (for our purposes, they are the basically the same) use a hierarchical directory structure. What would be called a "folder" in Windows is called a "directory" in Linux. Each directory can contain a number of files and other subdirectories, just like Windows. Unlike Windows, Linux users usually use a command line interface (rather than a GUI). From what I have seen in industry, most engineers spend much of their time using a command-line interface, so if you want to be employable (not just successful in ENSC351), it is worthwhile learning just a little bit of the command line interface (you don't have to know very much to be effective). With experience, you will find that the command line interface is much faster and more flexible (how many times have you searched window after window for a particular setting what if everything could be done by just entering a command?). Each user has a "home directory", and when you first log in, this is the directory you are in. You can make subdirectories and files within that home directory. When you start Linux, you will face a command line prompt (often it contains something like a ">") followed by a flashing cursor. This is where you will type all your commands. Some commands (like "gedit") will open windows, but most will just produce text output. Some of the commands you can type at the Linux prompt include: ls The "ls" command lists all the files in the current directory. When you log in the first time, you may not have many files (but there might be a few there). mkdir directoryname This command will make a subdirectory within your current directory. The new directory will have the name "directoryname". You can create as many directories in your current directory as you like. Try making a few, and then doing a ls to see the new directories. cd directoryname This will allow you to "go into" a subdirectory called directoryname (which must have been previously created using mkdir). When you go into a directory the first time, of course it will be empty. You can create a new subdirectory within a subdirectory, etc.

If you want to go back to the parent directory, use.. (two dots). So for example, cd.. would move you up to the parent directory. Some comments about files: Like Windows, files can be of many types. Usually (again like Windows), an extension is used in the filename to indicate what type of file it is (.html,.txt, for example). This is just convention, you don't *have* to do this. A special type of file is a "text file". To create a text file, you need a text editor (same idea as Winpad or variants in Windows). Religious wars have been fought about the best text editor to use in Linux. Most text editors (but not all) do not open up a new window, but instead use the current window to display and edit the file. The two most common text editors are called "emacs" and vi/vim, but they may take some time to learn (I have a separate vim cheatsheet handout for those of you who want to try it). However, you may find that gedit is perhaps the simplest to learn; it opens a new window to edit the file, meaning Xming (or other X-server software) has to be running. To create a file: gedit filename will open the editor to create the file filename. When you save, your file is written to the current directory, and is called filename. Create a number of files in your current directory, and do an ls to see that they are all there. Note that some people choose to edit their files on Windows, and then transfer them using a file transfer facility. If you find that easier, go ahead, however, be aware that if you do this when you go to industry, people will laugh at you. (Also be aware that a dos2unix command may be necessary as carriage returns in windows and linux environments are different.) To remove a file: rm filename deletes the file named filename in the current directory. Note that there is no trash can to save you if you make a mistake real engineers don't make mistakes.

To copy a file: cp filename1 filename2 The above command will make a copy (duplicate) of filename1 and call it filename2 in the current directory. After executing this, the two files will be identical. Sometimes, you might want to make a copy of an entire directory. You can do this, by using the r flag in the cp command as follows: cp r dirname1 dirname2 The above will make a duplicate of the directory named dirname1 and call it dirname2. All files and subdirectories are copied (and subdirectories of subdirectories, etc ). You might consider doing this to make backup copies. So, if you are in your home directory, and you have a subdirectory called ensc351, you could do something like this: cp r ensc351 backup to create a backup of everything in that directory just in case disaster strikes later. I would strongly suggest doing this regularly, particularly if you use know no other form of revision control! You can also copy a file into your current directory using the following command: cp /bin/important_stuff.txt. Note that the destination name in this case is a dot. The dot means "put it in my current working directory and call it the same thing as the source directory". So, in the above, you will get a copy of the important_stuff.txt file from the /bin directory in your working directory. You can also remove an entire directory using: rm r dirname1 which will remove the directory named dirname1 and everything below it. Warning: this is very dangerous! You can get in trouble very quickly. One command could mean you delete your entire ensc351 directory! The department does have backups, but it would take some time for them to dig the tapes out, so be very careful with this. My suggestion is *never* to use the r option with rm. Another miscellaneous command you might use is "ssh," which allows you to log into another machine (e.g. dogwood).

On Filetypes: Just as in Windows, Linux files can be of different types. However, most tools create files in a human-readable text format. Even large CAD tools (like those from Altera and Xilinx) rely on scripts and text files to describe a designer s circuit. This means you can open the circuit descriptions with a text editor! This is different than Windows (you can't open a.doc file with a text editor). Engineers like this, because it allows them to go in and understand the files and possibly edit the contents directly, even if the original tool is not available or difficult to use. This is something you will really appreciate later, if you choose to take ensc452 or ensc450. On Directories: Your directory is actually a subdirectory of some higher level directory that contains directories for all the team logins of your classmates on your workstation. That directory is a subdirectory of an even higher-level directory, and so on. You can quickly refer to your home directory using the tilde symbol. If your ENSC userid is lesley, then ~lesley refers to your home directory. So, you can go cd ~lesley to change to your home directory. You can also specify longer pathnames using the / symbol. This is the same as in Windows (except Windows uses the \ symbol). So, if your user id is lesley, and you have a subdirectory called ensc351 and that directory contains a subdirectory called phase2, you could quickly change to that subdirectory using: cd ~lesley/ensc351/phase2 Technically, you could also do something like this: if your friend's ENSC id is bob, you could do this: cp r ~bob/ensc351 ~lesley/ensc351 This will copy his ensc351 directory into yours! This seems like a security hole, and it is. By default, everyone else can see all your files! You can set the "permissions" for your directory so that no one can see your files using: chmod og-rx ~lesley where lesley is your userid. This will prevent anyone from seeing any of your files (including me). There's a lot more you can do with the chmod command, but that is beyond the scope of this document.

System Directories: There are a number of directories in the system that do not belong to anyone in particular. These directories contain files that everyone might find useful, as well as executable files. Script files can be executed using the source command (commonly shell script files which are generally denoted with.csh and.sh file extensions.