Expt 2 Study of Linux Shell Commands

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Expt. No.

2 Study of Linux Shell Commands


Aim : To study the syntax and utility of following Linux Commands by
working out these commands on the Linux shell.
Theory:
About Linux Operating System:
The Linux open source operating system, is a freely distributable, cross-platform operating system
based on Unix that can be installed on PCs, laptops, netbooks, mobile and tablet devices, video
game consoles, servers, supercomputers and more. The Linux OS is frequently packaged as a
Linux distribution for both desktop and server use and includes the Linux kernel (the core of the
operating system) as well as supporting tools and libraries. Popular Linux OS distributions include
Debian, Ubuntu, Fedora, Red Hat and openSUSE.
Important features of Linux Operating System:

Following are some of the important features of Linux Operating System.

• Portable – Portability means software can work on different types of hardware in same
way. Linux kernel and application programs supports their installation on any kind of
hardware platform.
• Open Source – Linux source code is freely available, and it is community-based
development project. Multiple teams work in collaboration to enhance the capability of
Linux operating system and it is continuously evolving.
• Multi-User – Linux is a multiuser system means multiple users can access system
resources like memory/ ram/ application programs at same time.
• Multiprogramming – Linux is a multiprogramming system means multiple applications
can run at same time.
• Hierarchical File System – Linux provides a standard file structure in which system files/
user files are arranged.
• Shell – Linux provides a special interpreter program which can be used to execute
commands of the operating system. It can be used to do various types of operations, call
application programs etc.
• Security – Linux provides user security using authentication features like password
protection/ controlled access to specific files/ encryption of data.

Directory Structure in Linux File System:


A standard Linux distribution follows the directory structure as provided below with Diagram and
explanation.

CSE-2252 Operating Systems Lab. Manual (4th SEM CSE YCCE)


Figure 2.1 Linux Directory Structure
• /bin : All the executable binary programs (file) required during booting, repairing, files
required to run into single-user-mode, and other important, basic commands viz., cat, du, df,
tar, rpm, wc, history, etc.
• /boot : Holds important files during boot-up process, including Linux Kernel.
• /dev : Contains device files for all the hardware devices on the machine e.g., cdrom, cpu, etc
• /etc : Contains Application’s configuration files, startup, shutdown, start, stop script for every
individual program.
• /home : Home directory of the users. Every time a new user is created, a directory in the name
of user is created within home directory which contains other directories like Desktop,
Downloads, Documents, etc.
• /lib : The Lib directory contains kernel modules and shared library images required to boot the
system and run commands in root file system.
• /lost+found : This Directory is installed during installation of Linux, useful for recovering files
which may be broken due to unexpected shut-down.
• /media : Temporary mount directory is created for removable devices viz., media/cdrom.

CSE-2252 Operating Systems Lab. Manual (4th SEM CSE YCCE)


• /mnt : Temporary mount directory for mounting file system.
• /opt : Optional is abbreviated as opt. Contains third party application software. Viz., Java, etc.
• /proc : A virtual and pseudo file-system which contains information about running process
with a particular Process-id aka pid.
• /root : This is the home directory of root user and should never be confused with ‘/‘
• /run : This directory is the only clean solution for early-runtime-dir problem.
• /sbin : Contains binary executable programs, required by System Administrator, for
Maintenance. Viz., iptables, fdisk, ifconfig, swapon, reboot, etc.
• /srv : Service is abbreviated as ‘srv‘. This directory contains server specific and service related
files.
• /sys : Modern Linux distributions include a /sys directory as a virtual filesystem, which stores
and allows modification of the devices connected to the system.
• /tmp :System’s Temporary Directory, Accessible by users and root. Stores temporary files for
user and system, till next boot.
• /usr : Contains executable binaries, documentation, source code, libraries for second level
program.
• /var : Stands for variable. The contents of this file is expected to grow. This directory contains
log, lock, spool, mail and temp files.

LAB Work:
Exploring Linux Commands:
Write about the following commands and their output, topic wise for each of the commands given
below. Also write about using these commands using different options, redirection, and pipes.

Topic Shell Commands


Process Management ps, pstree, kill, killall, top, time
Memory Management free, vmstat
Networking ifconfig, ping, traceroute, whois, telnet,
hostname, ssh, iftop, iptraf
Disk and file cp, mv, rm, ls, cd, mkdir, pwd, cat, touch,
Management chmod, lsblk, fdisk -l, df -h, stat, file, du,
locate, quota
Miscellaneous who, whoami, passwd, finger, uptime, cal,
lscpu, uname, gpg, dstat, lsusb, service, sudo,
history, mesg n, script, man, type, &

(Note: Students shall also practice these commands using different options, redirection,
pipes and filters)

CSE-2252 Operating Systems Lab. Manual (4th SEM CSE YCCE)


Home Work/Viva Questions:
1. If a.out is an executable program that computes and prints first 50 prime numbers, explain
what the following command does?
time ./a.out > ff &
2. What do each of the following commands do?
i)cat f1 > f2
ii)cat f1 >> f2
iii)./a.out < f3 >f4
3. What is the output of the following sequence of commands ?
touch myfile
chmod 020 myfile
rm myfile

CSE-2252 Operating Systems Lab. Manual (4th SEM CSE YCCE)

You might also like