Using the Terminal Lab 3+.

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

Shell Script Assignment 1.
Chapter One The Essence of UNIX.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
1 LINUX Desktops Using the GNOME and KDE Desktops Learning Red Hat Enterprise Linux & Fedora, 4th Edition By Bill McCarty, 2004.
Using Linux Commands 2 Lab#5
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.
Linux Installation and Administration Lesson 2 Tutor: George Papamarkos.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
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.
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.
SUSE Linux Enterprise Desktop Administration Chapter 2 Use the Linux Desktop.
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
Guide to Linux Installation and Administration, 2e1 Chapter 10 Managing System Resources.
Guide to Linux Installation and Administration, 2e1 Chapter 7 The Role of the System Administrator.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Operating Systems and Using Linux CMSC 104, Lecture 3 John Y. Park 1.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
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.
Λειτουργικά Συστήματα - Lab1 Γιάννης Πετράκης. The Operating System  Unix is a layered operating system  The innermost layer is the hardware that provides.
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.
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.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Operating Systems and Using Linux Courtesy of John Y. Park 1.
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.
Guide to Parallel Operating Systems with Windows 7 and Linux Chapter 10 Operating System Management.
CMSC 104, Version 9/011 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
Using Linux Kaya Oğuz Room: 310.
Overview of Linux Fall 2016 Dr. Donghyun Kim
SUSE Linux Enterprise Desktop Administration
Chapter 11 Command-Line Master Class
Lecture 2 Working with Files and Directories
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
UNIX System Overview.
The Linux Operating System
Shell Script Assignment 1.
Using Linux Commands Lab 3.
Operating Systems and Using Linux
Operating Systems and Using Linux
FTP and UNIX TOPICS Exploring your Web Hosting Site FTP UNIX
An Introduction to UNIX System --- Cosc513 Presentation
Operating Systems and Using Linux
(Chapter 2) John Carelli, Instructor Kutztown University
Chapter 2: System Structures
Unix : Introduction and Commands
Operating Systems and Using Linux
Operating Systems and Using Linux
Web Programming Essentials:
Introduction Paul Flynn
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
Linux Shell Script Programming
Linux Professor Sabol.
CSE 303 Concepts and Tools for Software Development
Operating Systems and Using Linux
Module 13 System and User Security
Consult America Technology Consulting Services
Presentation transcript:

Using the Terminal Lab 3+

"Under Linux there are GUIs (graphical user interfaces). where you can point and click and drag, and hopefully get work done without first reading lots of documentation. The traditional Unix environment is a CLI (command line interface) where you type commands to tell the computer what to do. That is faster and more powerful, but requires finding out what the commands are."

What is the Terminal There are many varieties of Linux, but almost all of them use similar commands that can be entered from a command- line interface terminal. The Terminal = command line interface = shell that gives command to the OS. A "shell" is a program which interprets commands so that the operating system can understand them. the use of the shell can be quicker than a graphical method. Red Hat uses bash as its default shell.

What is BASH? BASH = Bourne Again Shell BASH is a shell written as a free replacement to the standard Bourne Shell which is written by Steve Bourne for UNIX systems. It has all of the features of the original Bourne shell, plus additions that make it easier to program with and use from the command line. Since it is Free Software, it has been adopted as the default shell on most Linux systems.

Starting a Terminal Applications  System Tools  Terminal Print Screen

Shell Prompt Terms terminal window shell prompt command line Shell Print Screen

Terminal Window The terminal window is the window that contains the shell prompt, command line, and output from the shell.

Shell Prompt The shell prompt is the marker on the screen that shows where the command line should be placed. The following is an example of a shell prompt: UserName@ComputerName:~$ @ to separate UserName from ComputerName. : colon to separate the computer name from the directory. ~ tilda to represent your home directory. $ to terminate the prompt.

Command Line The command line is where options to a command are placed. The following is an example of a command line: command -options <filename>

Shell The shell is the program that interprets commands so that the operating system can understand them.

The prompt --- the command you type --- Enter. The lines that follow show the output that results from the command. NOTE: command may have options: command -options

Checking your login session Login Identity includes: user name, group name, user ID, and group ID. To find out information about your identity: Linux keeps track of login session: when you logged in, how long you have been idle, and where you logged in from. $ id uid=501(chris) gid=105(sales) groups=105(sales), 4(adm), 7(lp) When you log in to a Linux system, Linux views you as having a particular identity. That identity includes your user name, group name, user ID, and group ID. Linux also keeps track of your login session: it knows when you logged in, how long you have been idle, and where you logged in from. To find out information about your identity, use the id command as follows: $ id uid=501(chris) gid=105(sales) groups=105(sales),4(adm),7(lp) This shows that the user name is chris, which is represented by the numeric user ID (uid) 501. Here, the primary group for chris is called sales, which has a group ID (gid) of 105. Chris also belongs to other groups called adm (uid 4) and lp (uid 7). These names and numbers represent the permissions that chris has to access computer resources. (Permissions are described later in this chapter in the section on working with files.) You can see information about your current login session by using the who command. In the following example, the -m option tells the who command to print information about the current user, -u says to add information about idle time and the process ID, and -H asks that a header be printed: $ who -umH NAME LINE TIME IDLE PID COMMENT chris tty1 Jan 13 20:57 . 2013 The output from this who command shows that the user name is chris. Here, chris is logged in on tty1 (which is the monitor connected to the computer), and his login session began at 20:57 on January 13. The IDLE time shows how long the shell has been open without any command being typed (the dot indicates that it is currently active). The pid is the process-ID of the user's shell. COMMENT would show the name of the remote computer the user had logged in from, if that user had logged in from another computer on the network, or the name of the local X display if you were using a Terminal window (such as :0.0). $ who -umH NAME LINE TIME IDLE PID COMMENT chris tty1 jan 13 20:57 . 2013

 -m option tells the who command to print information about the current user -u says to add information about idle time and the process ID -H asks that a header be printed

