[go: up one dir, main page]

0% found this document useful (0 votes)
8 views43 pages

Hehe Compressed

Uploaded by

RTTI TECH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views43 pages

Hehe Compressed

Uploaded by

RTTI TECH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

G H Raisoni College of Commerce, Science and Technology, Nagpur

Department of Science and Technology


Bachelor of Computer Applications- first-year
AY 2023-24
Subject: Linux Operating System

Index

Sr.No Practical Name Date of Submission


1 Execute the ls command with all options 02/03/2024
2 Execute mkdir command with all options 05/03/2024
3 Execute rmdir command with all options 07/03/2024
4 Execute rm command with all options 13/03/2024
5 Execute mv command with all options 17/03/2024
6 Execute cat command with all options 23/03/2024
7 Execute cp command with all options 27/03/2024
8 Execute Vi editor command with all options. 04/04/2024
9 Execute uname command with all options 08/04/2024
10 Execute the backup and restore command-tar, gzip and gunzip. 10/04/2024
11 Execute ps command with all options. 13/04/2024
12 Execute free command with all options 13/04/2024
13 Execute top utitlity command with all options 13/04/2024
14 Execute df commands with all options 18/04/2024
15 Execute du command with all options 18/04/2024
16 Execute who, who am i and grep command. 21/04/2024
17 Execute date, time command 21/04/2024
18 Write a Shell script for multiplication of two numbers 23/04/2024
19 Write a Shell script to perform division of two numbers 23/04/2024
20 Write a Shell script to check whether a number is positive or 29/04/2024
negative
21 Write a Shell script to find greatest of three numbers 07/05/2024
22 Write a Shell script to print numbers 1 to 100 using while loop 09/05/2024
23 Write a Shell script to print sum of all digit 13/05/2024
24 Write a Shell script to find largest of n numbers 17/05/2024
25 Write a Shell script to find average of n numbers 21/05/2024
26 Write a Shell script to find factorial of a number 24/05/2024
1) Execute the ls command with all options
1. To list directory contents

2. To display One File Per Line (ls -1):

3. To display total information about Files/Directories(ls -l):

4. To show all the hidden files(ls -a OR ls -A):

5. To display files Recursively (ls -R):

6. 7. To display file size in human readable form(ls -lh file/directory name):

7. To order files based on last modified time(ls -lt):


8. To Order Files Based on Last Modified Time in Dec-ending Order(ls -lrt):

9. To Stream output format; files are listed across the page, separated by commas(ls -m):

10. To List all subdirectories(ls *):

11. To Display File Inode Number(ls -i):

12. To sort files with Size(ls -S):

13. To list directories only(ls -d */):

14. Display File UID and GID (ls -n):


15. To Do Visual Classification of Files(ls -F):

16. To Open Last Edited File (ls -t):


2) Execute mkdir command with all options

1) Creating a Single Directory

2) Create Multiple Directories

3) Control Directory Permissions


Creates a directory named “sample” with read, write, and execute permissions for
the owner, group, and other users. The ls -l command displays permission
information.

4) Create Intermediate Directories with mkdir –p

5) Display Verbose Message

6) Check Version
7) Get help
3) Execute rmdir command with all options
1) Removes the directory mydir.

2) Remove DIRECTORY and its ancestors.


4) Execute rm command with all options
1) Remove a Specific File using the rm command

2) Delete a Directory and Its Contents

3) Delete Multiple Files

4) Force Deletion (-f option)

5) Prompt for Confirmation (-i option)

6) Removes directory

7) What being done-verbose


8) Help

9) Version
5) Execute mv command with all options

1) Rename a File

2) Rename a Directory with ‘mv’

3) Move a Directory

4) Move a File to Another Directory with a New Name

5) Move a File to Another Directory with the Same Name

6) To get help
7) To get version
6) Execute cat command with all options

1) Display the Contents of a File on the Screen (cat file_name)

2) Displaying the Contents of Multiple Files Using ‘cat’ (cat file_name1


file_name2….)

3) To create a New file (cat > file_name)

4) Displaying File Contents with Line Numbers (cat -n file_name)

5) Making Backups of Files (cat original_file_name > backup_file_name)

