UNIX UTILITY PACKAGE Shell Simulator Added Shell Commands File System Explorer ( LNC ) System Information Process Tree Viewer.

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

Operating System Structures
Basic Unix system administration
Operating system services Program execution I/O operations File-system manipulation Communications Error detection Resource allocation Accounting Protection.
System Files and Process Environment Password file Group file System identification Time Process environment.
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.
Chapter 8 Files and User Information Utilities. Logical Partitions referred to as file systems like a drive in windows world $ df (display filesystems)
System-Level I/O Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O.
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.
Operating Systems Recitation 11, June 9-10, 2002.
I/O April 16, 2002 Topics Files Unix I/O Standard I/O Reading: (Beta) or (New) Problems: 12.9 (Beta) or 12.4 (New) class24.ppt
Linux Operating System
Kernel Directory Interface. DirectoriesDirectories Recall that in Unix your hard drive is organized into a hierarchical system of directories and files.
CS 311 – Lecture 12 Outline File management system calls Stat() Directory Information  Opendir()  Readdir()  Closedir() Truncate() and remove() Lecture.
Week 8 - Friday.  What did we talk about last time?  String to int conversions  Users and groups  Password files.
Overview of Linux CS3530 Spring 2014 Dr. José M. Garrido Department of Computer Science.
Manage Directories and Files in Linux
Chapter 39 Virtsualization of Storage: File and Directory Chien-Chung Shen CIS, UD
Input and Output Topics I/O hardware Unix file abstraction Robust I/O File sharing io.ppt CS 105 “Tour of the Black Holes of Computing”
1 System-Level I/O Andrew Case Slides adapted from Jinyang Li, Randy Bryant and Dave O’Hallaron.
Week 12 - Friday.  What did we talk about last time?  Exam 2 post mortem  Low level file I/O.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
The Linux /proc Filesystem CSE8343 – Fall 2001 Group A1 – Alex MacFarlane, Garrick Williamson, Brad Crabtree.
1 Project 3: An Introduction to File Systems CS3430 Operating Systems University of Northern Iowa.
UNIX Files File organization and a few primitives.
Files and Directories File types stat functions for file information
Introduction to Programming Using C An Introduction to Operating Systems.
System Administration – Part 2. Devices in UNIX are files: A device can be accessed with different file names All device files are stored in /dev or its.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Today’s topic Access and manipulate meta data for files –File type, ownership, access permissions, access time, etc How to determine if a file is not there?
Interacting with Unix. Getting the Process ID u Synopsis #include pid_t getpid(void); u Example: #include int main(){ pid_t n = getpid(); printf("Process.
Laface 2007 File system 2.1 Operating System Design Filesystem system calls buffer allocation algorithms getblk brelse bread breada bwrite iget iput bmap.
CS 105 “Tour of the Black Holes of Computing”
System Administration. Logging in as System Administrator System Admin login (aka superuser, aka root) –login id: root –Default PS1 prompt: # –Home directory:
CSC414 “Introduction to UNIX/ Linux” Lecture 6. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
CSE333 SECTION 3. Important Dates Jan 27 th – Homework 1 Due Feb 6 th – Midterm.
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.
CSCI 330 UNIX and Network Programming Unit VIII: I/O Management II.
Adv. UNIX: FileAgain/171 Advanced UNIX v Objectives –to look at the low-level manipulation of files and their properties (e.g. permissions)
Files Oct. 28, 2008 Topics Mapping file offsets to disk blocks File system buffering and you The directory hierarchy lecture-18.ppt “The course.
Basic UNIX system administration CS 2204 Class meeting 14 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Week 9 - Wednesday.  What did we talk about last time?  structs.
CSCE Systems Programming Lecture 07 – Make, Stdio, I/O Buffering CSCE 510 Jan 23, 2013.
Week 12 - Friday.  What did we talk about last time?  Exam 2 post mortem.
Advanced Programming in the UNIX Environment Hop Lee.
Computer Science 516 Addressing Modes. Addressing modes are how our programs get to data Multiple addressing modes created for specific uses Function.
Week 12 - Thursday CS222.
Overview of Linux Fall 2016 Dr. Donghyun Kim
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Proc File System Sadi Evren SEKER.
Avani R.Vasant V.V.P. Engineering College
Chapter 2: System Structures
UNIX System Overview.
Project 3: An Introduction to File Systems
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Operating System Hebrew University Spring 2004
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Tutorial of Unix Command & shell scriptS 5027
“The course that gives CMU its Zip!”
File Structure Related system calls
“The course that gives CMU its Zip!”
File Input and Output.
Project 3: An Introduction to File Systems
File I/O (1) Prof. Ikjun Yeom TA – Hoyoun
Chien-Chung Shen CIS, UD
Chapter 2: Operating-System Structures
CS 105 “Tour of the Black Holes of Computing”
Presentation transcript:

