Os Practicals
Os Practicals
Ques-1 Connect to the Linux Server and understand the basic Directory
Structure of Linux.
Code- Syntax- ssh username@server_ip
6. /lib (libraries)
Syntax:- ls /lib
Example- man ls
Example- info ls
3. help (Bash Built-in Help)
The ‘help’ command provides brief help for built-in shell commands in Bash.
Syntax:- help <command>
Example- help cd
Example- whatis ls
2. cd (Change Directory)
The cd command changes the current working directory.
Syntax:- cd <directory>
2. cal (Calendar)
The cal command displays a calendar of the current month or a specific
year/month.
Syntax:- cal
4. bc (Basic Calculator)
The bc command is an arbitrary-precision calculator.
Syntax:- bc
5. ls (List Directory Contents)
The ls command lists files and directories.
Syntax:- ls
2. Insert Mode:
Insert mode allows you to type and edit text.
3. Command-Line Mode:
This mode is used to save, quit, or execute commands.
The top command provides a dynamic, real-time view of running processes and
system resource usage. It displays CPU and memory usage, the number of
processes, and the load on the system.
Syntax:- top
The nice command is used to start a process with a modified priority level. Lower
priority processes receive fewer CPU resources compared to higher priority
processes.
The renice command allows you to change the priority of an already running
process.
Syntax:- ls -l <filename>
b. Numeric Mode
In numeric mode, file permissions are represented by numbers.
Syntax:- cd /path/to/directory
2. Set the file to read-only for the owner, group, and others using the chmod
command:
Syntax:- chmod 444 example.txt
Syntax:- ls -l example.txt
Ques-9 Delete one or more directories with the rmdir command. See what
happens if the directory is not empty. Experiment (carefully!) with the rm -r
command to delete a directory and its content.
Code- Commands:-
1. Deleting a empty directory
Syntax:- rmdir <empty_directory_name>
Can only delete empty directories. If the directory contains any files or sub
directories, it will not delete the directory and will display an error.
Syntax:- rmdir <non-empty_directory_name>
Deletes the directory along with all files and subdirectories inside it, regardless of
whether the directory is empty or not.
Syntax:- rm -r <directory_name>
Ques-10 Change your directory to the directory exercises. Create a file in that
directory, named the file as example1 using the cat command containing the
following text: water, water everywhere and all the boards did shrink; water,
water everywhere, no drop to drink.
Code- Commands:-
1. Change Directory to exercises
Syntax:- cd <directory_name>
3. Press Esc to leave insert mode and type :wq and press Enter to save and quit.
4. Give it execute permissions using the chmod and run the script using the following
command:
Ques-13 Write basic shell script to calculate factorial of a number.
Code- Commands:-
1. Open a terminal and create a new shell script file
3. Press Esc to leave insert mode and type :wq and press Enter to save and quit.
4. Give it execute permissions using the chmod and run the script using the following
command:
Ques-14 Write basic shell script to input the month number and generate
corresponding calendar
Code- Commands:-
1. Open a terminal and create a new shell script file
3. Press Esc to leave insert mode and type :wq and press Enter to save and quit.
4. Give it execute permissions using the chmod and run the script using the following
command:
Ques-15 Write basic shell script to list all directories.
Code- Commands:-
1. Open a terminal and create a new shell script file
3. Press Esc to leave insert mode and type :wq and press Enter to save and quit.
4. Give it execute permissions using the chmod and run the script using the following
command:
Ques-16 Write basic shell script to display greatest of three numbers.
Code- Commands:-
1. Open a terminal and create a new shell script file
3. Press Esc to leave insert mode and type :wq and press Enter to save and quit.
4. Give it execute permissions using the chmod and run the script using the following
command:
Ques-17 Write basic shell script to check whether the number entered by user is
prime or not.
Code- Commands:-
1. Open a terminal and create a new shell script file
3. Press Esc to leave insert mode and type :wq and press Enter to save and quit.
4. Give it execute permissions using the chmod and run the script using the following
command: