0% found this document useful (0 votes)
10 views5 pages

Linux Commands and Scripting Guide 2024

Uploaded by

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

Linux Commands and Scripting Guide 2024

Uploaded by

1603swatisingh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

OSY Practical Questions and Answers 2024-25

1. Write theory & procedure for installing and configuring Linux/Ubuntu operating systems.

To install and configure Ubuntu:

- Download the ISO image from the Ubuntu official site.

- Create a bootable USB using tools like Rufus or Etcher.

- Boot your system from the USB by modifying BIOS/UEFI settings.

- Follow the installation prompts to set up partitions, time zones, user accounts, etc.

- Post-installation, update the system using 'sudo apt update && sudo apt upgrade'.

- Configure settings such as network, firewall (ufw), and user permissions as required.

2. Execute and explain general-purpose commands date, time, cal, clear, banner, tty, script,

man.

General purpose commands:

- `date`: Displays the current date and time.

- `time`: Measures the duration of command execution.

- `cal`: Shows the calendar for a month or year.

- `clear`: Clears the terminal screen.

- `banner`: Creates ASCII art-style text (requires installation).

- `tty`: Displays the terminal name being used.

- `script`: Records terminal session to a file.

- `man`: Displays manual pages for commands.

3. Execute and explain basic commands: who, who am i, login, passwd, su, pwd.

Basic commands:

- `who`: Lists logged-in users.

- `who am i`: Shows your session information.

- `login`: Logs in to a session (used rarely in modern systems).


- `passwd`: Changes the user password.

- `su`: Switches the user.

- `pwd`: Prints the current working directory.

4. Execute and explain commands to start, stop and restart the specified service in Linux.

Service management:

- Lightdm: `sudo systemctl start|stop|restart lightdm`

- kmod: `sudo systemctl start|stop|restart kmod`

- cron: `sudo systemctl start|stop|restart cron`

- udev: `sudo systemctl start|stop|restart udev`

5. Execute and explain process-related commands: ps, wait, sleep, exit, kill.

Process-related commands:

- `ps`: Lists active processes.

- `wait`: Waits for a process to complete.

- `sleep`: Pauses execution for a specified time.

- `exit`: Exits a terminal or script.

- `kill`: Terminates a process by PID.

6. Execute and explain file and directory manipulation commands.

Commands:

- `ls`: Lists files and directories.

- `rm`: Removes files.

- `mv`: Moves or renames files.

- `cp`: Copies files or directories.

- `join`: Combines lines from two files based on a common field.

- `split`: Splits a file into smaller parts.

- `cat`: Concatenates files; can redirect output to another file.


- `head`: Displays the beginning of a file.

- `tail`: Displays the end of a file.

- `touch`: Creates empty files.

7. Execute file and directory manipulation commands (with wildcards).

Commands:

- `diff`: Compares file differences.

- `comm`: Compares two sorted files.

- `pr`: Formats text for printing.

- `chmod`: Changes file permissions.

- `mkdir`: Creates a directory.

- `rmdir`: Removes an empty directory.

- `cd`: Changes the working directory.

- `pwd`: Prints the working directory.

- `cmp`: Compares two files byte-by-byte.

8. Execute and explain text processing commands.

Commands:

- `tr`: Translates or deletes characters.

- `wc`: Counts words, lines, and characters.

- `cut`: Extracts fields from lines.

- `paste`: Joins lines from files side-by-side.

- `spell`: Checks for spelling errors in a file.

- `sort`: Sorts lines in a file.

- `grep`: Searches for patterns in files.

- `more`: Paginates file output.

9. Use vi editor and perform all important VI editor commands and explain them.
VI editor commands:

- `i`: Insert mode.

- `:w`: Save changes.

- `:q`: Quit editor.

- `:wq`: Save and quit.

- `/pattern`: Search for a pattern.

- `dd`: Delete a line.

- `u`: Undo last change.

10. Write, execute & explain the Shell Script by using the 'if' statement.

Example:

```bash

if [ $1 -gt 0 ]; then

echo 'Positive number'

else

echo 'Non-positive number'

fi

```

11. Write, execute & explain the Shell Script by using the 'for' statement.

Example:

```bash

for i in {1..5}; do

echo $i

done

```

12. Write, execute & explain the Shell Script to check file permissions.
Example:

```bash

if [ -r file ]; then echo 'Readable'; fi

if [ -w file ]; then echo 'Writable'; fi

if [ -x file ]; then echo 'Executable'; fi

```

You might also like