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

Lab 2

cpu scheduling

Uploaded by

kalyanamroshan
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)
22 views5 pages

Lab 2

cpu scheduling

Uploaded by

kalyanamroshan
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/ 5

1.

Nano : is a simple text editor


EX: nano file1.txt

Helloo
This is a file created using nano
Ctrl+s (save)
Ctrl+x (exit)

2. mv pp1/dd.txt newdir
(dd.txt is a file present in pp1 directory, newdir is another directory) dd.txt is
moved to newdir.
3. The chmod command in Unix is used to change the file mode (permissions)
of files and directories. This command allows you to control who can read,
write, or execute a file, thereby managing access permissions for users and
groups.
File permissions are typically represented in three categories:
 Owner: The user who owns the file.
 Group: A group of users who have specific permissions on the file.
 Others: All other users.
Each category can have three types of permissions:
 Read (r): Permission to read the file.
 Write (w): Permission to modify the file.
 Execute (x): Permission to execute the file (if it is a program or script).
Numeric Mode:
Permissions can be set using a numeric (octal) representation:
 0: No permission
 1: Execute (x)
 2: Write (w)
 3: Write and execute (wx)
 4: Read (r)
 5: Read and execute (rx)
 6: Read and write (rw)
 7: Read, write, and execute (rwx)
you can also use symbolic notation to set permissions:
 u: User (owner)
 g: Group
 o: Others
 a: All (user, group, others)
 +: Adds permission
 -: Removes permission
 =: Sets exact permission
To give the owner full permissions (read, write, execute), the group read and
execute permissions, and others no permissions:

chmod 750 example.txt


To add execute permission for the owner: chmod u+x
example.txt
To remove write permission for the group: chmod g-w
example.txt
To set read and write permissions for the owner, and read
permissions for the group and others: chmod u=rw,g=r,o=r
example.txt

PROCESS COMMANDS:
The ps (process status) command in Unix and Linux is used to display
information about the currently running processes. This command provides
details about processes such as their process IDs (PIDs), the users who own
them, and the commands that started them.
os40@redhat-OptiPlex-3060:~$ ps
PID TTY TIME CMD
13657 pts/31 00:00:00 bash
13872 pts/31 00:00:00 ps
 PID (13657): This is the unique identifier for the first process.
 TTY (pts/31): (Terminal type). This indicates that the process is running on
pseudo-terminal 31.
Pseudo-terminals (pts) are used for remote terminal sessions, such as SSH
connections.
 TIME (00:00:00): This indicates that the process has used 0 seconds of
CPU time so far. This is common for processes that are mostly idle or have
just started.
 CMD (bash): This is the command that started the process, which in this
case is bash. Bash is a Unix shell and command language.
 CMD (ps): This is the command that started the process, which in this
case is ps. The ps command is used to display information about active
processes.

OPTIONS:

 -e or -A: Display information about all processes in different terminals. Ex:


ps -e
 -f: Display full-format listing. Ex: ps -f
 -u [user]: Display processes for a specific user. Ex: ps -u os30
 -p [pid]: Display information about a specific process by PID. Ex: ps -p
7479
 -l: Display a long-format listing. Ex: ps -l
The kill command in Unix/Linux is used to send signals to processes, typically
to terminate them.
 SIGTERM (15): Gracefully terminate the process. This is the default
signal.
 SIGKILL (9): Forcefully terminate the process. Cannot be ignored or
handled by the process.
 SIGHUP (1): Hang up signal. Often used to reload configuration files.
 SIGINT (2): Interrupt from keyboard (similar to Ctrl+C).
Ex: kill 1234
Kill -9 1234
Kill -L ( listing all signals)
Kill -1 1234 or kill -HUP 1234
The top command is used to display real-time information about the processes
running on the system. It provides a dynamic, interactive view of system
performance, including CPU and memory usage, allowing users to monitor
processes and their resource consumption.
Ex: top
The nice command can increase or decrease the priority of a process. A lower
nice value (higher priority) allows a process to use more CPU time, while a higher
nice value (lower priority) restricts CPU time.
Default Nice Value: When a process starts, it has a default nice value of 0. The
range of nice values is typically from -20 (highest priority) to 19 (lowest
priority).
Example:
 pgrep sleep (returns pid of sleep=27057)
 ps -o pid,ppid,ni,cmd -p 27057
PID PPID NI CMD
27057 1316 10 sleep 60
 nice -n 15 sleep 60 (change priority of sleep to 15)
 To change the nice value of a process with PID 1234 to 10: renice 12 -p
27057
Networking commands:
Ping:
The ping command is a network utility used to test the reachability of a host
(usually a computer or server) on a network. It works by sending Internet Control
Message Protocol (ICMP) Echo Request packets to the target host and waiting for
Echo Reply packets. This helps determine whether the host is reachable and
measures the round-trip time for messages sent to the destination.
Ex: Ping google.com
ping -c 4 google.com
The ifconfig command (short for "interface configuration") is a network utility
in Unix/Linux systems used to configure and manage network interfaces. It
displays information about the network interfaces on the system, including their
status, IP addresses, and other network-related settings.
The netstat command (short for "network statistics") is a network utility in
Unix/Linux systems that provides information about network connections, routing
tables, interface statistics, and more. It helps in monitoring network traffic and
diagnosing network issues.
Netstat
Netstat -t
Netstat -u
Netstat -s
The route command in Unix/Linux systems is used to view and manage the
routing table. The routing table contains information about the paths that
network packets take to reach different network destinations.
The ssh command (Secure Shell) is a network protocol used to securely
connect to remote computers over a network. It provides a secure channel for
logging into another computer and executing commands remotely. SSH encrypts
the data transmitted over the network, making it more secure than other
protocols like Telnet or FTP
The scp command is a powerful and secure method for transferring files
between local and remote systems in Unix/Linux environments.
Copy a File from Local to Remote:
 os40@redhat-OptiPlex-3060:~$ scp prashu/dd.txt os39@redhat-
OptiPlex-3060:
os39@redhat-optiplex-3060's password: itlab3

 os40@redhat-OptiPlex-3060:~$ scp prashu/uu.txt os39@redhat-


OptiPlex-3060:~/ss
os39@redhat-optiplex-3060's password: itlab3
ifconfig:

You might also like