C151 Multi-User Operating Systems

Slides:



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

1 Introduction to UNIX Ke Liu
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.
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.
Lesson 22 – Introduction to Linux Systems Administration.
Linux Linux File System.
The UNIX File System.
Guide To UNIX Using Linux Third Edition
Introduction to Linux and Shell Scripting Jacob Chan.
Linux Commands LINUX COMMANDS.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
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.
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 Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Unix Basics Chapter 4.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
Introduction to Linux Azzam Mourad COEN 346.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
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.
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.
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:
L&T Infotech1 UNIX – Getting Started - Aneesh Ramani.
Chapter Two Exploring the UNIX File System and File Security.
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:
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
Introduction to Programming Using C An Introduction to Operating Systems.
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.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
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.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
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.
Learning Unix/Linux Based on slides from: Eric Bishop.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE.
Read the relevant material in Sobell!
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.
Getting started with CentOS Linux
Chapter 11 Command-Line Master Class
Linux 101 Training Module Linux Basics.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Linux file system "On a UNIX system, everything is a file;
Lecture 2 Working with Files and Directories
Some Linux Commands.
Introduction to Unix: Fundamental Commands
CSE 374 Programming Concepts & Tools
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Exploring the UNIX File System and File Security
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
Getting started with CentOS Linux
Linux Shell Script Programming
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Linux Commands LINUX COMMANDS.
Chapter 4: The Linux Filesystem
January 26th, 2004 Class Meeting 2
LPI Linux Certification
Presentation transcript:

C151 Multi-User Operating Systems Linux Commands

Expressions in Commands Current directory: . Parent directory: .. Home directory: ~ Root directory: /

Path Absolute path: complete sequence of directories to a file starting from the root directory /: /home/yul/c151/cat.jpg Relative path: the sequence of directories to reach a file starting from the current directory: c151/cat.jpg The absolute paths have the same meaning no matter what the working directory is. The relative paths depend on the current working directory. An absolute path is the concatenation of the current working directory and the relative path: /home/yul/ + c151/cat.jpg

Linux File Systems /      root directory /bin   executable for single user mode /dev   devices that can be mounted by the system /etc  local configuration, administrative things /home home directories for most users /lib   shared libraries /mnt   temporary mount point for mountable devices /proc  kernel and process information /root  home of the superuser (root) /sbin  system binaries (executables) /tmp   temporary files /usr   lots of information used by the system

Linux Users There is one special user that has administrative powers - the superuser. It's name is root. Every user has a home directory that can be found under /home/username. They have an allocated disk space. Every user’s home directory contains configuration (resource) files that define their environment. They all start with a dot. Example: .signature. For example, the file ".cshrc" will always be executed whenever the user logs in or opens a terminal window.

Environment Variables The environment variables are global variables that are defined within the shell and that can be used for many purposes. Their names are in general in all uppercase. Display the value of an environment variable: echo $PATH $PATH lookup list for binaries to be executed. $HOME user's home directory

Linux Commands Small utilities/programs under Linux that can take options and arguments. Argument: what the command applies to. ls /usr Option: how do we want the command to be executed ls –l The options and arguments can be combined: ls -l /usr/include Some commands take more than one argument cp requires a source file and a destination file.

More On Commands Some useful commands: cd, ls, man, pwd, cat, find, grep, wc Manipulating files and directories: mv, rm, cp, mkdir, rmdir

Linux Commands ls: list files cd: switch working directories Example: ls ~ cd: switch working directories Example: cd \ pwd: display current working directory Example: pwd man: display manual of command Example: man ls cat: display the entire content of a file Example: cat lab1.txt

Linux Commands mkdir: create a directory rm:delete files Example: mkdir C151 rm:delete files Example: rm *.txt rmdir: delete a directory Example: rmdir C151

Linux Commands Viewing the Contents of a File The more command Displays the entire contents of a file one page at a time Spacebar moves through file one page at a time Enter key moves through file one line at a time Only moves forward through a file, not backward Exit: q Example 1: more lab1.txt Example 2: man ls | more

Linux Commands Viewing the Contents of a File (continued) The less command Nearly equivalent to the more command Allows you to move forward and backward in the file Usage: same as more

Linux Commands Viewing the Contents of a File (continued) The head command Displays just the first ten lines of a file The tail command Displays just the last ten lines of a file Usage: same as more and less

Linux Commands find ./ -name hw1.txt find / -name “*.txt” The find command: find files The argument is a path. The name of the file must be specified with the option –name. There more options Find file with name “hw1.txt” in current directory (including sub directories) find ./ -name hw1.txt Find file with name extension “.txt” in root (including all sub directories) find / -name “*.txt”

Linux Commands The grep command: match a regular expression against text in a file Display the lines that contain ligyu in file file1.txt grep “ligyu” file1.txt

Linux Commands mv ~/a.pp ./ mv ~/a.pp ~/b.cpp Examples: mv: rename or move files Requires two parameters: name of original file and new name or location of file Examples: Move file “a.cpp” from home directory to current working directory: mv ~/a.pp ./ Rename file “a.cpp” in home directory to “b.cpp” mv ~/a.pp ~/b.cpp

Linux Commands cp ~/a.pp ./ cp ~/a.pp ~/b.cpp Examples: cp: copy files Requires two parameters: path and name of the original file and path and name or the new file Examples: Copy file “a.cpp” from home directory to current working directory (without changing name): cp ~/a.pp ./ copy file “a.cpp” in home directory to “b.cpp” cp ~/a.pp ~/b.cpp

Text Editor: Pico Provides a series of commands at the bottom of the screen Backspace, Delete, and other keys work as expected Easy to Use Start Pico Pico file_name Exit Pico [ctrl]+x

Linux Processes kill pid A process is any running program. Under Linux a process has an identity (PID), a parent process (PPID), an owner (UID). To view the active processes: ps Useful options: -A (all), -l (long list) Stop the execution of a program launched from a terminal: Ctrl-c Stop the execution of any process kill pid The signal 9 is the most powerful. Kill a process with id 1258 Kill 1258 kill 9 1258

Launching Jobs on Linux A job is any executable run from the terminal. The jobs are launched as foreground tasks by default - they will block the terminal until they are done. To launch a job in the background, use the symbol & at the end of the command line. A job can be intentionally brought to the foreground with the command fg.

Pipe Pipe (|) enables you to pass the output of one command through the input of another command ls -l | more The way this works is that when the shell sees the pipe symbol, it creates a temporary file to store the result of the first command Then this file becomes the input to second command

Input and Output Redirection Redirecting the input: command < filename Any input will read from that file (must be file). Redirecting the output. The simple > rewrites the output file, while the double one >> appends to the file (must be file). command > filename command >> filename Combine input and ouput redirections Example: wc < my_text_file.txt > output_file.txt

Compressing Files The most common utilities for compressing and decompressing files on Linux are tar, gzip, and gunzip. tar allows us to compress several files (directories) into one archive. Options: cf for compressing, xf for decompressing. Example: tar –cf C151.tar C151 gzip compresses one file at a time. Options: none to compress, -d to decompress. Example: gzip C151.tar To archive more than one file, most people use a combination of tar and gzip in that order. Those archives have the extension .tar.gz or simply .tgz.

Decompressing Files Suppose we have a compressed file called C151.tar.gz, how could we decompress it? gzip –d C151.tar.gz (or gunzip C151.tar.gz) We get C151.tar tar –xf C151.tar We get uncompressed files (folders)

File Ownership and Permissions Every file belongs to a particular user, generally the creator of that file. This is the owner of the file. Users may be organized in groups and a group can have special permissions to a file. A file can be accessible for reading r, writing w, or executing x. To view the content of a directory, the directory should be executable. Usually the owner has read and write permission to a file, also execute permission if applicable. The root (super user)has read and write permissions for any file. The command ls -l displays the permissions of a file for the owner, the group, and everyone else (all). Change permissions: chmod

File Ownership and Permissions Linux file and folder attributes seen with ls -l Column of 10 characters on left First character: file (-), directory (d), or link (l) 2nd, 3rd, and 4th characters show permissions of owner 5th, 6th, and 7th characters show permissions of group 8th , 9th, and 10th characters show permissions of all others

Managing Files and Directories with Shell Commands File and Folder Permissions (continued) Permissions R = read W = write X = execute - =disabled Permission mode values read=4 write=2 execute=1

File Ownership and Permissions Change permissions with chmod Requires two parameters Access mode number File or directory name to change Example chmod 644 reports

Reading Assignment Textbook: Chapter 3, Chapter 4, and Chapter 5