Checking directories and permissions To find out what your current directory is: To find out the name of your home directory: $ pwd /usr/bin $ echo $HOME /home/chris

To get back to your home directory: To change the current directory to the directory that you choose: $ cd $ cd /etc

File & Directory Commands To list the contents of the current directory: Date The date of last modification permissions User The user that owns the file, or directory Size The size in bytes $ ls –al /home/chris total 158 drwxrwxrwx 3 chris sales 1024 May 12 13:55 . drwxr-xr-x 3 root root 1024 May 10 01:49 .. -rw------- 1 chris sales 2204 May 18 21:30 .bash_history -rw-r--r-- 1 chris sales 24 May 10 01:50 .bash_logout -rw-r--r-- 1 chris sales 230 May 10 01:50 .bash_profile At this point, list the contents of your home directory, using the ls command. Either you can type the full path to your home directory to list its contents, or you can use the ls command without a directory name to list the contents of the current directory. Using the -a option to ls enables you to view the hidden files (dot files) as well as all other files. With the -l option, you can see a long, detailed list of information on each file. (You can put multiple single-letter options together after a single dash, for example, -la.) $ ls -la /home/chris total 158 Displaying a long list (-l option) of the contents of your home directory shows you more about file sizes and directories. Directories such as the current directory (.) and the directory above the current directory (..) are noted as directories by the letter "d" at the beginning of each entry. In this case, dot (.) represents /home/chris and two dots (..), which is also referred to as the parent directory, represents /home. The /home directory is owned by root. All other files are owned by the user chris (who belongs to the sales group). The file or directory names shown on the right are mostly dot (.) files that are used to store GUI properties (.kde) or shell properties (.bash files). The only non-dot file shown in this example is the one named letter. At the beginning of each line are the permissions set for each file. (Permissions and configuring shell property files are described later in this chapter.) Other information in the listing includes the size of each file in bytes (column 4) and the date and time each file was most recently modified (column 5). Group The group that file belongs to, Directories This field specifies the number of links or directories inside this directory. Directory or File The name of the file or directory.

File & Directory Commands List the contents of your home directory List the contents of your root directory $ ls ~ $ ls /

Checking system activity To list running processes and monitoring system usage: a option ask to show process of all users who are associated with your current terminal u option asks that user names be shown , as well as other information such as the time process started and CPU usage. VSZ (virtual set size)  size of image process(in kilobytes). RSS(resident set size) size of program in memory. $ ps au USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 2164 0.0 0.8 1908 1100 ttyp0 S 14:50 0:00 login - - jake jake 2147 0.0 0.7 1836 1020 ttyp0 S 14:50 0:00 -bash jake 2310 0.0 0.7 2592 912 ttyp0 R 18:22 0:00 ps au  it is a snapshot of what is running when you invoked the command. If you want a constantly updated list of running processes Application such as Mozilla and Nautilus are thread-aware — multiple threads are created to handle multiple users or multiple requests, and each thread is given a process ID. By default, ps and top only display the main (initial) thread. To view all threads, use the command ps -m or type [Shift]-[H] in top. If you prefer a graphical interface for top, you can use the GNOME System Monitor. To start it from the desktop, select Main Menu Button (on the Panel) => System Tools => System Monitor or type gnome-system-monitor at a shell prompt from within the X Window System. Then select the Process Listing tab. The GNOME System Monitor allows you to search for process in the list of running process as well as view all processes, your processes, or active processes. In this example, the -a option asks to show processes of all users that are associated with your current terminal, and the -u option asks that user names be shown, as well as other information such as the time the process started and memory and CPU usage. The concept of terminal comes from the old days, when people worked exclusively from character terminals, so a terminal typically represented a single person at a single screen. Now you can have many "terminals" on one screen by opening multiple Terminal windows. On this shell session, there isn't much happening. The first process shows that the user named jake logged in to the login process (which is controlled by the root user). The next process shows that jake is using a bash shell and has just run the ps au command. The terminal device ttyp0 is being used for the login session. The STAT column represents the state of the process, with R indicating a currently running process and S representing a sleeping process. The USER column shows the name of the user who started the process. Each process is represented by a unique ID number referred to as a process ID (PID). (You can use the PID if you ever need to kill a runaway process.) The %CPU and %MEM columns show the percentage of the processor and random access memory, respectively, that the process is consuming. VSZ (virtual set size) shows size of the image process (in kilobytes), and RSS (resident set size) shows the size of the program in memory. START shows the time the process began running, and TIME shows the cumulative system time used.

Checking system activity To see and monitor all the processes running on the system : use spacebar to page through , and q to end the list $ ps aux | less A pipe lets you direct the output of one command to be the input of the next command.

Checking system activity To stop any process by PID i.e. to kill process To stop all process except your shell $ kill  2310 $ kill  0

References žRed Hat Linux Bible: Fedora and Enterprise Editionby Christopher Negus http://labnet321.blog.com/references/chapter-4/