1.
PWD
NAME
pwd - print name of current/working directory
Syntax
pwd [OPTION]...
DESCRIPTION
Print the full file name of the current working directory.
OUTPUT:
2. MKDIR
NAME
mkdir - make directories
SYNTAX
mkdir [OPTION]... DIRECTORY...
DESCRIPTION
Create the DIRECTORY(ies), if they do not already exist.
OUTPUT:
3. CD
NAME
cd – change directories
SYNTAX
cd... DIRECTORY...
DESCRIPTION
change the directory .
OUTPUT:
4. RMDIR
NAME
rmdir - remove empty directories
SYNTAX
rmdir [OPTION]... DIRECTORY...
DESCRIPTION
Remove the DIRECTORY(ies), if they are empty.
OUTPUT:
5. LS
NAME
ls - list directory contents
SYNTAX
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default). Sort entries alphabetically if none
of -cftuvSUX nor --sort.
Mandatory arguments to long options are mandatory for short options too.
-a, --all
do not ignore entries starting with .
-r, --reverse
reverse order while sorting
-l use a long listing format
-R, --recursive
list subdirectories recursively
-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
-t sort by modification time
-u with -lt: sort by, and show, access time with -l: show access
time and sort by name otherwise: sort by access time
-i, --inode
print the index number of each file
OUTPUT:
ls:
ls-d:
ls-R:
ls-r:
ls-l:
ls-u:
ls-a:
ls-ld:
ls-i:
ls-t:
6. HOSTNAME
NAME
hostname - show or set the system's host name
dnsdomainname - show the system's DNS domain name
SYNTAX
hostname [-v] [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-i] [--ip-address] [--long] [-s] [--short] [-y] [--yp]
[--nis]
hostname [-v] [-b] [--boot] [-F filename] [--file filename] [hostname]
hostname [-v] [-h] [--help] [-V] [--version]
dnsdomainname [-v]
DESCRIPTION :
Hostname is used to either set or display the current host or domain name of the system. This name is
used by many of the networking programs to identify the machine. The domain name is also used by
NIS/YP.
OUTPUT:
7. CAT
NAME
cat - concatenate files and print on the standard output
SYNTAX
cat [OPTION]... [FILE]...
DESCRIPTION
Concatenate FILE(s), or standard input, to standard output.
Create FILE(s)
Display FILES(s)
OUTPUT: (Create and Display File)
OUTPUT: (Merge)
8. BC
NAME
bc - An arbitrary precision calculator language
SYNTAX
bc [ -hlwsqv ] [long-options] [ file ... ]
VERSION
This man page documents GNU bc version 1.06.
DESCRIPTION
bc is a language that supports arbitrary precision numbers with inter‐
active execution of statements
OUTPUT:
9. SORT
NAME
sort - sort lines of text files
SYNTAX
sort [OPTION]... [FILE]...
sort [OPTION]... --files0-from=F
DESCRIPTION
Write sorted concatenation of all FILE(s) to standard output.
OUTPUT:
10. CHMOD
NAME
chmod - change file mode bits
SYNTAX
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
DESCRIPTION
The chmod command is used to set the permission of one or more files for all three categories of
users(owner, group and others).
It can be run only by user which is the owner and the super user.
The command can be used in two ways:-
In a relative manner by specifying the change to the current permission.
In an absolute manner by specifying the final permission.
OUTPUT: (Previous File Permission of B)
OUTPUT: (Changed File Permission of B)
11.MV
NAME
mv - move (rename) files
SYNTAX
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
DESCRIPTION
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
OUTPUT:
12. RM
NAME
rm - remove files or directories
SYNTAX
rm [OPTION]... FILE...
DESCRIPTION
The RM command removes the files & directories from the current working directories.
OUTPUT:
13. DATE
NAME
date - print or set the system date and time
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
DESCRIPTION
Display the current time in the given FORMAT, or set the system date.
OUTPUT:
14. WHO
NAME
who - show who is logged on
SYNOPSIS
who [OPTION]... [ FILE | ARG1 ARG2 ]
DESCRIPTION
Print information about users who are currently logged in.
OUTPUT:
15. WHOAMI:
NAME
whoami - print effective userid
SYNOPSIS
whoami [OPTION]...
DESCRIPTION
Print the user name associated with the current effective user ID.
Same as id -un.
OUTPUT:
16. WHATIS
NAME
whatis - display manual page descriptions
SYNOPSIS
whatis [-dlhvV] [-r|-w] [-s list] [-m system[,...]] [-M path] [-L
locale] [-C file] name ...
DESCRIPTION
Each manual page has a short description available within it.
What is searches the manual page names and displays the manual page descriptions of any name
matched.
OUTPUT:
17. W
NAME
w - Show who is logged on and what they are doing.
SYNOPSIS
w [-husfVo] [user]
DESCRIPTION
w displays information about the users currently on the machine, and
their processes. The header shows, in this order, the current time,
how long the system has been running, how many users are currently
OUTPUT:
18.CAL
NAME
cal, ncal — displays a calendar and the date of Easter
SYNOPSIS
cal [-3hjy] [-A number] [-B number] [[month] year]
cal [-3hj] [-A number] [-B number] -m month [year]
ncal [-3bhjJpwySM] [-A number] [-B number] [-s country_code] [[month]
year]
ncal [-3bhJeoSM] [-A number] [-B number] [year]
ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]
DESCRIPTION
The cal utility displays a simple calendar in traditional format and ncal
offers an alternative layout, more options and the date of Easter. The
new format is a little cramped but it makes a year fit on a 25x80 termi‐
nal. If arguments are not specified, the current month is displayed.
OUTPUT:
19. UNAME
NAME
uname - print system information
SYNTAX
uname [OPTION]...
DESCRIPTION:
Print certain system information. With no OPTION.
OUTPUT:
20. READ
NAME
read - read from a file descriptor
SYNOPSIS
#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count);
DESCRIPTION
read() attempts to read up to count bytes from file descriptor fd into
the buffer starting at buf.
PROGRAM:
OUTPUT:
21. ECHO
NAME
echo - display a line of text
SYNOPSIS
echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION
DESCRIPTION
Echo the STRING(s) to standard output.
PROGRAM:
OUTPUT:
25. tr
NAME
tr - translate or delete characters
SYNTAX
tr [OPTION]... SET1 [SET2]
DESCRIPTION
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
-c, -C, --complement
first complement SET1
-d, --delete
delete characters in SET1, do not translate
-s, --squeeze-repeats
replace each input sequence of a repeated character that is listed in SET1 with
a single occurrence of that character .
OUTPUT:
16. TTY
NAME
tty - print the file name of the terminal connected to standard input
SYNTAX
tty [OPTION]...
DESCRIPTION
Print the file name of the terminal connected to standard input.
-s, --silent, --quiet
print nothing, only return an exit status
--help display this help and exit
--version
output version information and exit .
OUTPUT:
26. CUT
NAME
cut - remove sections from each line of files
SYNTAX
cut OPTION... [FILE]...
DESCRIPTION
Print selected parts of lines from each FILE to standard output.
Mandatory arguments to long options are mandatory for short options too.
-b, --bytes=LIST
select only these bytes
-c, --characters=LIST
select only these characters
-d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter
-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless
the -s option is specified .
OUTPUT:
27. PR
NAME
pr - convert text files for printing
SYNTAX
pr [OPTION]... [FILE]...
DESCRIPTION
Paginate or columnate FILE(s) for printing.
Mandatory arguments to long options are mandatory for short options
too.
OUTPUT
24. FILTER
A programme that uses character stream as Standard Input(<), Manipulates
its content and write it to standard output(>).
Command like Cat, WC, CMP, uses both standard input and output.
OUTPUT:
17. Ln
NAME
ln - make links between files
SYNOPSIS
ln [OPTION]... [-T] TARGET LINK_NAME
DESCRIPTION
Create a link between two files.
OUTPUT:
Q28: Write a Shell Script to find GREATEST of three numbers.
Code:
echo "enter first number"
read first
echo "enter second number"
read sec
echo "enter third number"
read third
if [ $first -gt $sec ] ; then
if [ $first -gt $third ] ; then
echo -e " $first is greatest number "
else
echo -e " $third is greatest number "
fi
else
if [ $sec -gt $third ] ; then
echo -e " $sec is greatest number "
else
echo -e " $third is greatest number "
fi
fi
OUTPUT
Q29: Write a Shell Script to find FACTORIAL of numbers.
Code:
fact=1
echo -e "enter a number"
read n
if [ $n -le 0 ] ; then
echo "invalid number"
exit
fi
if [ $n -gt 0 ] ; then
for((i=$n;i>=1;i--))
do
fact=`expr $fact \* $i`
done
fi
echo "The factorial of $n is $fact"
OUTPUT:
Q30: Write a Shell Script to find whether a no. is PRIME or NOT.
Code.
echo -n "Enter a number: "
read num
i=2
while [ $i -lt $num ]
do
if [ `expr $num % $i` -eq 0 ]
then
echo "$num is not a prime number"
echo "Since it is divisible by $i"
exit
fi
i=`expr $i + 1`
done
echo "$num is a prime number "
OUTPUT:
Q31: Write a Shell Script to print FIBONACCI Series.
Code:
c=0
a=1
b=1
read -p "Enter limit of fibonacci Series:" n
echo -n "$a "
echo -n "$b "
#Fibonacci series logic
while((c<n))
do
c=$((a+b))
echo -n "$c "
a=$b
b=$c
done
echo -e "\n"
OUTPUT:
Q32: Write a Shell Script to SUM of digit of a number.
Code:
echo -e "enter the number"
read n
sum=0
a=$n
while(($n >0))
do
x=`expr $n % 10`
sum=`expr $sum + $x`
n=`expr $n / 10`
done
echo "the sum of $a is $sum"
OUTPUT:
Q33: Write a Shell Script whether a year is a LEAP YEAR or not.
Code:
echo-e “enter a year”
read year
if[$year-le 0 ];then
year=`date | cut-d ” ” –f6`
fi
if[`expr$year%year%400`-eq0];then
echo “$year is a leap year”
elif[`expr$year%100`-eq0];then
echo “$year is not a leap year”
if[`expr$year%year%4`-eq0];then
echo “$year is a leap year”
else
echo “$year is not a leap year”
fi
OUTPUT:
Q34: Write a Shell Script to Print the following triangle of number.
1
12
123
1234
12345
Code:
for((i=1;i<=5;i++))
do
for((k=1;k<=(5-i);k++))
do
echo -e "\c"
done
for((j=1;j<=i;j++))
do
echo -e "$j\c"
done
echo -e "\n"
done
OUTPUT:
Q35: Write a Shell Script to find number is EVEN or ODD.
Code:
echo "enter a no "
read x
y=`expr $x % 2`
if test $y -eq 0
then
echo "no is even "
else
echo "no is odd"
fi
OUTPUT:
Q36: Write a Shell Script to display the system date in format MM/DD/YY
and system time in hrs:mins:secs.
Code:
echo current date in required format MM/DD/YY
date +%D
echo current time in required format hrs:mins:secs
date +%T
OUTPUT:
Q37: Write a Shell Script to CONCATENATE two Files.
Code:
CAT > F1
CAT > F2
CAT F1 F2 > F3
CAT F3
Output:
Q38: Write a Shell Script to say HELLO to USER.
Code:
echo enter your name
read name
echo hello $name
OUTPUT:
Q39: Write a Shell Script to display name of users who are currently
logged in the system along with total number of user.
Code:
echo users currently logged in to computer along wid total no of users
who
a= who | wc -l
echo $a
OUTPUT:
Q40: Write a Shell Script to compute PALINDROME of a string.
Code:
echo "Enter a string to be entered:"
read str
echo
len=`echo $str | wc -c`
len=`expr $len - 1`
i=1
j=`expr $len / 2`
while test $i -le $j
do
k=`echo $str | cut -c $i`
l=`echo $str | cut -c $len`
if test $k != $l
then
echo "String is not palindrome"
exit
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
echo "String is palindrome"
OUTPUT
Q41: Write a Shell Script to REVERSE a number.
Code:
echo "Enter a number"
read n
sd=0
rev=0
while [ $n -gt 0 ]
do
sd=$(( $n % 10 ))
rev=$(( $rev *\ 10 + $sd ))
n=$(( $n / 10 ))
done
echo "Reverse number of entered digit is $rev"
OUTPUT:
Q42: Write a Shell Script to read a file and print alphabets and lines.
Code:
echo Enter the filename
read file
w=`cat $file | wc -w`
c=`cat $file | wc -c`
l=`grep -c "." $file`
echo Number of characters in $file is $c
echo Number of words in $file is $w
echo Number of lines in $file is $l
OUTPUT:
Q43: Write a Shell Script to CONCATENATE two STRINGS and find out the
LENGTH of concatenated string.
Code:
echo Enter first string:
read s1
echo Enter second string:
read s2
s3=$s1$s2
len=`echo $s3 | wc -c`
len=`expr $len - 1`
echo Concatinated stringis $s3 of length $len
OUTPUT: