unix utility package l.
Skip this Video
Loading SlideShow in 5 Seconds..
UNIX UTILITY PACKAGE PowerPoint Presentation
Download Presentation

Loading in 2 Seconds...

play fullscreen
1 / 33

UNIX UTILITY PACKAGE - PowerPoint PPT Presentation

  • Uploaded on

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

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'UNIX UTILITY PACKAGE' - rich

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
unix utility package
  • Shell Simulator
  • Added Shell Commands
  • File System Explorer ( LNC )
  • System Information
  • Process Tree Viewer
what is shell

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
Shell Comparison

Most contemporary versions of UNIX provide all three shells

  • Bourne Shell
  • C Shell
  • Korn Shell
functions of shell
Functions Of Shell
  • Command line interpretation
  • Program initiation
  • Input-output redirection
  • Pipeline connection
  • Substitution of filenames
  • Maintenance of variables
  • Environment control
  • Shell programming

The list of implemented shell commands with a description


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 <path> - 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


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


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
Mount continued

FILE *fp;

struct mntent *mn;



while (mn!= NULL) {

printf("%s on %s",mn->mnt_fsname,mn->mnt_dir); printf("type %s (%s)",mn->mnt_type,mn->mnt_opts);





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 ,…


We open the file /proc/cpuinfoand simply print it for geeting info about the cpu


Using sysinfo structure and

Sysinfo system call we get info about processes ,memory ,…

int sysinfo(struct sysinfo *info);

sysinfo continued
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 */

….. };


We want to get file system block size.

The whole thing is :

struct stat st;stat("/",&st); /* current fs */printf("%d",st.st_blksize);


Gives info about you ; with the help of

getuid() , getlogin ()

inode path

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 */



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
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
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
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 */



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 path
Cd .. Cd\ cd <path>

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 < path >
  • Shells : Using /etc/shells , we list existing shells in system
who who a mount inode
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 < path >: Inode table of file as in stat structure
filesys sysinfo sysconf fsblk
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
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
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

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
Curses In 10 Lines !!

WINDOW *windir;







mvwprintw(windir,1,1," BE BRIEF “);



advantages of the project
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

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