UNIX UTILITY PACKAGE Shell Simulator Added Shell Commands File System Explorer ( LNC ) System Information Process Tree Viewer

What Is Shell ? Shell provides a protective covering for the kernel. A UNIX shell provides a protective outer covering. To protect the user from the complexity of the kernel, and to protect the kernel from the user, a protective shell is built around the kernel. The user makes requests to a shell, which interprets them, and passes them on to the kernel.

Shell Comparison Most contemporary versions of UNIX provide all three shells Bourne Shell C Shell Korn Shell

Functions Of Shell 1.Command line interpretation 2.Program initiation 3.Input-output redirection 4.Pipeline connection 5.Substitution of filenames 6.Maintenance of variables 7.Environment control 8.Shell programming

Our Shell Commands HelpTimeCd ShellsSysconfInode MountSysinfoWho FilesysFsblkWho –a LsLs –aLs –r Ls –ILs –lLs –ss typesLncLs –i Cd\Cd..Cpu am

help The list of implemented shell commands with a description

ls ls - Displays entries in the current working directory -l -Displays the file modes and no of links to the file,owner name, group name, size of the file (in bytes) time stamp and the file name. -a - Displays all entries including hidden files -r - Displays all entries in reverse order -i - Displays all file names with their inodes no -i - Displays the inode no of the file name specified -ss - Displays the file names in sorted order on size types - Displays all file names with their types

Shells Display existing shells in the system by reading and printing /etc/shells

Mount Display all devices and file systems mounted in the system by opening and reading /etc/mtab We use mntent structure and setmntent( ) getmntent( ) for reading the file

Mount continued FILE *fp; struct mntent *mn; fp=setmntent("/etc/mtab","r"); mn=getmntent(fp); while (mn!= NULL) { printf("%s on %s",mn->mnt_fsname,mn->mnt_dir); printf("type %s (%s)",mn->mnt_type,mn->mnt_opts); mn=getmntent(fp); } endmntent(fp);

Sysconfig Long sysconf ( int name ) Get system limits or run time options We pass macros and get integer Macros can be : _SC_ARG_MAX, _SC_CLK_TCK, _SC_OPEN_MAX, _SC_STREAM_MAX,…

Cpu We open the file /proc/cpuinfo and simply print it for geeting info about the cpu

sysinfo Using sysinfo structure and Sysinfo system call we get info about processes,memory,… int sysinfo(struct sysinfo *info);

Sysinfo continued struct sysinfo { long uptime; /* Seconds since boot */ unsigned long loads[3]; /* 1, 5, 15 min load averages */ unsigned long totalram; /* Total usable main memory size */ unsigned long freeram; /* Available memory size */ unsigned long sharedram; /* Amount of shared memory */ unsigned long bufferram; /* Memory used by buffers */ unsigned long totalswap; /* Total swap space size */ unsigned long freeswap; /* swap space still available */ unsigned short procs; /* Number of current processes */ ….. };

fsblk We want to get file system block size. The whole thing is : struct stat st; stat("/",&st); /* current fs */ printf("%d",st.st_blksize);

Am Gives info about you ; with the help of getuid(), getlogin ()

Inode Using stat structure and stat system call we get info about inode of the specified file.. struct stat { dev_t st_dev; /* device */ ino_t st_ino; /* inode */ mode_t st_mode; /* protection */ dev_t st_rdev; /* device type (if inode device) */ off_t st_size; /* total size, in bytes */ unsigned long st_blksize; /* blocksize for I/O */ unsigned long st_blocks; /* allocated blocks*/ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last change */ };