6) Displaying End of Every Line in a File (cat -ne file_name)

7) Display Tab Character in a Line of a File (cat -neT file_name)


7) Execute cp command with all options

1) Copy a file or directory from source to destination(cp source_path


destination_path):

2) A directory (and all its content) can be copied from source to destination with
the recursive option -r(cp -r source destination)

3) Copy multiple files or directories (cp file1 file2 source destination):

4) Confirm before overwriting in a interactive mode(cp -i source destination):

5) To show copying details in a verbose manner(cp -v source destination)


8. Execute Vi editor command with all options.

1. Command for Navigation:


• h, j, k, l: Move left, down, up, and right respectively.

• Ctrl + f: Move forward one screen.

• Ctrl + b: Move backward one screen.


• $: Move to the end of the line.

• 0 (zero): Move to the beginning of the line.

2. Editing:
• x: Delete the character under the cursor.

• dd: Delete the entire line.

• yy: Yank (copy) the entire line.

• p: Paste the yanked or deleted text after the cursor.


• u: Undo the last change.

• P: Paste the yanked or deleted text before the cursor.

3. Search and Replace:


• /pattern: Search forward for the pattern.

• ?pattern: Search backward for the pattern.

• :s/old/new/g: Replace all occurrences of 'old' with 'new' in the current line.
• :%s/old/new/g: Replace all occurrences of 'old' with 'new' in the entire file.
9. Execute uname command with all options

uname –a: all the information can be printed At once by running uname –a

uname –m: Print machine hardware name

uname –r: to get information about your kernel release

uname –v: to get information about the kernel version

uname –n: to view network hostname.

uname: To print the kernel name of you system.


10. Execute the backup and restore command-tar, gzip and gunzip.

1. gzip command

2. gunzip command

3. tar command
11) Execute ps command with all options.
1: List processes in the current shell (ps)

2: List every process running currently on the system (ps -ef OR ps -aux)

3: List every process on the system using BSD syntax (ps aux)

4: Print a process tree (ps -ejH)

5: Print every process running as root (ps -U root -u root u)


6. Display threads of process (ps –p 3150 –L)

7: List all processes of a specific user (ps -u user_name1,user_name2…)

8: List Processes in a Hierarchy tree (ps -e … –forest)

9: Finding memory Leakage (ps aux –sort pmem)

10. Generates a full listing of processes.


12) Execute free command with all options
1. To get the memory information in bytes, add the '-b' option to the command

2. When the free command is used alone, as was demonstrated earlier, without any option, the default
display of the memory is in kilobytes.

3. To view the memory information in megabytes, add the '-m' option to the command

4. To view the memory information in gigabytes, add the '-g' option to the command

5. To view the memory information in human-readable format, add the '-h' option to the command
13) Execute top utility commands with all options.
1.-d, --delay: Specifies the delay between updates in seconds. By default, top updates every 3 seconds.

2. -n, --iterations: Specifies the number of iterations top should run before exiting.

3. -b, --batch: Runs top in batch mode. This is useful for redirecting the output of top to another
program or file.

4. -c, --command: Shows the command line of the processes. This option displays the full command
that launched the process.
5. -i, --ignore-case: Ignores case when searching or sorting.

6. -u, --user: Limits top to display only processes owned by a specific user or users.

7. -p, --pid: Monitors specific process IDs (PIDs). This option allows you to specify one or more PIDs
to monitor.

8. -U, --user=USERNAME: Displays processes owned by a specific user. This is similar to the -u
option, but allows you to specify the username directly.
9. -H, --threads: Enables displaying individual threads for each process. This can provide more
detailed information about thread usage.
14. Execute df commands with all options
1. -a: Shows information about all filesystems, including those with a size of zero blocks.

2. -h: Provides human-readable output, displaying sizes in a more understandable format (e.g., KB,
MB, GB).

3. -T: Displays the filesystem type for each filesystem.

4. -t ext4: Limits the output to only show filesystems of type ext4. You can replace ext4 with any
other filesystem type you want to filter.

5. -x tmpfs: Excludes filesystems of type tmpfs from the output.


6. -l: Shows detailed information about each filesystem, including the number of used and available
inodes.

