0% found this document useful (0 votes)
14 views7 pages

OPERATING SYSTEMS (LAB 2 WITH FORMAT)

Uploaded by

tasawarnawax190
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)
14 views7 pages

OPERATING SYSTEMS (LAB 2 WITH FORMAT)

Uploaded by

tasawarnawax190
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
You are on page 1/ 7

“OPERATING SYSTEMS”

PROF SHAHID FARID

LAB : 02:
BASIC SHELL COMMANDS:

 pwd: Prints the current working directory path.


 ls: Lists files and directories in the current
directory.
 cd [directory]: Changes the current directory. Use
`cd ..` to go up one level.
 mkdir [directory]: Creates a new directory.
 rmdir [directory]: Removes an empty directory.
 rm [file|directory]: Removes files or directories. Use `rm -r
[directory]` to remove directories recursively.
 cp [source] [dest]: Copies files or directories. Use `cp -r
[source_directory] [dest]` to copy directories.
 mv [source] [dest]: Moves or renames files or directories.
 touch [file]: Creates a new empty file or updates the
timestamp of an existing file.
 cat [file]: Displays the contents of a file.
 more [file]: Views the content of a file one page at a
time.
 less [file]: Similar to `more`, but allows backward
movement in the file.
 head [file]: Displays the first few lines of a file (default
is 10 lines).
 tail [file]: Displays the last few lines of a file (default is
10 lines).
 man [command]: Displays the manual pages for
commands.
 echo [text]: Displays a line of text or the value of a
variable.
 env: Displays the environment variables.
 set: Sets or unsets shell attributes and positional
parameters.
 export [variable]: Exports a variable to the environment
of subsequently executed commands.
 alias [name]='[cmd]': Creates an alias for a command.
 unalias [name]: Removes an alias.
 history: Displays the command history.
 clear: Clears the terminal screen.
 find [path] -name [pattern]: Searches for files in a directory
hierarchy.
 grep [pattern] [file]: Searches for patterns in files.
 wc [file]: Counts lines, words, and characters in a
file.
 cut -d [delimiter] -f [field] [file]: Removes sections from each
line of files.
 sort [file]: Sorts lines of text files.
 uniq [file]: Reports or omits repeated lines.
 diff [file1] [file2]: Compares files line by line.
 tar [options] -f [archive_file] [files]: Archives multiple files
into one file.
 gzip [file]: Compresses files using the Lempel-Ziv
coding (LZ77).
 ping [host]: Checks network connectivity to a server.
 traceroute [host]: Traces the route packets take to a
network host.
 ssh [user]@[host]: Securely connects to a remote server.
 scp [source] [user]@[host]:[dest]: Securely copies files
between hosts on a network.
 ftp [host]: Transfers files between a client and a
server.
 curl [options] [URL]: Transfers data from or to a server
using various protocols.
 wget [URL]: Downloads files from the web.
 ps: Reports a snapshot of current processes.
 top: Displays dynamic real-time information
about running processes.
 kill [PID]: Sends a signal to a process, usually to
terminate it.
 chmod [permissions] [file]: Changes file permissions.
 chown [owner]:[group] [file]: Changes file owner and group.
 df: Displays disk space usage for file systems.
 du [file|directory]: Displays disk usage of files and
directories.
 mount [device] [mount_point]: Mounts a file system.
 umount [mount_point]: Unmounts a file system.
 shutdown [options]: Shuts down or reboots the system.
 reboot: Reboots the system.
 whoami: Displays the current user's username.
 uname [options]: Displays system information.
 uptime: Shows how long the system has been
running.
 date: Displays or sets the system date and time.
 cal: Displays a calendar.
 bc: An arbitrary precision calculator language.
 jobs: Lists active jobs in the current session.
HELPING MATERIAL

chmod Command:
What is chmod?

The chmod command is used to change the file permissions of a file or directory in
Unix and Linux systems. Permissions determine who can read, write, or execute a file.

Understanding File Permissions

In Linux, every file and directory has three types of permissions:

 Read (r): Permission to read the contents of a file or list the contents of a directory.
 Write (w): Permission to modify the contents of a file or add/delete files in a directory.
 Execute (x): Permission to run a file as a program or script.

Permission Levels

Permissions can be set for three categories of users:

 Owner: The user who owns the file.


 Group: Other users who are part of the file's group.
 Others: All other users.

How to Use chmod:

You can use either symbolic or numeric notation to set permissions.

Symbolic Notation

 To add permission: +
 To remove permission: -
 To set permission: = (exactly that permission)

EXAMPLES
 chmod u+x filename

 chmod o-w filename


TAR COMMAND:
Basic syntax:
tar [options] [archive-file] [file-or-directory-to-archive]

Common Options
 -c: Create a new archive.
 -x: Extract files from an archive.
 -t: List the contents of an archive.
 -f: Specifies the name of the archive file (this option is required).
 -v: Verbosely list files processed (optional, for visibility).
 -z: Compress the archive using gzip (optional).
 -j: Compress the archive using bzip2 (optional).
 -C: Change to a directory before performing operations (optional).

TASKS
Task 1: File Management
1. Create a new directory called Lab_Manual.
2. Inside Lab_Manual, create three subdirectories: Commands, Scripts, and Notes.
3. Create a text file in the Notes directory called summary.txt and write a summary of
basic shell commands.

Task 2: File Permissions


1. Create a file named data.txt in the Lab_Manual directory.
2. Change the file permissions to read and write for the owner, and read-only for the
group and others.
3. Verify the permissions using the ls -l command.

Task 3: Process Management


1. Use the top command to view running processes.
2. Identify a process that you want to terminate and note its PID (Process ID).
3. Use the kill command to terminate the process.

Task 4: Networking
1. Use the ping command to check the connectivity to google.com.
2. Use the traceroute command to trace the path taken to reach google.com.

Task 5: File Compression and Archiving


1. Create a directory called Backup in Lab_Manual.
2. Move all files from Lab_Manual/Notes to Backup.
3. Create a compressed archive of the Backup directory using the tar command.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy