Unix Basics Chapter 4.

Slides:



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

Pre-Assessment Questions
5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
Exploring the UNIX File System and File Security
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.
Guide To UNIX Using Linux Third Edition
Unix Basics. Systems Programming: Unix Basics 2 Unix Basics  Unix directories  Important Unix file commands  File and Directory Access Rights through.
UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Systems Programming Concepts
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Guide To UNIX Using Linux Fourth Edition
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
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.
The file structure and related utilities CS240 Computer Science II.
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.
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Lesson 1. PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor,
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
Chapter Two Exploring the UNIX File System and File Security.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
Chapter Two Exploring the UNIX File System and File Security.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
November 5, 2015CIS 118 Intro to UNIX What’s a Unix? Unix is an Operating System Designed for high-traffic usage Many variants –Linux, BSD: free versions.
E X C E E D I N G E X P E C T A T I O N S Basic LINUX Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Directory structure:
Introduction to Programming Using C An Introduction to Operating Systems.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
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.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
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.
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.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Basic Unix Commands. Listing files and directories ● ls:command is used to list the files and ● directories in present working directory ● ls command.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
Learning basic Unix command It 325 operating system.
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.
Using UNIX Charles Duan FAS Computer Services June 12, 2016.
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 101 Training Module Linux Basics.
Lecture 2 Working with Files and Directories
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
CSE 374 Programming Concepts & Tools
Exploring the UNIX File System and File Security
Web Programming Essentials:
Linux Shell Script Programming
Lab 2: Terminal Basics.
Chapter 4: The Linux Filesystem
January 26th, 2004 Class Meeting 2
Presentation transcript:

Unix Basics Chapter 4

The Filesystem Partitions / - The root partition: essential system binaries & configuration files /bin contains shells, ls, mkdir, etc. /usr – Operating system binaries & source code /usr/include contains c header files ie: stdio.h /usr/bin contains executables ie: gcc, g++, locate, where, passwd, etc. /usr/local – Administrator installed programs ie: apache web server, samba file server, etc. /tmp – Temporary files

Partitions Continued … /var – Files that change regularly ie: mail spools, printer spools /dev – Device files Provides access to all hard drives, ports, tape drives, floppy drive & cdrom drive. /users – User home directories Some UNIX servers use /home instead On Turing, all of your student accounts are in /users/student ie: /users/student/lbburford

Moving Around the Filesystem cd – change directory Absolute paths – specify the full path from the root directory (/) ie: cd /usr/include Absolute paths always have a leading slash Relative paths – specify the path from the present working directory Relative paths never have a leading slash For example, let’s assume I’m currently in the /usr directory The command cd bin would take me to /usr/bin not to /bin

Moving Continued Special characters . – current directory .. – parent directory ie: from the /usr/bin directory, cd .. would take you to the /usr directory. ~ - home directory cd ~ will take you to your home directory cd ~user will take you to user’s home directory

You’ve changed directories, how do you find out what’s in there? ls – Directory listing ls -a - list all files in the current directory. Files beginning with a ‘.’ are hidden. Using the -a flag will show those files. ls -l - list all files in the current directory with permissions, user and group information, size, and last modified date ls -al - lists extended information about all files in the current directory pwd – Present working directory If you forget which directory you’re currently working in, the pwd command will show you.

Working with Files & Directories cp – copy file(s) cp source destination mv – move & rename files mv source destination rm – delete a file or directory rm filename rm -R directory recursively deletes all files in the specified directory, then deletes the directory itself. mkdir – make directory mkdir directory

File Permissions There are 3 different types of permissions for files & directories on UNIX systems Read On files, allows the file to be opened On directories, allows a file listing (ls) inside the directory Write On files, allows the file to be modified/deleted On directories, allows the creation of files in the directory Execute On files, allows the file to be executed (run as a program) On directories, allows traversal inside the directory (lets you cd into the directory)

File Permissions There are 3 different sets of users for which permissions are set on a file. Owner – the person who owns the file Group – The group that owns the file World – Everyone else When you do an ls –l in a directory, you’ll see each file has a permission entry like this: rwxr-xr-x This type of entry is read left to right, the first 3 letters are for the user, the second 3 letters are for the group, and the third three letters are for the world. A hyphen indicates no permission. This particular entry means that the user has read, write, and execute permissions, while the group and the world have read and execute permission on it.

File Permissions Continued The chmod command is used to modify file and directory permissions chmod permission file permission in the above command is a 3 digit number. The first digit represents the owner permission, the second represents the group permission, and the third represents the world permission. Read = 4 Write = 2 Execute = 1 Add the numbers of the permissions you wish to assign together ie: read and write = 4 + 2 = 6 Apply the same principle for each set of users

File Permissions Exercise Let’s assume we have a file called test.sh We want to allow the owner to have all permissions, the group to have read and write permissions, and the world to have only execute permission. What is the 3 digit number representing the permissions we want? Let’s start with the owner: read + write + execute = permission 4 + 2 + 1 = 7 Group = read + write 4 + 2 = 6 World = execute 1 Now put it all together Permission = 761 The final command is: chmod 761 test.sh

Getting Help man – Display manual pages aka: man pages man command If when you run man on a particular command, you get the “builtin” man page, it means the command you specified is provided directly by the shell and not as an external program. In this case, you need to look up the man page for the shell you are using to find information about the command. man also works for C functions provided by the system. ie: man printf

Editing Text There are several options for text editors pico – easy to use editor with on screen menus. ee – similar to pico, menus not quite as intuitive. vi – the most powerful text editor. No on screen menus, high learning curve. The only editor guaranteed to be on any UNIX system you encounter. Textpad – while not a UNIX application, it is probably the best available choice for a Windows text editor with C syntax highlighting. Available for use on all CS computers, allows you to work on your programs through a mapped network drive.

Other Useful Commands pine – email client with on screen menus lpr – print a file lpr –P prlaser myfile.c available printers on Turing: prlaser, syslaser, memlj, mem2lj, advlaser grep – search for specific text less & more – show the contents of a file, or page output of a command ps – show all of your currently running processes kill – allows you to send signals to your processes kill -TERM pid TERM, HUP, & 9 are the most common signals you’ll need to send

Hints to make your life easier ./ - UNIX only knows about commands in your path. To run a program/script not in your path, you must either specify the whole path to the executable, or if you’re in the same directory as the executable, then type ./name_of_executable ./a.out tab – auto complete file names & paths | - pipe operator, allows you to redirect the output of one command to the input of another ls | grep .c ls -l | lpr -P prlaser ls | more > - output redirection operator ./a.out > output.txt up arrow – allows you to scroll through your command history instead of retyping a command