7. --sync: Forces df to synchronize its output by opening and closing the filesystems being analyzed.

8. -P: Provides POSIX output format, ensuring compatibility with scripts and easier parsing of output.

9. -B 1M: Sets the block size to 1 megabyte.

10. --total: Adds a summary line at the end of the output, showing total usage across all filesystems.
11. --block-size=1G: Sets the block size to 1 gigabyte.

12. --help: Displays a brief help message summarizing the usage of the df command.
15) Execute du command with all options
1. -a: Displays counts for all files, not just directories.

2. -c: Produces a grand total of all file sizes listed.

3. -h: Outputs sizes in a human-readable format (e.g., 1K, 2M, 3G).

6. /: Specifies the directory to start the disk usage analysis. In this case, it starts from the root
directory.
6. df –b : It will sow the file size in kbs
16) Execute who, who am i, and grep command.
1. Who command: who command is a tool print information about users who are currently logged in.
who command only see a real user who logged in.

2,. Whoami: The 'whoami' command in Linux is a built-in utility that displays the username of the
current user

3. Combining "who" and "am i" to get detailed information:

This command combines the output of "who" with the current username obtained from "whoami"
using a pipe and then filters the output to display only information about the current user.
17. Execute date and time command
1. Displaying the current date and time:

2. Displaying the date and time in a specific format:


$ date +"%Y-%m-%d %H:%M:%S"

This command will display the current date and time in the format "YYYY-MM-DD HH:MM:SS".
You can customize the format as needed by adjusting the format string within the double quotes.
3. Displaying the date only:
$ date +"%Y-%m-%d"

This command will display only the current date in the format "YYYY-MM-DD".
4. Displaying the time only:
$ date +"%H:%M:%S"

This command will display only the current time in the format "HH:MM:SS".
5. Displaying the day of the week:
$ date +"%A"

This command will display the current day of the week in full format (e.g., "Monday", "Tuesday",
etc.).
18. Write a Shell script to multiplication of two numbers

Program
num1=10
num2=20

ans=$((num1 * num2))

echo $ans

Output
19. Write a Shell script to calculate Division of two numbers

Program
num1=100
num2=20

ans=$((num1 / num2))

echo $ans

Output
20. Write a Shell script to check whether a number is positive or negative

Program
echo "Enter a Number"
read num

if [ $num -lt 0 ]
then
echo "Negative"
elif [ $num -gt 0 ]
then
echo "Positive"
else
echo "Neither Positive Nor Negative"
fi

Output
21. Write a Shell script to find greatest of three numbers

Program
echo "Enter Num1"
read num1
echo "Enter Num2"
read num2
echo "Enter Num3"
read num3

if [ $num1 -gt $num2 ] && [ $num1 -gt $num3 ]


then
echo $num1
elif [ $num2 -gt $num1 ] && [ $num2 -gt $num3 ]
then
echo $num2
else
echo $num3
fi

Output
22. Write a Shell script to Print numbers 1 to 100 using while loop

Program
i=1
while [ $i -le 100 ]
do
echo $i i=$
(($i+1))
done

Output
23. Write a Shell script to print sum of all digit

Program
echo "Enter a number"
read num

sum=0

while [ $num -gt 0 ]


do
mod=$((num % 10)) sum=$
((sum + mod)) num=$((num /
10))
done

echo $sum

Output
24. Write a Shell script to find largest of n numbers

Program
echo "Enter Size(N)"
read N

i=1
max=0

echo "Enter Numbers"


while [ $i -le $N ]
do
read num
if [ $i -eq 1 ]
then
max=$num
else
if [ $num -gt $max ]
then
max=$num
fi
fi
i=$((i + 1))
done

echo $max

Output
25. Write a Shell script to find average of n numbers

Program

echo "Enter Size(N)"


read N

i=1
sum=0

echo "Enter Numbers"


while [ $i -le $N ]
do
read num sum=$
((sum + num)) i=$
((i + 1))
done

avg=$(echo $sum / $N | bc -l)

echo $avg

Output
26. Write a Shell script to find factorial of a number

Program
echo "Enter a number"
read num

fact=1

for((i=2;i<=num;i++))
{
fact=$((fact * i))
}

echo $fact

Output

You might also like