filesys Using struct statfs and statfs system call we get info about file system. int statfs(const char *path, struct statfs *buf); int fstatfs(int fd, struct statfs *buf);

Filesys continued struct statfs { long f_type;/* type of fs */ long f_bsize; /* opt transfer block size */ long f_blocks; /* total data blocks in fs */ long f_bfree; /* free blocks in fs */ long f_bavail; /* free blocks avail to non-superuser */ long f_files; /* total file nodes in fs */ long f_ffree; /* free file nodes in fs */ fsid_t f_fsid; /* file system id */ long f_namelen; /* maxlength of filenames */ long f_spare[6]; /* spare for later */ };

Who, Who -a Using /etc/passwd and /var/run/utmp and structures utmp and passwd we get logged in users or all users. struct utmp { short ut_type; /* type of login */ pid_t ut_pid; /* pid of login process */ char ut_line[UT_LINESIZE]; /* device name of tty - "/dev/" */ char ut_user[UT_NAMESIZE]; /* user name */ char ut_host[UT_HOSTSIZE]; /* hostname for remote login */ struct timeval ut_tv; /* time entry was made. */ int32_t ut_addr_v6[4]; /* IP address of remote host. */ …..};

Who –a continued struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* user password */ uid_t pw_uid; /* user id */ gid_t pw_gid; /* group id */ char *pw_gecos; /* real name */ char *pw_dir; /* home directory */ char *pw_shell; /* shell program */ };

Time We get useful info by using tm structure and localtime(), time() system calls struct tm { int tm_sec; /* seconds */ int tm_min; /* minutes */ int tm_hour; /* hours */ int tm_mday; /* day of the month */ int tm_mon; /* month */ int tm_year; /* year */ int tm_wday; /* day of the week */ int tm_yday; /* day in the year */ int tm_isdst; /* daylight saving time */ };

Cd.. Cd\ cd OBVIOUSLY with chdir( ) !

Help,Time,Cd,Shells Help : About all shell commands that we have implemented Time : Using tm structure we get time, date, day of week and day in year Cd : File system traversal. It can handle cd \ and cd.. and cd Shells : Using /etc/shells, we list existing shells in system

Who, Who –a, mount, inode Who : Using /var/run/utmp we list logged on users Who –a : Using /etc/passwd we list all who have account Mount : Using /etc/mtab we list all mounted filesystems in mount table Inode : Inode table of file as in stat structure

Filesys, sysinfo, Sysconf, Fsblk Filesys : Using statfs structure and system call we get info about file system Sysinfo : Using sysinfo structure and system call we get info about system Sysconf : Using sysconf() system call we get information about system configuration Fsblk : File system block size

Ls, types, lnc, cpu, am Lnc : Is a file systtem explorer Ls : Has been implemented with –i, -a, - ss, -r, -l flags Types : All file with their types Cpu : CPU information Am : Current user information

Late Night Commander (LNC) GUI for file system exploration Ability to operation of files like copy, delete, remove,… Uses Curses Gives information about files and file system It can have shell capabilities

Curses The curses package is a subroutine library for terminal-independent screen- painting and input-event handling which presents a high-level screen model to the programmer, hiding differences between terminal types and doing automatic optimization of output to change one screen-full of text into another.

Curses In 10 Lines !! WINDOW *windir; initscr(); start_color(); init_pair(1,COLOR_WHITE,COLOR_BLUE); windir=newwin(26,70,3,0); box(windir,ACS_VLINE,ACS_HLINE); wattrset(windir,COLOR_PAIR(1)); mvwprintw(windir,1,1," BE BRIEF “); wrefresh(windir); endwin();

Advantages Of The Project ! 1. Portability 2. Low requirements 3. User friendly 4. All advantages of shells applies here ! 5. All advantages of a file system explorer applies to LNC ! 6. Our added shell commands

Limitataions Not a complete shell LNC and big directories LNC not complete Colors are not that properly implemented Dependence on the underlaying shell Bugs !

THANK YOU !