Linux Programming File
Linux Programming File
PWD
NAME
Syntax
pwd [OPTION]...
DESCRIPTION
OUTPUT:
2. MKDIR
NAME
SYNTAX
mkdir [OPTION]... DIRECTORY...
DESCRIPTION
OUTPUT:
3. CD
NAME
cd – change directories
SYNTAX
cd... DIRECTORY...
DESCRIPTION
OUTPUT:
4. RMDIR
NAME
SYNTAX
DESCRIPTION
OUTPUT:
5. LS
NAME
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
-r, --reverse
-R, --recursive
-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
-u with -lt: sort by, and show, access time with -l: show access
-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
SYNTAX
hostname [-v] [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-i] [--ip-address] [--long] [-s] [--short] [-y] [--yp]
[--nis]
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
DESCRIPTION
OUTPUT: (Merge)
8. BC
NAME
SYNTAX
VERSION
DESCRIPTION
NAME
SYNTAX
DESCRIPTION
OUTPUT:
10. CHMOD
NAME
SYNTAX
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.
NAME
SYNTAX
DESCRIPTION
OUTPUT:
12. RM
NAME
SYNTAX
rm [OPTION]... FILE...
DESCRIPTION
The RM command removes the files & directories from the current working directories.
OUTPUT:
13. DATE
NAME
SYNOPSIS
DESCRIPTION
Display the current time in the given FORMAT, or set the system date.
OUTPUT:
14. WHO
NAME
SYNOPSIS
DESCRIPTION
OUTPUT:
15. WHOAMI:
NAME
SYNOPSIS
whoami [OPTION]...
DESCRIPTION
Print the user name associated with the current effective user ID.
Same as id -un.
OUTPUT:
16. WHATIS
NAME
SYNOPSIS
whatis [-dlhvV] [-r|-w] [-s list] [-m system[,...]] [-M path] [-L
What is searches the manual page names and displays the manual page descriptions of any name
matched.
OUTPUT:
17. W
NAME
SYNOPSIS
w [-husfVo] [user]
DESCRIPTION
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
SYNOPSIS
year]
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‐
OUTPUT:
19. UNAME
NAME
SYNTAX
uname [OPTION]...
DESCRIPTION:
OUTPUT:
20. READ
NAME
SYNOPSIS
#include <unistd.h>
DESCRIPTION
PROGRAM:
OUTPUT:
21. ECHO
NAME
echo LONG-OPTION
DESCRIPTION
PROGRAM:
OUTPUT:
25. tr
NAME
SYNTAX
DESCRIPTION
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
-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
--version
output version information and exit .
OUTPUT:
26. CUT
NAME
SYNTAX
DESCRIPTION
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
SYNTAX
pr [OPTION]... [FILE]...
DESCRIPTION
OUTPUT
24. FILTER
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:
read first
read sec
read third
else
fi
else
else
fi
fi
OUTPUT
fact=1
read n
if [ $n -le 0 ] ; then
exit
fi
if [ $n -gt 0 ] ; then
for((i=$n;i>=1;i--))
do
done
fi
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
do
then
exit
fi
i=`expr $i + 1`
done
OUTPUT:
Q31: Write a Shell Script to print FIBONACCI Series.
Code:
c=0
a=1
b=1
while((c<n))
do
c=$((a+b))
a=$b
b=$c
done
echo -e "\n"
OUTPUT:
Q32: Write a Shell Script to SUM of digit of a number.
Code:
read n
sum=0
a=$n
while(($n >0))
do
x=`expr $n % 10`
n=`expr $n / 10`
done
OUTPUT:
Q33: Write a Shell Script whether a year is a LEAP YEAR or not.
Code:
read year
if[$year-le 0 ];then
fi
if[`expr$year%year%400`-eq0];then
elif[`expr$year%100`-eq0];then
if[`expr$year%year%4`-eq0];then
else
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:
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:
Output:
Code:
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:
read str
echo
len=`expr $len - 1`
i=1
j=`expr $len / 2`
do
if test $k != $l
then
exit
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
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 ))
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
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
read s2
s3=$s1$s2
len=`expr $len - 1`
OUTPUT: