Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

Linux Programming Solution

BLP Solution

Uploaded by

amaankazi1793
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Linux Programming Solution

BLP Solution

Uploaded by

amaankazi1793
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

LINUX PROGRAMMING Q.

B SOULTION
BY anonymous

1. Aim :-EXECUTE GENERAL PURPOSE LINUX


COMMANDS(cal,printf,bc,clear,script)

USE:
1. cal: This command displays a calendar for current month
2. printf: This command is used for formatted printing. You can
use it to print text with specific formatting.
3. bc: This is a calculator that supports floating-point arithmetic
and mathematical functions.
4. clear: This clears the terminal screen.
5. Script: This command starts a typescript of your terminal
session,saving all input and output of a file.
OUTPUT:
2. Aim :-EXECUTE GENERAL PURPOSE LINUX
COMMANDS(echo,date,malix,man)

Use:
1. Echo: This command is used to display text on terminal
2. date: This command is used to display the current date and
time.
3. Malix: This command is used for sending and receiving email
from the command line
4. man: this command is used to display the manual pages for
other commands
OUTPUT:
3. Aim :-EXECUTE GENERAL PURPOSE LINUX
COMMANDS(passwd,who,whoami,ps)

Use:
1. Passwd: This command is used to change a users password.
When you run this command it asks you to enter a old
password and after entering, it asks you to enter a new
password.
2. Who: This command shows information about the users who
are currently logged in to the system, including their
username, terminal, login time and remote host.
3. Whoami: this command prints the username of the current
user who is logged in.
OUTPUT:

4. Aim :-EXECUTE GENERAL PURPOSE LINUX


COMMANDS(tty,stty,ps,kill,sleep)

Use:
1.tty: This command prints the filename of the terminal
connected to the standard input
2.stty: This command is used to display or modify terminal
settings.
3.ps: This command is used to display information about active
processes running on the system
4.kill: This command is used to terminate processes based on
their process ID(PID).
5.Sleep: This command is used to pause the execution for a
specific amount of time.
OUTPUT:

5. Aim :-EXECUTE FILE AND DIRECTORY MANIPULATION LINUX


COMMANDS(pwd,cd,mkdir,rmdir,file)

Use:
1.pwd: This command prints the current working directory
2.Cd: This command is used to change directories
3.mkdir: This command is used to make new directories
4.rmdir: This command is used to remove an empty directory
5.file: This command is used to determine the type of file

OUTPUT:
6. Aim :-EXECUTE FILE AND DIRECTORY MANIPULATION LINUX
COMMANDS(ls,cat,cp,mv,rm)
Use:
1.ls: This command is used to display the contents of current
directory
2.cat: This command is used to display the contents of file
3.cp: This command is used to copy files into another directory
4.mv: This command is used to move files into specific directory
5.mv: This command is used to rename the files.
6.rm: This command is used to remove files or directories
7. Aim :-EXECUTE FILE AND DIRECTORY MANIPULATION LINUX
COMMANDS(lp,touch,wc,cmp)

Use:
1.lp: This command is used to print documents
2.touch: This command is used to create files\
3.wc: This command is used to count words,lines and characters
in a file
4.cmp: This command is used to compare files byte by byte
OUTPUT:

8. Aim :-EXECUTE FILE AND DIRECTORY MANIPULATION LINUX


COMMANDS(more,comm,diff,split)

Use:
1.more: This command is used to view the conent of file one
screen at a time.
2.comm: This command is used to compare two files line by
line.it can display the files that are unique to each file and that
are common between the two files
3.diff: This command is used to compare the contents of two
text files and display the diffrences between them
4.split: This command is used to spilt the file into smaller parts
OUTPUTS:
9. Aim :-EXECUTE LINUX COMMANDS FOR
COMPRESSING,DECOMPRESSING AND ARCHIVING FILE
(gzip,gunzip,tar,zip,unzip)

Use:
1.gzip: This command is used to compress files
2.gunzip: This command is used to decompress a file
3.tar: This command is used to archive files and directories into a
single file
4.zip: This command is used to compress files into a zip archive
5. unzip: This command is used to unzip a zip archive

OUTPUT:
10.Aim :- CHANGE FILE AND DIRECTORY PERMISSIONS(ls
commands,chmod(with all options),chown,chgrp)

Use: 1. ls command
1.ls -a: List all files including hidden files starting with ‘. ‘.
2.ls -l: list with long format- show permissions
3.ls -r: list in reverse order
4. ls -i : lists file index number
4.ls -ltr: view reverse output order by date.
5.ls -t : sort by time and date
6.ls -n: It is used to print group id and owner id instead of their
name.
7.ls -m: A list of files seprated by commas
8.ls -Q: place double quotations around file names.

2.chmod: This command is used to change the file permissions


Use:
1.chmod u+rwx: This command is used to give the owner
read,write and execute permissions on a file.
2.chmod u+x: This command is used to give all permissions to a
file
3.chmod g-w filename: This command is used to remove write
permission for the group on the same file.
4. chmod u+s: sets the UID(user id)bit,which allows the file to be
executed with the permissions of the file’s owner.
3.Chown: This command is used to change the Owner of a file or
directory.
4.chgrp: This command is used to the group ownership of a file
or directory.
Here is a example:(chown and chgrp)

cd ~ # Navigate to your home directory


ls -l example.txt # Check current ownership and
permissions
chown john example.txt # Change ownership of example.txt to
john
ls -l example.txt # Verify ownership change
chgrp newgroup myfile.txt

OUTPUTS:
11.Aim: USE THE VI EDITOR TO CREATE AND EDIT FILES

Use:
vi is a text editor that is commonly used in Unix and Linux systems. It
stands for "visual editor." vi is known for its powerful editing capabilities
and is often used by system administrators, programmers, and other
users who work extensively with text files in a terminal environment.

OUTPUT
12.Execute Input and Output redirection in Linux

Use:
Input and output redirection in Linux lets you control
command input and output destinations. Use > to redirect
standard output to a file (command > output.txt), >> to
append to a file, and < to read input from a file (command <
input.txt).

OUTPUT:
13.EXECUTE THE FOLLOWING FILTERS COMMAND IN LINUX
(head,tail,cut,paste,tr)

USE:
1.head: This command is used to display first few lines of a
file.
2.tail: This command is used to display last few lines of a file
3.cut: This command is used to extract specific columns from
from a file
4.paste: This command is used to merge lines of files
horizontally(side by side).
5.tr: This command is used to translating or deleting
characters.
14. Execute filters command in linux(grep,egrep,sed,sort,uniq)

USE:
1.grep: This command is used to search for patterns in file
2.egrep: This command is used to search specific words or letters
in the file
3.sed: This command is used to interchange numbers and letters
of a specific word
4.sort: This command is used to sort the lines of a file in ascending
order.
5.uniq: It is used to filter repeated lines in a sorted file.
Output:
15.Aim: EXECUTE SHELL SCRIPT BY USING IF STATEMENT
USE: The if statement in shell scripting is used to execute a
block of commands based on a specified condition. It allows
scripts to make decisions and perform different actions
depending on whether the condition is true or false. This is
particularly useful for implementing logic such as checking
user input, handling file existence or permissions, validating
variables, and controlling program flow.
OUTPUT:
16.Aim:- EXECUTE SHELL SCRIPT BY USING WHILE LOOP
USE:
The while loop in shell scripting executes a block of commands
as long as a specified condition is true. It's vital for tasks
requiring repetitive actions until a condition is met or a set
number of iterations is reached. Common uses include
continuous processing of input, iteration control based on
counters, and dynamic automation tasks
OUTPUT:
17.Aim:- EXECUTE SHELL SCRIPT BY USING FOR LOOP

USE: The for loop in shell scripting is used to iterate over


a list of items and perform a set of commands for each
item in the list. It allows scripts to automate repetitive
tasks that involve processing elements from a predefined
set or range. This loop is particularly useful for tasks such
as processing files in a directory, iterating over array
elements, or executing commands with different
arguments.
OUTPUT:

You might also like